How to create a plugin in JMeter - plugins

i would like to create a JMeter plugin. I would like to understand how to write and pack my code to extend JMeter with my Sample. More in detail i'm looking for an "adhoc" TCPSampler that implement my protocol.
I tried following an old pdf document from JMeter site but it doesn't work. Where is the mistake?
Can you help me with some examples?
Thank you
RM

There are several options to extend JMeter.
Use JSR223 Sampler (groovy language is recommended to use as it can be compiled into Java code, however you'll need to download groovy-all.jar and drop it to /lib folder of your JMeter installation)
Use Beanshell Sampler - basically the same, but it's built-in. Have lower performance than JSR223 + Groovy
Create your own Java Request. 2 Java Request samplers are shipped with JMeter - JavaTest and SleepTest. You can inspect their source to see how they're implemented.
Create your own Sampler. See ExampleSampler source code for details and how to implement it or even use it as a base for your plugin.
All JMeter Extensions should be packaged as .jar and live under /lib/ext folder of your JMeter installation.

Here is book - How to Write a plugin for JMeter http://jmeter.apache.org/extending/jmeter_tutorial.pdf

Related

Jmeter (JMX) running on GIThub) encounters an error

I tried to run my JMX file on Github however I'm encountering an error. can someone help me fix this. Your response is highly appreciated. Thank you.
PerfAction for Jmeter
Screenshot:
YAML File
Your test plan is using Dummy Sampler and your JMeter installation doesn't have this Dummy Sampler plugin installed.
Make sure to add it using JMeter Plugins Manager (it can also be done in command-line mode) and this error will go away.
If your script uses other JMeter Plugins - do the same for all the plugins used.

Jacoco code coverage for remote machine

I tried to find this answer but hardly found it anywhere. I am doing the API testing, In process I need to call the rest API from my local machine. local machine contains the maven project and a framework to call respective rest API.
I need to check the code coverage of remote Rest API and form a report based on the code coverage. please help, how to do that?
Note: I found this link useful but it does not elaborate clearly on what to do?
http://eclemma.org/jacoco/trunk/doc/agent.html
you will probably do a bit of file copying around - depending on the way you run the tests.
JaCoCo runs as a java agent. So you usually add the javaagent parameter as mentioned in the docs you linked to the start script of you application server.
-javaagent:[yourpath/]jacocoagent.jar=[option1]=[value1],[option2]=[value2]
so it would look like:
java -javaagent: -jar myjar.jar
Using tomcat you can add the "-javaagent" part into JAVA_OPTS or CATALINA_OPTS environment variables. Should be similar for other servers.
this will create the jacoco*.exec files. you need to copy those back to your build or CI server to show its results (for ex if you use sonar you need those files before running the sonar reporter). Its important to just include the packages you're interested in.
You can also create one jacoco.exec file per test flavour (jacoco.exec for unit tests, jacoco-it.exec for integration tests, jacoco-at.exec for application tests).
And I would not mix coverage with performance testing - just to mention that too.
There are some examples on stackoverflow for JBoss

Can I use Eclipse XQDT to debug Marklogic modules/xquery?

Hi Markloggers out there,
I am working now a coupe of months with Marklogic, developping xquery, modules, applications on the ML app server etc etc. I use eclipse a lot, I have XQDT up and running for several marklogic servers. We use the console also.
What I miss is a debug functionality... in Eclispe with XQDT I cannot get the debug function working?
What I need is a nice and clean way to quickly test and develop modelules and functions...
This is my basic lib from the ML example documentation:
xquery version "1.0-ml";
module namespace lib = 'http://www.example.com/lib';
declare function lib:user()
{
xdmp:get-current-user()
};
I have this is my XQDT project in eclipse, I have setup a marklogic XDBC server locally and it works ok.
Now I want to use the above module from a file again in the XQDT project in eclipse. But without going to steps of uploading the module to the db etc etc...:
(: XQuery main module :)
import module namespace lib = 'http://www.example.com/lib' at 'lib.xq';
lib:user()
Gives:
XDMP-MODNOTFOUND: (err:XQST0059) Module /lib.xq not found
Question 1: Is there a way to find the module without putting it in a module root? In the docs it says from a XQDT project I could source a module but I cannot get it to work...
Question 2: I can execute arbitrary xquery to the local Marklogic server but if I set a debug flag anywhere in a xgy file in the XQDT project and press the debug button I get a popup saying "The Debug Engine is not properly configured". Can anyone explain to me if it is possible to use the debug option in eclipse XQDT with Marklogic 7 ?
Regards,
hugo
It's best to limit yourself to one question per SO post. After all you can only accept one answer.
Now I want to use the above module from a file again in the XQDT
project in eclipse. But without going to steps of uploading the module
to the db etc
That's a problem. You can evaluate an ad-hoc query directly. But if it references a library module, that library module needs to be available to the server. You're going to have to copy it to the server sooner or later anyhow, so do it sooner. I don't use an IDE myself, but can't you set it up to do that for you?
Question 1: Is there a way to find the module without putting it in a module root?
Not in the broadest sense of "module root", no. The docs at https://docs.marklogic.com/guide/app-dev/import_modules talk about how this works. Somehow or other, you need to make the library module available to MarkLogic.
I can't address your last question. I don't use an IDE, and even if I did I probably wouldn't use a debugger. Instead I xdmp:log messages to ErrorLog.txt, and occasionally I'll plant an breakpoint-like error() call in my code.

scala online code execution

I'd like to develop an web-based application that allows user to submit Scala code from their web browser client and compile / execute their code on the server.
I was trying to use the scala.tools.nsc.IMain / ILoop classes to load the client file and then execute the file on the server. How do I do this?
How does using the IMain / ILoop classes compare to forking off an external process to compile and execute the code?
Zeppelin is another opensource project worth to take a look at.
It's got scala interpreter embedded for Apache Spark.
https://github.com/NFLabs/zeppelin
I guess it's worth to take a look at https://github.com/Bridgewater/scala-notebook http://vimeo.com/user18356272/review/66548724/53e2b222c1

What language does SmartFoxServer 2x use on the server side?

I have downloaded and started the community version of SFSx2. I read everything on their documentation page:
http://docs2x.smartfoxserver.com/DevelopmentBasics/introduction
Which unfortunately only talks about flash client side code. Nothing about the corresponding server side code, nor about html5 client side which I need.
I downloaded the HTML5 examples, which took me a long time to find (they are here: http://www.smartfoxserver.com/download/get/140 )
None of the examples work, as they can't connect to the server. Presumably, this is because the examples only supply client side code. There are no instructions supplied on how to install or run the examples.
I can find no mention on the smartfox documenation on the following:
1) what language is used on the server side. One assumes its java.
2) how does one deploy java code to the smartfox server? I cant find any mention of this in the docs.
3) how does one find and install the server part of the client side examples (which are Tris, GameLobby, BuddyMessenger, AdvancedChat).
I applied to be allowed to post on the smartfoxserver forums, but no reply yet.
I also found it hard so I share what I've found out.
The server extensions are written in Java. I used Eclipse JUNO to write my code.
You can download Eclipse here. http://www.eclipse.org/downloads/
You export the extension in jar format from eclipse into you extension path. The name of your file has to end in 'extension' eg MyFirstExtension.jar otherwise sfs2x wont recognize it. Your extension path will be something like this: C:\Program Files\SmartFoxServer2X\SFS2X\extensions\MyFirstExtension\MyFirstExtension.jar if your working in windows.
You will find docs on JAVA API here. http://docs2x.smartfoxserver.com/api-docs/javadoc/server/
This is a link to the basic example code: http://www.smartfoxserver.com/download/get/120
Unzip the content into the [SFS2X_install_folder]/SFS2X/www/root/examples folder, overwriting the existing file. Run the index.html file, then navigate to another index.html to open the example. Run the sfs2x-standalone.exe first of course(see below). If you followed the 'server configuration tutorial' on smartfox website and changed the server ports, the examples wont work. Leave the ports alone until you start to understand the server.
This is a link to the flash example code: http://www.smartfoxserver.com/download/get/108
You will find the example code for apps mentioned above. They are written in Adobe Flash Builder and Java extensions. I don't know if there is any code for HTML5 but the Java server code and AS3 is there.
I also found that using the standalone server was the way to go rather than using SFS2x as a service. c:\program files\smartfoxserver2x\sfs2x\sfs2x-standalone.exe. Using the exe gives you the command prompt window. You can use the window for debugging and see the state of the server when it starts.
Most of the examples should work without creating extensions but to create an extension out of source examples:
Create and setup a new project in your Java IDE. You will have already set up a workspace.
Copy the content of the /source/server/src folder to your project's source folder.
Add SFS2X Libraries. Go to properties of the project -> Select Java Build Path -> Click Library Tab -> Add external jar. Add 'sfs2x.jar' and 'sfs2x-core.jar' from C:\Program Files\SmartFoxServer2X\SFS2X\lib folder. To create the extension, export jar file to extension path. Restart server.
Another problem I had was the Java Version I was using. I had to use Java1.6 with my version of sfs2x when writing extensions. This was trial and error as there was no documentation. There may be a newer version out now.
I had to copy all the server source into eclipse to try and understand how things were done. It was a way of having all the code in one place. There was a lot of trial and error as getting help is hard. I eventually accomplished what I set out to achieve. Good Luck.
SmartFox Server is easy to use even with extension. documentation Give try to Nuggeta solution for game development too. No extension needed at first. This is optionnal.
We have full HTML5 open source game walkthrough on github