Practical issues and solutions for working with JMeter – Part2 – User friendly Tech help
n
n
Scenario:-
nHow to display results from Beanshell sampler to response?
n
nSolution :-
n
nSimple code example:-
n
nString display=”HelloWorld”;
n//Taking results and displaying in response
nSampleResult.setResponseData( display);
n
nSampleResult.setDataType( org.apache.jmeter.samplers.SampleResult.TEXT );
n
n
nScenario:- Not able to understand the error message thrown by jmeter in beanshell sampler or beanshell assertions?
n
Solution :-
n
nUse try-catch
n
try{
int expectedMsgs = ${noOfMessages} * ${messageThreads};
int actualCount =Integer.parseInt(SampleResult.getResponseDataAsString());
//System.out.print(actualCount);
if (expectedMsgs!=actualCount) {
Failure = true;
FailureMessage ="Expected Messages Sent"+expectedMsgs+"!="+actualCount+"ActualMessages in cassandra";
print("Expected Messages Sent"+expectedMsgs+"!="+actualCount+"ActualMessages in cassandra");
}
}
catch(Exception e){
log.error("Failed check the erro"+e);
}
n
n
nScenario:-
nConnect to remote mySql instance (say ubuntu box) using JMeter?
n
nSolution :-
nBefore doing this we need to provide privileges to the remote user to access the database using
n1.SSH into remote machine
nssh username@ip address > enter password
n
n2.Login to mysql using root user
nmysql -u root -pPassword
3.Grant permission as below
nGRANT ALL PRIVILEGES ON *.* TO remote@’10.0.110.***’ IDENTIFIED BY ‘pwd’ WITH GRANT OPTION;
n
n4.Make sure to comment the following line in Mysql configuration file,
n/etc/mysql/mysql.conf.d/mysqld.cnf
n
ncomment bind-address = 127.0.0.1 using the # symbol
n
n5.Now we can replace the localhost, username and password in our connection settings for mysql.
n
Note:-Incase you are getting the below error
n
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
n
nSolution is run the command uninstall plugin validate_password;
n
Practical Examples
n