Skip to content

并发测试 #29

@ghost

Description

可以使用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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions