17

We have a master-slave configuration for Jenkins. Our .NET project is built by a slave Jenkins instance running on Windows.

There are a bunch of GUI tests, however they only seem to run if there's a remote desktop connection (RDC) session open.

When trying to run the tests with no RDC, Jenkins doesn't show any progress in testing. Then, however, I connect to the Slave's desktop and can see the main window of the application launched, however the UI testing framework (White) cannot perform any actions.

The Jenkins slave is launched via Java Web Start.

I read on several websites that unfortunately it is not possible to run GUI tests without RDC session.

I just want to confirm that it is true and wonder if there is any workaround.

Mike Borozdin
  • 1,038
  • 3
  • 12
  • 31

4 Answers4

14

Your slave machines have to be at a desktop before the test can run properly. We had the same problem.

Solution was to have the test machine start up and auto-logon to the desktop. To ensure that the test would ONLY start after the desktop was available, we added a scheduled task, set to run at user login, that would launch the Jenkins slave via Java Web Start. That way, Jenkins would only see the slave once the desktop was running. After that, everything worked fine.

Jason Swager
  • 6,251
  • 6
  • 38
  • 55
  • hi! Thanks for the answer. It looks remarkably similar to what I've been doing, however it didn't bring much of success. I also noticed and read that every time you minimise an RDC window, the tests stop. – Mike Borozdin Apr 17 '12 at 08:23
  • 4
    RDC creates and destroys desktops. This causes the visual tests to go nuts - their desktops are being wiped and recreated. That method of visual testing will not work when RDC is involved. When we ran our tests, we NEVER connected via RDC during the test run. Since our test machines were VMWare VMs, we connected via the VM Console, which shows what the monitor would see, not the remote desktop created when RDC connects. – Jason Swager Apr 17 '12 at 15:45
  • our tests are running on an ec2 instance, we don't normally RDC to them. The only reason we were doing that is to check why Jenkins stalled when running tests. When we have an open RDC session, then we can see that the tests are running in Jenkins, otherwise nothing happens. – Mike Borozdin Apr 17 '12 at 19:12
  • 2
    The solution Jason describes is the only way I've ever gotten this kind of thing to work. I would run "control userpasswords2" in a cmd.exe window on your EC2 machine, and configure it to log in to an account automatically at boot. You can then configure the Jenkins agent to run in that desktop session (as the logged-in Windows user). If connecting to the machine via RDC continues to give you problems I would try switching to VNC to connect to the already-logged-in machine. – Bill Agee Apr 19 '12 at 05:18
  • 1
    This is relevant I think: https://forums.aws.amazon.com/thread.jspa?messageID=248701 – Francis Upton IV Sep 28 '12 at 17:41
8

I have a Jenkins cluster running different kinds of GUI testing, win32, swing, selenium. They are running thousands of tests in unattended manner 24x7. Here is my solution:

  1. How to keep GUI testing alive - RDC doesn't work, the GUI applications will only function well when the RDC session is active. I've tried different ways, so don't bother to try again. Your test would broke after the RDC window is minimized or disconnected. The solution so far is install VNC Server (I am using UltraVNC) as service and make sure it is started during log on. Also make sure you don't connect to your test machine with RDC, as RDC will break VNC session. If possible connect it with VNC client as well. But that is up to you. What I do is when I need to debug something on the machine, I RDC to it and restart it to make sure #2 and #3 are set.

  2. Auto logon - there is a tool autologon.exe in SysInternalsSuite, run it on your slave

  3. Auto register slave - What you need is Swarm Plugin - https://wiki.jenkins-ci.org/display/JENKINS/Swarm+Plugin . Write a simple batch and place a shortcuts in your startup folder. Everytime your machine autologon, it is automatically registered as slave.

I actually combine #2 and #3 as a simple batch file:

autologon.exe <user> <domain> <password>
REM Here to make sure the logonCount is properly generated
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoLogonCount /t REG_DWORD /d 0xFFFF /f

start /min java -jar I:\CDC\jenkins\swarm-client-1.9-jar-with-dependencies.jar -executors 1 -fsroot c:\Jenkins -labels "Prod Win7 %ComputerName%" -master <Jenkins URL> -name farm-%ComputerName% -username <username> -password <password>
Andy Chen
  • 331
  • 2
  • 8
  • In case you preffer the formal autologon registry modification: http://support.microsoft.com/kb/315231, you can use the registry data file I posted here: http://serverfault.com/questions/269832/windows-server-2008-automatic-user-logon-on-power-on/606130#606130 – Noam Manos Jun 18 '14 at 15:13
6

There is another way of do it without windows auto logon (works for me on few machines).

1. Go to Computer Management -> Services and Applications -> Services -> Jenkins Slave -> Properties
2. In Log On tab chose Local System account and check Allow services to interact with desktop
3. Close this windows by clicking OK, and restart the Jenkins slave service
4. Go to directory where is your test app and chose Properties on your app executable
5. On Security tab click Edit...
6. In new window click Add..
7. In new window click Locations... and chose Local computer (top most option on list), click OK
8. Put LOCAL SERVICE to white area of the window and click Check Names, click OK
9. Allow Full control for that user, click OK, close all windows

That should be everything. Let me know if it works for you.

maQ
  • 406
  • 3
  • 7
2

As the other answers already stated, one needs a configuration, where the windows machine auto logons to a real user, see other answers for details. However this was not enough for me, I needed to setup a UltraVNC Server as running as service to solve the problems.

On the site is mentioned, that a login via RDP is a problem for that trick, i.e. connect with VNC or reboot after RDP access.

jan
  • 2,522
  • 1
  • 28
  • 51
  • I know this is an old question but can you help me set this up, please? I installed the UltraVNC and enabled the loopbackonly option. Now it runs as a service but how do I test it? What I'm trying to accomplish here is that I have a software that is scheduled on the server and when it runs, Its takes the screenshot of the server every 5 minutes and stores it but if I'm disconnected from VM, It just stops. I will really appreciate it if you tell me how you solved it. Thanks. – ChiragMS Sep 15 '19 at 06:10
  • @ChiragMS: We don't run this setup anymore. I cannot check what details I might have missed noting. Have you understood the detail, that login via RDP stops the solution from working, i.e. the machine has to reboot after RDP to auto login and only this way it will stay running. You can only test from outside via writing the screenshot to a network share and checking this share from another machine for example. – jan Sep 15 '19 at 14:26
  • Yes I got that part and I configured it. Its working fine now. Thanks. – ChiragMS Sep 19 '19 at 15:56