使用jmeter执行负载测试时出错

时间:2017-10-16 06:06:11

标签: jmeter performance-testing load-testing

我正在尝试使用JMeter执行负载测试,其中我使用HTTP脚本记录器记录了脚本。现在我必须对多个用户执行相同的测试,因此使用包含5个用户的详细信息的.csv文件。现在在为5个用户配置后运行测试脚本并假设有5个HTTP请求。然后一些请求未能显示以下错误: -

Connector.php第55行中的PDOException: SQLSTATE [HY000] [1045]拒绝用户访问'伪造' @' localhost' (使用密码:否)

in Connector.php line 55
at PDO->__construct('mysql:host=localhost;port=3306;dbname=forge', 'forge', '', array('0', '2', '0', false, false)) in Connector.php line 55
at Connector->createConnection('mysql:host=localhost;port=3306;dbname=forge', array('driver' => 'mysql', 'host' => 'localhost', 'port' => '3306', 'database' => 'forge', 'username' => 'forge', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'timezone' => '+00:00', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, false)) in MySqlConnector.php line 22
at MySqlConnector->connect(array('driver' => 'mysql', 'host' => 'localhost', 'port' => '3306', 'database' => 'forge', 'username' => 'forge', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'timezone' => '+00:00', 'strict' => false, 'name' => 'mysql')) in ConnectionFactory.php line 60
at ConnectionFactory->createSingleConnection(array('driver' => 'mysql', 'host' => 'localhost', 'port' => '3306', 'database' => 'forge', 'username' => 'forge', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'timezone' => '+00:00', 'strict' => false, 'name' => 'mysql')) in ConnectionFactory.php line 49
at ConnectionFactory->make(array('driver' => 'mysql', 'host' => 'localhost', 'port' => '3306', 'database' => 'forge', 'username' => 'forge', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'timezone' => '+00:00', 'strict' => false, 'name' => 'mysql'), 'mysql') in DatabaseManager.php line 175
at DatabaseManager->makeConnection('mysql') in DatabaseManager.php line 67
at DatabaseManager->connection('mysql') in Model.php line 3224
at Model::resolveConnection(null) in Model.php line 3190
at Model->getConnection() in Model.php line 1870
at Model->newBaseQueryBuilder() in Model.php line 1813
at Model->newQueryWithoutScopes() in Model.php line 1432
at Model->save() in ActivityController.php line 19
at ActivityController::logUserActivity(object(Request), 'visited', array('url' => 'http://localhost/busnet/Source/Main/Services/public/index.php/post', 'method' => 'POST', 'requested_on' => '1508130477.865', 'responded_on' => '1508130477.8878', 'ip_address' => '127.0.0.1', 'status' => '200')) in ActivityMiddleware.php line 52
at ActivityMiddleware->addToActivityLog(object(Request), object(JsonResponse)) in ActivityMiddleware.php line 34
at ActivityMiddleware->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ActivityMiddleware), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AuthMiddleware.php line 74
at AuthMiddleware->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AuthMiddleware), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CorsMiddleware.php line 26
at CorsMiddleware->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CorsMiddleware), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Application.php line 1451
at Application->sendThroughPipeline(array('App\Http\Middleware\CorsMiddleware', 'App\Http\Middleware\AuthMiddleware', 'App\Http\Middleware\ActivityMiddleware'), object(Closure)) in Application.php line 1221
at Application->dispatch(object(Request)) in Application.php line 1161
at Application->run(object(Request)) in index.php line 30

这是我在记事本中的.csv

test1@gmail.com,test@123,DATE,DESC,null,1,2,test1@gmail.com
test2@gmail.com,test@124,DATE,DESC,null,3,3,test2@gmail.com
test3@gmail.com,test@125,DATE,DESC,null,4,4,test3@gmail.com
test4@gmail.com,test@126,DATE,DESC,null,5,5,test4@gmail.com
test5@gmail.com,test@127,DATE,DESC,null,6,6,test5@gmail.com

和CSV数据集配置如下
https://i.imgur.com/zZaIP9M.png

每次运行的不同请求都会出现错误,即有时5个用户通过中有4个发送相同的请求,但有一个请求失败。

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

只是一个猜测,但这可能是由于mysql没有配置为接受并发登录?您可以通过将Jmeter线程组中的所有内容放在Critical Section控制器下来测试:

https://jmeter.apache.org/api/org/apache/jmeter/control/CriticalSectionController.html