How to Jprofile on linux system (No GUI) - jprofiler

I have Linux system where jprofiler installed.
I have to profile one running server and one client together which lying on same Linux system. I am sending 100+ different request from client to server.
My query is:
How to Automate whole jprofile process without GUI intervention?
When start the jprofiling, before 100 request submitted to client or after?
I haven't found config.xml (/root/.jprofiler8) after installing jprofiler in Linux system. How to create it?
How to create session without GUI?
To analyse the jprofiler output I will copy on window system and will use GUI jprofiler.
Thanks in advance,
Edit-1
I can automate profiling procedure step 4 and 5 from below. All below steps are correct or not?
Configure session using GUI as you suggested on yours reply (Session->Integration Wizards->New Remote Integration)
export session using GUI as you suggested on yours reply (Session->Export Session Settings).
Copy config.xml from window to Linux where jvm are running.
Run jpenable in linux system like below:
jpenable --pid=8568 --noinput --offline --config=/home/myuser/config.xml --id=106
Run jpcontroller in Linux system like below and Save snapshot:
jpcontroller 8568
Copy snapshot output from Linux system to window and open snapshot(Session-> Open Snapshot) using jprofiler for further analysis.
Edit-2
-agentpath VM parameter added in start script instead of using my step 4. Now, can I start my created session to use JProfiler GUI instead of using my step 5-6? I am receiving connection error when select and start my session.
Session -> Start Center -> Select and Start session (e.g. id="138" name="Remote application on linux1")
Also, I ran "netstat -a | grep 8849" on Linux system but didn't get any result/output.
Replaced and executed step 4 like below:
linux1:/var/opt# su myuser
myuser#linux1:/var/opt> java -Xmx2g -agentpath:/opt/jprofiler8/bin/linux-x64/libjprofilerti.so=offline,id=138,config=/home/myuser/.jprofiler8/config.xml -classpath /opt/jprofiler8/bin/agent.jar -jar /opt/myapp.jar
JProfiler> Offline profiling mode.
JProfiler> Protocol version 41
JProfiler> Using JVMTI
JProfiler> JVMTI version 1.1 detected.
JProfiler> 64-bit library
JProfiler> Using config file /home/myuser/.jprofiler8/config.xml (id: 138)
JProfiler> Listening on port: 8849.
JProfiler> Instrumenting native methods.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
JProfiler> Using dynamic instrumentation
JProfiler> Time measurement: elapsed time
JProfiler> CPU profiling enabled
SLF4J: Class path contains multiple SLF4J bindings.
MyApp started
But, I am able use JProfiler GUI if i followed below steps instead of using my step 1-2-3-4-5-6 and it's not offline:
Step 1:
Go to Linux jprofiler
myuser#linux1:/opt/jprofiler8/bin> ./jpenable
Select a JVM:
myapp.jar [29389] [1]
myapp2.jar [29228] [2]
1
Please select the profiling mode:
GUI mode (attach with JProfiler GUI) [1, Enter]
Offline mode (use config file to set profiling settings) [2]
1
Please enter a profiling port
[31757]
You can now use the JProfiler GUI to connect on port 31757
Step 2:
Go to window jprofiler
Session -> New session -> [Attach (Squire shape Button) -> Attach to profiled JVM (radio button) --> Host: linux1 --> Profilling port: 31757 --> OK]

You cannot create the triggers without a GUI. The idea is to configure the session locally on your desktop machine by invoking
Session->Integration Wizards->New Remote Integration
from the main menu. Select "Profile offline" in the "Startup mode step". The wizard will give you the VM parameter that you have to add on the remote side and create a new session on which you can configure triggers.
After that, export the session by invoking
Session->Export Session Settings
from the main menu and copy that config file to the remote server into the directory that you specified on the "Config synchronization" step of the wizard.

Related

Jmeter remote testing exits too early

