Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

并发测试 #29

Open
ghost opened this issue Nov 20, 2018 · 1 comment
Open

并发测试 #29

ghost opened this issue Nov 20, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Nov 20, 2018

可以使用testng进行并发测试,发现错误

@Test(threadPoolSize = 5001, invocationCount = 5002, timeOut = 1000000)
    public void testExecute() {
        RestTemplate template = new RestTemplate();

        HttpHeaders headers = new HttpHeaders();
        List<String> cookies = new ArrayList<>();
        cookies.add("userPhone=" + "1737467" + Phone++);
        headers.put(HttpHeaders.COOKIE, cookies);
        HttpEntity request = new HttpEntity(null, headers);

        long start = System.currentTimeMillis();
        String s = template.postForObject("http://localhost:8080/seckill/1000/bf204e2683e7452aa7db1a50b5713bae/execution", request, String.class);
        long end = System.currentTimeMillis();

        log.info("{}|{}ms ,res|{}",Thread.currentThread().getId(),(end - start),s);
    }

org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

@ghost
Copy link
Author

ghost commented Nov 20, 2018

不要用c3p0 2005年的东西

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants