How can I test a WebSocket STOMP using JMeter - websocket

I have followed this question But things did not work properly because when I try to download JMeterWebSocketStompSampler-0.2.jar, It is not Found. But other jar files are found and are in place, here's a sample of my samplers screenshot attached.
Are there any suggestions to be able to test a local STOMP ?? I also tried APIC extension in chrome and it is failing, I am attaching an image.
Any Suggestions?
Thanks

It looks like you can use WebSocket Samplers by Peter Doornbosch (can be installed using JMeter Plugins Manager), some sample code snippets are available in Using Websocket samplers in JMeter with STOMP plugin issue discussion, for instance this one:
String s = "CONNECT\n" +
"login:${wsToken}\n" +
"passcode:\n" +
"accept-version:1.1,1.0\n" +
"heart-beat:20000,0\n" +
"\n" +
'\0' // note: NULL char at end
;
vars.put("wsStompData", s);

Related

Send messages to AWS SQS using JMeter

I want to test the scenarios of sending message to AWS SQS from Jmeter. But i dont find any relevant procedure to do it. I came to know about awsmaster plugin but after installing it, it doesnot get installed(seems like a corrupted version)
I am trying with Custom code but there also, the attribute builder() of "sqs client" shows a warning as "This static method of interface SqsClient can only be accessed as SqsClient.builder"
So, can someone please guide how to send messages to SQS queue using Jmeter and the steps.Thanks
If you're willing to copy and paste the code to initialize the SqsClient you can take a look at AWS Java SDK Examples repository:
SqsClient sqsClient = SqsClient.builder()
.region(Region.US_WEST_2)
.credentialsProvider(ProfileCredentialsProvider.create())
.build();
Then you can send the message like it's described here:
CreateQueueRequest request = CreateQueueRequest.builder()
.queueName(queueName)
.build();
sqsClient.createQueue(request);
GetQueueUrlRequest getQueueRequest = GetQueueUrlRequest.builder()
.queueName(queueName)
.build();
String queueUrl = sqsClient.getQueueUrl(getQueueRequest).queueUrl();
SendMessageRequest sendMsgRequest = SendMessageRequest.builder()
.queueUrl(queueUrl)
.messageBody(message)
.delaySeconds(5)
.build();
sqsClient.sendMessage(sendMsgRequest);
The code can be placed in i.e. JSR223 Sampler, use Groovy as the scripting language.
Make sure to add necessary import statements, copy AWS Java SDK with all its dependencies to JMeter classpath and restart JMeter to pick up the jars.

JMeter: How to access a remote Cloud directory in JMeter?

I need to access a remote cloud directory ( microsoft azure) to list the files in the folder. I also need to move some of the files to another folder in the cloud directory ( cut and paste ).
I found a few answers which spoke about using a Beanshell Sampler and a Foreach controller to get the files in a directory (This was for the folder structure on my local machine). I was able to check the results using a Debug Sampler and a view results tree. However, I am not sure how to use this for a Cloud directory.
I also found answers around using a Directory Listing Config Plugin, this works well with the local directory as well. But I am unable to pass the path to the cloud directory.
Is there a way to access the cloud directory? I am fairly new to JMeter.
Please Help. Thank You.
If you're talking about Azure Files - it can be accessed either via NFS protocol or SMB protocol.
None of the protocols is supported by JMeter or any plugins so you will have to use JSR223 Sampler and write some custom Groovy code using the relevant Java library like EMC NFS Java Client or JCIFS. For the latter one example code can be found in How to Load Test SMB/CIFS with JMeter, example adaptation just in case:
import jcifs.smb.NtlmPasswordAuthentication
import jcifs.smb.SmbFile
String url = "smb://path/to/your/cloud/directory";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, "username", "password");
SmbFile smbFile = new SmbFile(url, auth);
SmbFile[] files = smbFile.listFiles("*");
for (int i = 0; i < files.length; i++) {
log.info("File + " + i + ": " + files[i].getName());
}

Try to load CDN and invoke method in CDN js in JMeter

In our App, we are using Video Publishing API (https://static.opentok.com/v2/js/opentok.js).
The problem with my test case is, we are externally invoking a method "Connect(-,-)" in openttok.js.
But how we can achieve through JMeter to Test Video Publishing?
I tried with following way,
Test Plan
Thread Group
Http Request
call cdn: https://static.opentok.com/v2/js/opentok.js
Post Request:
JSR223 PostProcessor: use variable in CDN JS
//OT varible is available in OpenTok JS.
var session = OT.initSession(apiKey, sessionID);
These are the Screens:
Http Request for OpenTok.js
Post Processor:
But it throws an error
Caused by: jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "OT" is not defined
I think, OpenTok not loading or not available to Post Processor Script.
How can I load OpenTok and use a variable within this Js?
You won't be able to do it this way as JMeter is not a browser and cannot execute JavaScript.
I would recommend the following approach
Download Opentok Server jar
Obtain all the dependencies, for OpenTok Server 3.0.0 they would be
async-http-client-1.9.40.jar
commons-beanutils-1.9.2.jar
commons-digester-1.8.1.jar
commons-lang-2.6.jar
commons-logging-1.2.jar
commons-validator-1.6.jar
jackson-annotations-2.9.0.pr4.jar
jackson-core-2.9.0.pr4.jar
jackson-databind-2.9.0.pr4.jar
jose4j-0.5.1.jar
netty-3.10.6.Final.jar
Put all the .jars under JMeter Classpath
Restart JMeter to pick the jars pu
Add JSR223 Sampler to your Test Plan
Use the following code to create a session:
import com.opentok.OpenTok
def apiKey = 123456789
def apiSecret = 'your_api_secret'
OpenTok opentok = new OpenTok(apiKey,apiSecret)
def session = opentok.createSession()
References:
OpenTok Java SDK Usage
OpenTok Documentation
Apache Groovy - Why and How You Should Use It

Headless browser using jmeter

I tried to use (jp#gc - HtmlUnit Driver Config) to create a headless browser test using jmeter, but I get this error
Response message: com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: "getComputedStyle" is not defined.
I read online and it suggest that jp#gc - HtmlUnit Driver Config doesn't support javascript. Is there a way I can fix this via jmeter? or is there any other option to do headless browser testing. I have linux server as load injector
Update:
I have a webdriver sampler to open google page
WDS.sampleResult.sampleStart() WDS.browser.get('http://google.com')
WDS.sampleResult.sampleEnd()
and have downloaded Phanton JS, but when I run it it doesn't show anything on the report. Should I add any other config?
HtmlUnit do not support very well JS.
I done many tests and used each one and i can say that PHANTOMJS is the best one with good support of all JS/CSS... have a beautiful renderer to have nice screenshots.
by code you can use it like this (you can download it from here http://phantomjs.org/download.html (phantomjs-1.9.8 is very stable)):
Capabilities caps = new DesiredCapabilities();
((DesiredCapabilities) caps).setJavascriptEnabled(true);
((DesiredCapabilities) caps).setCapability("takesScreenshot", true);
((DesiredCapabilities) caps).setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
"your custom path\\phantomjs.exe"
);
WebDriver driver = new PhantomJSDriver(caps);
If you want to do that via JMeter GUI, you need to add before your Logic Controller an element JSR223 Sampler JSR223_Sampler
and inside the script panel :
org.openqa.selenium.Capabilities caps = new org.openqa.selenium.remote.DesiredCapabilities();
((org.openqa.selenium.remote.DesiredCapabilities) caps).setJavascriptEnabled(true);
((org.openqa.selenium.remote.DesiredCapabilities) caps).setCapability("takesScreenshot", true);
((org.openqa.selenium.remote.DesiredCapabilities) caps).setCapability(
org.openqa.selenium.phantomjs.PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
"your custom path\\phantomjs.exe");
org.openqa.selenium.WebDriver driver = new org.openqa.selenium.phantomjs.PhantomJSDriver(caps);
org.apache.jmeter.threads.JMeterContextService.getContext().getCurrentSampler().getThreadContext()
.getVariables().putObject(com.googlecode.jmeter.plugins.webdriver.config.WebDriverConfig.BROWSER, driver);
Do not hesitate if you need more informations.

webpage.open() never calls callback

I'm using PhantomJS 1.8.2 to run some Jasmine unit tests using JsTestDriver. The tests run fine using Chrome, but about half the time when using PhantomJS, the test result is that no test cases were found.
I've narrowed the issue down to PhantomJS failing to open the local JsTestDriver page (http://localhost:9876/capture). Here's how to reproduce this, about 50% of the times, the Loaded ... with status ... message is never shown:
Start JsTestDriver server locally
Run phantomjs phantomjs-jstd-bridge.js
The file phantomjs-jstd-bridge.js looks like this:
var page = require('webpage').create();
var url = 'http://localhost:9876/capture';
console.log('Loading ' + url);
page.open(url, function(status) {
console.log('Loaded ' + url + ' with status ' + status);
});
The first log line (Loading ...) is always displayed, but the second line coming from the callback is only printed about half the time.
What could be the cause for this? Opening the URL in question in a web browser works fine every time.
Is there any way to get more info on why PhantomJS does not call the callback?
Check some tips mentioned in the Troubleshooting wiki page. Particularly useful is tracking the network transfer activity as it may indicate whether some resources are not sent properly or other similar problems.

Resources