I have 3 instances in AWS with Jmeter installed - one master and two slaves.
I want to test 1M requests against my application. I have a script, which runs 100 threads concurrently 10,000 times.
When running the test on localhost or on a single instance only it runs fine.
My issue is that when I run the test using remote servers it exits immediately on both machines. The only logs I get from this are these:
Starting the test on host 10.229.48.10 # Mon Dec 02 15:21:49 UTC 2019 (1575300109383)
Warning: Nashorn engine is planned to be removed from a future JDK release
Finished the test on host 10.229.48.10 # Mon Dec 02 15:22:00 UTC 2019 (1575300120030)
I get nothing else even with verbose logging enabled.
This is the command I use to run the test:
JVM_ARGS="-Xms2048m -Xmx2048m" ./bin/jmeter -n -t test.jmx -R 10.229.48.10,10.
System load: 0.0 Processes: 122 │229.48.23
Both machines are fully open to the master instance.
Why does the script run fine on a single instance but craps out when using remote hosts?
The general checklist for troubleshooting JMeter master-slave configuration is:
Check jmeter.log file on the master and jmeter-server.log on the slaves
Ensure that Java version is the same on master and the slaves, if it is not the same - get the relevant (better latest) version of 64-bit JDK or Server JRE
Ensure that JMeter version is the same on master and the slaves, if it's not the case - get the relevant (better latest) version of JMeter
If your test is using any of JMeter Plugins - ensure that the same set of plugins is installed on all the machines. The plugins can be installed using JMeter Plugins Manager
If you're using any external data files, i.e. CSV files which are consumed by the CSV Data Set Config - the file(s) need to be copied over to all the slaves
If your test relies on some JMeter Properties make sure to supply the properties via -J or -D command-line arguments on all the machines or via -G command-line arugment on the master or put them into user.properties file
Which version of JDK are you using?
Is it JDK 8 or something else?
Make sure the following things,
a. Internal Networking is enabled in all three instances.
b. JDK 8 is installed from official resources.
c. You are able to communicate with the instances individually.
d. Installed JMeter from the official resource instead of "apt install jmeter"

AttachNotSupportedException when trying to start a JFR recording

I'm receiving AttachNotSupportedException when trying to start a JFR recording.
It was working normally, until now.
jcmd 3658 JFR.start maxsize=100M filename=jfr_1.jfr dumponexit=true settings=profile
Output:
3658:
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
What might be happening?
SO: Oracle Linux Server release 6.7
$ java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
One of the probable reasons is that /tmp/.java_pid1234 file has been deleted (where 1234 is PID of a Java process).
Tools that depend on Dynamic Attach Mechanism (jstack, jmap, jcmd, jinfo) communicate to JVM through a UNIX domain socket created at /tmp.
This socket is created by JVM lazily on the first attach attempt or eagerly at JVM initialization if -XX:+StartAttachListener flag is specified.
Once the file corresponding to the socket is deleted, tools cannot connect to the target process, and unfortunately there is no way to re-create communication socket without restarting JVM.
For the description of Dynamic Attach Mechanism see this answer.
With personal experience... This problem also occurs in scenarios where the development environment is divided into partitions, and the partition where the operating system is located is different from the operating system partition. Example, operating system partition is EXT4 and the development environment partition is NTFS (where the JVM is). Problem occurs because you can not create a file "/tmp/.java_pid6024" (where 6024 is the PID of the java process).
To troubleshoot add -XX: + StartAttachListener at the start of the JVM, or application server.
Another possibility: your app is running under systemd with 'PrivateTmp=yes'. This prevents the /tmp/.java_pid1234 file from being found.

Jenkins & TestNG start browsers

