在 Jmeter Junit 测试的设置中使用 JDBC
我试图在通过 Jmeter 运行的 Junit 测试的设置和拆卸方法中使用 JDBC 连接到我的 MySQL 数据库。 Jmeter 将创建多个线程,每个线程将运行我的测试的一个实例。
我遇到的问题是,如果我在 Junit 测试的设置中实例化我的数据源,那么我的连接池就会耗尽连接。有没有办法设计我的测试以避免这种情况发生?我试图避免增加最大 MySQL 连接数来解决这个问题。
I was trying to use the JDBC to connect to my MySQL database in the setup and teardown methods of my Junit tests that are being run through Jmeter. Jmeter will create multiple threads, each of which will run one instance of my test.
The issue that I run into, is if I instantiate my datasource in the setup of my Junit test, then my connection pool runs out of connections. Is there a way to design my test so that this does not happen? I'm trying to avoid increasing my max MySQL connections to solve this issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,请确保每个测试都关闭连接并在完成后将其返回到池中。听起来好像没有发生,但我不能确定。
如果情况并非如此,我建议更好地调整连接和线程池大小,以免耗尽。
Yes, make sure that each test closes the connection and returns it to the pool when it's done. Sounds like that's not happening, but I can't be sure.
If that's not the case, I'd recommend tuning your connection and thread pool sizes better so you don't run out.
一些建议:
A couple suggestions: