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
Related
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.
I have JMeter 5.2.1 installed in my system.
When I try to execute below code i am getting this error.
Response message:javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during class generation: java.lang.NoClassDefFoundError: Unable to load class com.azure.messaging.eventhubs.EventDataBatch due to missing dependency org/apache/qpid/proton/amqp/messaging/Section
Code:
import com.azure.messaging.eventhubs.*
final String connectionString = 'EVENT HUBS NAMESPACE CONNECTION STRING'
final String eventHubName = 'EVENT HUB NAME'
// create a producer using the namespace connection string and event hub name
EventHubProducerClient producer = new EventHubClientBuilder()
.connectionString(connectionString, eventHubName)
.buildProducerClient()
// prepare a batch of events to send to the event hub
EventDataBatch batch = producer.createBatch()
batch.tryAdd(new EventData('Fifth event'))
// send the batch of events to the event hub
producer.send(batch)
// close the producer
producer.close()
Below are dependent libraries that i have it in LIB folder. Can you please let me know if i am missing any dependency or using wrong version
dependency.
amqp-client-5.7.1.jar
azure-core-1.13.0.jar
azure-core-amqp-2.0.2.jar
azure-core-test-1.5.3.jar
azure-eventhubs-3.2.2.jar
azure-identity-1.2.3.jar
azure-messaging-eventhubs-5.5.0.jar
jackson-annotations-2.9.0.jar
jackson-core-2.9.9.jar
jackson-databind-2.9.9.jar
jackson-dataformat-xml-2.9.9.jar
jackson-datatype-jsr310-2.9.9.jar
jackson-module-jaxb-annotations-2.9.9.jar
junit-jupiter-api-5.6.3.jar
junit-jupiter-engine-5.6.3.jar
junit-jupiter-params-5.6.3.jar
mockito-core-3.3.3.jar
proton-j-0.31.0.jar
qpid-proton-j-extensions-1.2.1.jar
reactive-streams-1.0.3.jar
reactor-core-3.3.12.RELEASE
reactor-test-3.3.12.RELEASE
slf4j-api-1.7.28
stax2-api-3.1.4
woodstox-core-5.1.0
The org/apache/qpid/proton/amqp/messaging/Section lives in proton-j-0.33.4.jar
I don't know where did you get your proton-j-0.31.0.jar from, my expectation is that you should stick to Microsoft Azure Client Library For Event Hubs ยป 5.5.0 and use dependency management system like Maven or Ivy in order to obtain the library with all its dependencies including the transitive ones.
Once you obtain them - copy all the .jar files to "lib" folder of your JMeter installation (or other location on JMeter Classpath) and restart JMeter to pick up the changes
Just in case here is how the list should look like:
azure-core-1.13.0.jar
azure-core-amqp-2.0.2.jar
azure-messaging-eventhubs-5.5.0.jar
jackson-annotations-2.11.3.jar
jackson-core-2.11.3.jar
jackson-databind-2.11.3.jar
jackson-dataformat-xml-2.11.3.jar
jackson-datatype-jsr310-2.11.3.jar
jackson-module-jaxb-annotations-2.11.3.jar
jakarta.activation-api-1.2.1.jar
jakarta.xml.bind-api-2.3.2.jar
netty-tcnative-boringssl-static-2.0.35.Final.jar
proton-j-0.33.4.jar
qpid-proton-j-extensions-1.2.3.jar
reactive-streams-1.0.3.jar
reactor-core-3.3.12.RELEASE.jar
slf4j-api-1.7.30.jar
stax2-api-4.2.1.jar
woodstox-core-6.2.1.jar
Also be aware that according to JMeter Best Practices you should always be using the latest version of JMeter so consider upgrading to JMeter 5.4 (or whatever is the latest version available at JMeter Downloads page) as soon as possible.
I'm testing out deploying my own parse server following the steps in the Parse Server Guide. I've got the server up and running and have been able to create and fetch objects via curl. I built a simple iOS app using the Parse SDK (1.14.2). I've initialized the SDK with the app id and server url as described in the Parse Server Guide. When I try to make requests, I get back unauthorized from the server. Digging further, I noticed that the SDK is not sending the application id header to the server. I modified the SDK to send the application id header and everything works. Am I missing a configuration step somewhere?
This is because you are not passing the ClientKey. In swift 3 you would pass it like this in the didFinishLaunchingWithOptions.
// Init Parse
let configuration = ParseClientConfiguration {
$0.applicationId = PARSE_APP_KEY
$0.clientKey = PARSE_CLIENT_KEY
$0.server = PARSE_SERVER_URL
$0.isLocalDatastoreEnabled = true
}
Parse.initialize(with: configuration)
If you are falling when trying to test CloudCode, then its because your parse-server is not passing the Javascript key. So just make sure you initialize the server to do so if this issue is related to Parse.Cloud function.
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.
I try to use Tuleap REST API with SpagoBI and it can't find any information.
So, is it possible to get data from REST APIs in SpagoBI?
Thanks for your answer,
Sandra
Yes, it is possible. I've spent a while trying to get this working.
Below is a link with the technique that worked for me.
In short:
I'm using a Script Data-Set, the Groovy language, and the Groovy WSLite web service library. This required updating the version of Groovy shipped with SpagoBI and dropping in the Groovy WSLite library.
The Groovy script retrieves any parameters passed
Makes the web service calls with the parameters
Parses the results
Creates the output in SpagoBI's DataSet XML format
SpagoBI DataSet REST Webservice via Groovy
//Sample code: Using Groovy and Groovy WSLite to call a RESTful web service
//Then, the response is parsed and returned in SpagoBI DataSet's XML format
import wslite.rest.*
def param_ip = parameters['param_ip'] ?: ''
def client = new RESTClient("http://ip-api.com/json/${param_ip.toString()}")
def response = client.get()
assert response.statusCode == 200
def str = response.json
"""
<ROWS>
<ROW
params="${parameters['param_ip'].toString()}"
status="${str.status.toString()}"
country="${str.country.toString()}"
countryCode="${str.countryCode.toString()}"
region="${str.region.toString()}"
regionName="${str.regionName.toString()}"
city="${str.city.toString()}"
zip="${str.zip.toString()}"
lat="${str.lat.toString()}"
lon="${str.lon.toString()}"
timezone="${str.timezone.toString()}"
isp="${str.isp.toString()}"
org="${str.org.toString()}"
as="${str.as.toString()}"
/>
</ROWS>
""".toString()
It is possible to use REST 2.0 API, but you have to have FIWARE version of SpagoBI.
Versions are the same, excpet that FIWARE have REST API services.
Check this links:
http://catalogue.fiware.org/enablers/data-visualization-spagobi/documentation
and Apiary:
http://docs.spagobi.apiary.io/#reference/0/the-content-subresource/return-the-document-content