Is it possible to make Jenkins use actual browser instead of headless browser? I a running some tests written in TestNG (using Selenium webdriver). When I run the testng.xml file in Eclipse, the browser starts and the tests run. But when I use Jenkins and run the tests with maven, it doesn't start any browsers.
If your jenkins is hosted in a Windows machine, there are some special configurations you should know about services that are allow to use the interface.
By the way, the easiest way to see the browsers running is starting jenkins using the command line:
java -jar jenkins.war
In linux you could use the same command or use xvfb plugin to run browsers in background.
Hope helps
In addition to this, the main reason for not launching the browser is JNLP (java network launch protocol) , when we execute the war we can interact with the desktop applications.
Using Selenium Grid will allow you to execute the test on Jenkins but open the browser on a remote slave.
To achieve this you need to create an instance RemoteWebdriver than ChromeDriver, IEDriver etc I
For linux. If jenkins is running as a daemon, you could specify active display to connect to and run your browser on it. Check what display you could connect to:
ps e | grep -Po " DISPLAY=[\.0-9A-Za-z:]* " | sort -u
My output is:
DISPLAY=:10.0
DISPLAY=:2
DISPLAY=:2.0
Then go to your jenkins project -> Configure -> Build and add the next string above your main build configuration through "Add build step -> Execute shell"
/bin/bash -c "export DISPLAY=:10"
Edited: I've encountered the issue again recently. To resolve it:
I've given for the jenkins' user ability to interact with the desktop of my current user:
xhost +si:localuser:jenkins
so if I connect to my linux system through ssh using jenkins' user credentials, export display of my current user (export DISPLAY=:10) and run, for example google-chrome or firefox inside of putty's terminal, they are launching on my current user's desktop.
After this I've checked If I could start "mvn test" command inside of workspace/MyTests folder from my putty so it will start browser and execute tests.
At the end I've created simple script in the root of my current user:
vi ~/.startup.sh
#!/bin/bash
xhost +si:localuser:jenkins
and added it to my Xfce4 GUI: Application -> Settings -> Session and Startup -> Application Autostart, specifying command field as:
sh -c $HOME/.startup.sh
It's because of this script should work only when desktop is loaded to share my current user's display with jenkins' user. After reboot and connecting to this server through RDC desktop loads with xhost command applied. And after this jenkins could interract with desktop even when I close the RDP connection but leaving current user's session alive.
I've removed Build step in my jenkins' project configuration that was stated "Invoke top-level Maven targets". It could not start my browsers.
I've changed my "Add build step -> Execute shell" to:
export DISPLAY=:10
cd /var/lib/jenkins/workspace/MyTests
mvn test
I've tried grid also, turning selenium-server-standalone -hub and -node into daemons. But it was slower than launching browsers with WebDriver in the such way.

Jenkins stops at Launching Internet Explorer

