Jenkins Windows Node(Agent) for GUI testing

Hi All,

I have a Jenkins V2.323 controller running on Windows Server 2012 and a Node (agent) running Windows 10. Both computer are running Java 8 build 311 (build 1.8.0_311-b11).

To start my Node from my Windows 10 machine I do from command prompt:

java -jar agent.jar -jnlpUrl http://myDomain:8080/... -secret 154jnjn4jn33... -workDir "C:/Jenkins"

That way, I’m able to start my pipeline using my Node. Also this Windows 10 node have a physical monitor and I’m login in the session (no remote desktop)

After that, in my pipeline (JenkinsFile) I start a Python script. This script is using pyautogui to automatize GUI testing. When performing the GUI test, it fail because the Node is start from the command line java -jar agent.jar and no GUI is found.

Running same Python script locally on the Windows 10 node works fine

Other solution found on the internet are using the Launch agent from browser.

Dec 15, 2021 3:47:19 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
Dec 15, 2021 3:47:19 PM org.jenkinsci.remoting.protocol.impl.BIONetworkLayer$Reader run
INFO: Waiting for ProtocolStack to start.
Dec 15, 2021 3:47:20 PM hudson.remoting.UserRequest perform
WARNING: LinkageError while performing UserRequest:hudson.slaves.SlaveComputer$SlaveInitializer@1f8358
java.lang.ExceptionInInitializerError
	at hudson.slaves.SlaveComputer$SlaveInitializer.call(SlaveComputer.java:1050)
	at hudson.slaves.SlaveComputer$SlaveInitializer.call(SlaveComputer.java:1041)
	at hudson.remoting.UserRequest.perform(UserRequest.java:211)
	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
	at hudson.remoting.Request$2.run(Request.java:376)
	at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:122)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "hudson.util.RingBufferLogHandler.defaultSize" "read")
	at java.security.AccessControlContext.checkPermission(Unknown Source)
	at java.security.AccessController.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkPermission(Unknown Source)
	at com.sun.javaws.security.JavaWebStartSecurity.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
	at java.lang.System.getProperty(Unknown Source)
	at java.lang.Integer.getInteger(Unknown Source)
	at java.lang.Integer.getInteger(Unknown Source)
	at hudson.util.RingBufferLogHandler.<clinit>(RingBufferLogHandler.java:39)
	... 11 more

This issue was also posted where:

Also Jenkins is moving from Java 8 to 11, and Java Web Start is remove in Java 11

Java Web Start has been removed in Java 11. When a Jenkins controller runs on Java 11, the Java Web Start button will no longer appear in the Web UI. You can’t launch agents for a Java 11 Jenkins server from a *.jnlp file downloaded to a web browser. There are no plans to replace this functionality. Connect agents to Jenkins on Java 11 with plugins like SSH Build Agents Plugin, with operating system command line calls to java -jar agent.jar , or using containers.

Finally, I try to run the Node as a Windows Service.
https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+as+a+Windows+service
But the option seem to have been remove since the File is no more available:
image

Regarding all this information, what is the best way to do GUI testing on a Windows Node?

Thanks in advance for your help,

Missing post:

Just update to Jenkins 2.325 and encountering the same problems with javaws / gui tests.

We’re using the agent to run GUI tests. All worked nicely with javaws / jnlp agents prioir to the update.

I can get the agent to launch and connect with :
java -jar agent.jar -jnlpUrl ...

But the GUI tests now fail.

I’ve tryied launch using open webstart and the Open JDK javaws from redhat. Both connect, then immediately terminate. Looks like the same exception:
Caused by: java.security.AccessControlException: access denied (“java.util.PropertyPermission” “hudson.util.RingBufferLogHandler.defaultSize” “read”)

Coming from this code:
private static final int DEFAULT_RING_BUFFER_SIZE = Integer.getInteger(RingBufferLogHandler.class.getName() + “.defaultSize”, 256)

None of this makes any sense. The Java process itself isn’t running Java Gui stuff, it would be telling the os to run a sub process.

According to What is the difference between 'java', 'javaw', and 'javaws'? - Stack Overflow the only real difference is javaw does not open a console window.

I don’t know enough about windows, but usually it’s a problem with the service account running the agent not having enough permissions to launch (Gui) applications.

If it’s not that, maybe your somehow running a different version of Java then you think you are. Or maybe you don’t have the matching agent.jar to go with your controller. It shouldn’t matter as long as remoting matches up, so I’d recommend downloading agent.jar directly from you controller again

Those have been the two conditions that I’ve seen as well. GUI testing on Windows without running the process on the Desktop is not as close to the way users do things as the person running the tests might hope. Run the agent process from within the Windows desktop.

Because the inbound agent relies on a copy of agent.jar on the agent file system, the Jenkins administrator needs to take extra steps to assure that the agent.jar version is current.

I prefer to install the Microsoft OpenSSH server on Windows computers and launch the agent using ssh. Jenkins manages the agent.jar version in that case. However, that doesn’t allow access to the Windows Desktop. When I must have Windows desktop access, I run agent.jar from a batch file on the agent.

Dug into this a bit more, unfortunately my java knowledge is very limited.

Anyhow, the gui tests where failing when running from the agent launched by:
java -jar agent.jar -jnlpUrl ...
due to windows not being “active” immediately after the test app was launched. Windows seems to behave differently from the console window on what windows it activates from our test script.
Adding some code to the test, to activate the window first, solves that problem and things work, so the account launching the agent has all the necessary permissions to run gui apps.

Digging into the javaws problem and it seems to be javaws imposes some kind of security layer on the agent. And this causes the getInteger call to fail. Seems to be similar problems reported with jnlp security but not simple fix that I can see.

Possibly it’s some checkbox I now need to enable on the agent machine to let it run with the correct permission, but I’ve got no idea what.

We’re using java-1.8.0-openjdk-1.8.0.312-2 on the agents.

Hi All,

After restarting all the service and rebooting all computer it start working! Not sure what was the issue. I use the same agent.jar.

In conclusion, you can use java -jar agent.jar for GUI testing.

Thanks for your help,