we are using Jenkins as CI in our project. We were running the CI from the command line using the following command
java -jar C:\\jenkins\\jenkins.war --httpPort=8085 --ajp13Port=8009
As the system needs to restart frequently, we change CI to start as a windows service.
Now we are facing the issues for Selenium test cases. Selenium test cases are not running after we make Jenkins as service. We are getting the following log and no more progress from that point
18:36:30,718 INFO [org.openqa.selenium.server.SeleniumDriverResourceHandler] Command request: getNewBrowserSession[*iexploreproxy, http://192.168.132.105:8080/, ] on session null
18:36:30,718 INFO [org.openqa.selenium.server.BrowserSessionFactory] creating new remote session
18:36:30,796 INFO [org.openqa.selenium.server.BrowserSessionFactory] Allocated session 80b95d0273ac4ea4a82860c79438f071 for http://192.168.132.105:8080/, launching...
18:36:30,796 INFO [org.openqa.selenium.server.browserlaunchers.WindowsProxyManager] Modifying registry settings...
18:36:31,781 INFO [org.openqa.selenium.server.browserlaunchers.InternetExplorerCustomProxyLauncher] Launching Internet Explorer...
Per hudson wiki, you should be running Hudson (or jenkins) as tasks rather than service for GUI testing. Check here. Look at the section GUI Testing in Windows
Following changes will resolve the problem
Update the selenium version.
Use *iexploreproxy or *piiexplore for IE instead of *iehta/*iexplore

Selenium Grid - remote control connections to hub - fail to register, but build successfully

I've successfully run a Selenium Grid on my local machine, and I've moved it to a server (windows Server 2008 R2).
The server instance has run successfully with locally launched agents
The server hosted console is visible over the internet
However, when I create a new remote control on a different machine, they build successfully but they do not register with the hub.
The command line is:
ant -Dport=6601 -Dhost=<ip address of my box> -DhubURL=http://ab.cdefg.ca:4444/wd/hub* -Denvironment"firefox" launch-remote-control
I've also used my hostname as a replacement for my ip name (pc78.subdomain.domain.ca)
If I do not specify the Denvironment, I get the following back:
C:\Sgrid\selenium-grid-1.0.8>ant -Dport=6601 -Dhost=pcname.subdomain.domain.ca -Dhu
bURL=http://ab.cdefg.ca:4444/wd/hub* launch-remote-control
Buildfile: C:\Sgrid\selenium-grid-1.0.8\build.xml
launch-remote-control:
[java] Sep 15, 2011 3:37:11 PM com.thoughtworks.selenium.grid.remotecontrol
.RegistrationRequest execute
[java] INFO: Registering to http://ab.cdefg.ca.ca:4444/wd/hub*/registration
-manager/register
[java] Exception in thread "main" java.lang.IllegalStateException: Could no
t register successfuly to http://ab.cdefg.ca.ca:4444/wd/hub*/registration-manage
r/register with environment '*firefox'. Most likely this environment is not defi
ned on the hub.
[java] at com.thoughtworks.selenium.grid.remotecontrol.RegistrationRequ
est.execute(RegistrationRequest.java:29)
[java] at com.thoughtworks.selenium.grid.remotecontrol.SelfRegisteringR
emoteControl.register(SelfRegisteringRemoteControl.java:29)
[java] at com.thoughtworks.selenium.grid.remotecontrol.SelfRegisteringR
emoteControlLauncher.main(SelfRegisteringRemoteControlLauncher.java:27)
BUILD FAILED
C:\Sgrid\selenium-grid-1.0.8\build.xml:90: Java returned: 1
Total time: 1 second
If do specify the Denvironment, I get the following back:
C:\Sgrid\selenium-grid-1.0.8>ant -Dport=6601 -Dhost=pcname.sub.domain.ca -Dhu
bURL=http://ab.cdefg.ca:4444 -Denvironment"firefox" launch-remote-control
Buildfile: C:\Sgrid\selenium-grid-1.0.8\build.xml
BUILD SUCCESSFUL
Total time: 0 seconds
C:\Sgrid\selenium-grid-1.0.8>
However, the console does not recognize or utilize this agent. Nor is this agent visible on http://localhost:4444/console
So I thought, I'll reverse it and use my local as a server and try and register the server as a remote control, but the same problem repeated itself, command line success, but functionally no activity. Sounds like a network problem, so I booted up a third machine, installed and tested selenium grid (works). Console is visible from my laptop, running on my desktop, via ipaddress:4444/console.
I then launched a remote control, had the same problem. Okay, I then turn off the firewall on my local desktop (treating it as my server) and my laptop (treating it as a remote). Same problem.
Finally, thinking maybe the existence of a local console is messing with the remote launch, I reboot and run only the following:
ant -Dport=6601 -Dhost=<laptop ip> -DhubURL=http://<desktop ip>:4444 -Denvironment"firefox" launch-remote-control
Same problem.
Also I can ping the server from my desktop
Is there a setting I'm missing? It seems like everything in each instance is okay, and all of them have the same versions installed. Clearly something isn't getting from one place to the other, but I have no idea how to work around it when everything else seems okay. Many thanks.
You need an "=" after the environment. I.e., -Denvironment="firefox".
ant -Dport=6666 -Dhost=pc78.subdomain.domain.ca -DhubURL=http://ab.cdef.ca:4444 launch-remote-control
Thanks for the kick start - dropping the "/wd/hub*" from the DhubURL and dropping the Denvironment all together actually got me working - thanks for the response. I