Quantcast

Error: cannot open display: :0.0

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Error: cannot open display: :0.0

Michael Cole
Hello, I'm using Selenium with Hudson to test a PHP project on Ubuntu Linux.

As my regular user, I can run my ant script and selenium-rc opens firefox, runs some tests, and everything works.
     [exec] PHPUnit 3.4.14 by Sebastian Bergmann.
     [exec]
     [exec] .
     [exec]
     [exec] Time: 5 seconds, Memory: 5.75Mb
     [exec]
     [exec] OK (1 test, 0 assertions)

When I run the script in Hudson, I get this error:

     [exec] PHPUnit 3.4.14 by Sebastian Bergmann.
     [exec]
     [exec] E
     [exec]
     [exec] Time: 21 seconds, Memory: 5.75Mb
     [exec]
     [exec] There was 1 error:
     [exec]
     [exec] 1) Example::testMyTestCase
     [exec] PHPUnit_Framework_Exception: Response from Selenium RC server for getNewBrowserSession(*firefox, http://dsat.test).
     [exec] Failed to start new browser session: Error while launching browser.
     [exec]
     [exec]
     [exec]
     [exec] FAILURES!
     [exec] Tests: 1, Assertions: 0, Errors: 1.

If I sudo su hudson and try to run the ant script, I get the same errors.  If I try to start firefox as the hudson user, I get this:
     $ firefox
     No protocol specified
     No protocol specified
     Error: cannot open display: :0.0
Any ideas on why this is happening?  What about the hudson user is preventing it from using display?

I installed Hudson with these steps this morning (which apparently created the hudson user):
      wget -q -O - http://hudson-labs.org/debian/hudson-labs.org.key | sudo apt-key add -
      echo "deb http://hudson-labs.org/debian binary/" | sudo tee -a /etc/apt/sources.list
      sudo apt-get update
      sudo apt-get install hudson

Thanks for your help,

Mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: cannot open display: :0.0

Sami Tikka
For obvious security reasons, access to the X server is restricted to
only the user who has logged in on the console.

Your options:

a) Relax the access restrictions. See man Xsecurity and its linked man
pages for details. This is complicated and not recommended.

b) Start another X server for the tests running in Hudson, such as
Xvfb or Xvnc. There is even a Hudson plugin to make it easy for you:
http://wiki.hudson-ci.org/display/HUDSON/Xvnc+Plugin

-- Sami

2010/7/14 Michael Cole <[hidden email]>:

>
> Hello, I'm using Selenium with Hudson to test a PHP project on Ubuntu Linux.
>
> As my regular user, I can run my ant script and selenium-rc opens firefox,
> runs some tests, and everything works.
>     [exec] PHPUnit 3.4.14 by Sebastian Bergmann.
>     [exec]
>     [exec] .
>     [exec]
>     [exec] Time: 5 seconds, Memory: 5.75Mb
>     [exec]
>     [exec] OK (1 test, 0 assertions)
>
> When I run the script in Hudson, I get this error:
>
>     [exec] PHPUnit 3.4.14 by Sebastian Bergmann.
>     [exec]
>     [exec] E
>     [exec]
>     [exec] Time: 21 seconds, Memory: 5.75Mb
>     [exec]
>     [exec] There was 1 error:
>     [exec]
>     [exec] 1) Example::testMyTestCase
>     [exec] PHPUnit_Framework_Exception: Response from Selenium RC server
> for getNewBrowserSession(*firefox, http://dsat.test).
>     [exec] Failed to start new browser session: Error while launching
> browser.
>     [exec]
>     [exec]
>     [exec]
>     [exec] FAILURES!
>     [exec] Tests: 1, Assertions: 0, Errors: 1.
>
> If I sudo su hudson and try to run the ant script, I get the same errors.
> If I try to start firefox as the hudson user, I get this:
>     $ firefox
>     No protocol specified
>     No protocol specified
>     Error: cannot open display: :0.0
> Any ideas on why this is happening?  What about the hudson user is
> preventing it from using display?
>
> I installed Hudson with these steps this morning (which apparently created
> the hudson user):
>      wget -q -O - http://hudson-labs.org/debian/hudson-labs.org.key | sudo
> apt-key add -
>      echo "deb http://hudson-labs.org/debian binary/" | sudo tee -a
> /etc/apt/sources.list
>      sudo apt-get update
>      sudo apt-get install hudson
>
> Thanks for your help,
>
> Mike
>
>
> --
> View this message in context: http://hudson.361315.n4.nabble.com/Error-cannot-open-display-0-0-tp2288363p2288363.html
> Sent from the Hudson users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: cannot open display: :0.0

Michael Cole
This post was updated on .
Yes!  xvnc fixed it.  On Ubuntu, here's what I did:

       sudo apt-get vnc4server
       vncserver
       (set password to quickstart)

Next, I tried copying the password to hudson home directory:
       sudo cp -a /home/quickstart/.vnc/ /var/lib
       sudo chown -R hudson:www-data /var/lib/.vnc/
       sudo nano /etc/init.d/hudson
       (add this line at top:  export HOME=/var/lib/hudson  )
       (restart Linux)

This didn't work, so I tried:
       sudo su hudson
       vncserver
       (set password to quickstart)

(not sure if all the above steps are needed, but whatever)

I still can't sudo su hudson and start firefox, but Hudson doesn't mind.

Finally, here is my build script for a reference.  Note the sleep 5 seconds.

<project name="xxx" default="build">



  <target name="build" depends="build-unix" />

 

  <target name="build-unix"    depends="test-unit-unix,    test-functional-unix,    wrapup-unix" />

  <target name="build-windows" depends="test-unit-windows, test-functional-windows, wrapup-windows" />



 

  <target name="clean">

   

    <delete dir="${basedir}/build"/>

  </target>



  <target name="prepare" depends="clean">

   

    <mkdir dir="${basedir}/build/logs"/>

    <mkdir dir="${basedir}/build/docs"/>

  </target>



  <target name="selenium-start">

   

    <get taskname="selenium-shutdown" src="http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer"

        dest="${basedir}/build/selenium-shutdown.txt" ignoreerrors="true" />

    <echo taskname="selenium-shutdown" message="Errors during shutdown are expected" />

   

    <java jar="${basedir}/dev/selenium-rc/selenium-server.jar"

          fork="true"

          spawn="true" />

    <sleep seconds='5' />

    <get taskname="selenium-start" src="http://localhost:4444/selenium-server/driver/?cmd=status"

        dest="${basedir}/build/selenium-start.txt" ignoreerrors="true" />

  </target>



  <target name="wrapup">

   

    <get taskname="selenium-shutdown" src="http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer"

        dest="${basedir}/build/selenium-shutdown.txt" ignoreerrors="true" />

  </target>

 

 







  <target name="prepare-unix" depends="prepare">

   

    <copy file="${basedir}/config.php.test-unix" tofile="${basedir}/config.php" />

    <exec executable="/bin/bash" dir="${basedir}">

      <arg value="set-file-permissions.sh"/>

    </exec>

  </target>



  <target name="test-unit-unix" depends="prepare-unix">

    <exec dir="${basedir}"

            executable="phpunit"

            failonerror="true">

      <arg line="--log-junit build/logs/phpunit-unit.xml test/source"/>

    </exec>

  </target>



  <target name="test-functional-unix" depends="prepare-unix, selenium-start">

   

    <exec executable="/bin/bash" dir="${basedir}/install-database">

      <arg value="install_oracle.sh"/>

    </exec>

   

    <exec dir="${basedir}"

            executable="phpunit"

            failonerror="true">

      <arg line="--log-junit build/logs/phpunit-functional.xml test/functional"/>

    </exec>

  </target>

 

  <target name="wrapup-unix" depends="wrapup" />

Now for writing tests!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: cannot open display: :0.0

Sami Tikka
I haven't used this myself and it has been a long time since I used Xvnc myself.

I would start debugging it by making absolutely sure the .vnc
directory is where it is supposed to be. I would create a new
freestyle job (not using Xvnc plugin) with no SCM, only 1 build step
containing one line:

ls -l $HOME/.vnc

Run the job and check the console output.

Do you have slaves? Does the job run on the node you think it runs?

-- Sami

2010/7/16 Michael Cole <[hidden email]>:

>
> Yes, xvnc sounds great.  I'm struggling to get it to work though.
>
> On Ubuntu, here's what I did:
>
>       sudo apt-get vnc4server
>       vncserver
>       (set password to quickstart)
>
> To try and get rid of the error, I tried getting the password file into the
> hudson user's session:
>       sudo cp -a /home/quickstart/.vnc/ /var/lib
>       sudo chown -R hudson:www-data /var/lib/.vnc/
>       sudo nano /etc/init.d/hudson
>       (add this line at top:  export HOME=/var/lib/hudson  )
>       (restart Linux)
>
> But this didn't work, I'm still getting the error below.  Any suggestions?
>
>
> The console output is:
>
> Started by user anonymous
> Reverting https://xxx
> Updating https://xxx
> At revision 1756
> no change for https://xxx since the previous build
> Starting xvnc
> [workspace] $ vncserver :10
>
> You will require a password to access your desktops.
>
> getpassword error: Invalid argument
> Password:Starting xvnc
> [workspace] $ vncserver :11
>
> You will require a password to access your desktops.
>
> getpassword error: Invalid argument
> Password:Starting xvnc
> [workspace] $ vncserver :12
>
> You will require a password to access your desktops.
>
> getpassword error: Invalid argument
> Password:Starting xvnc
> [workspace] $ vncserver :13
>
> You will require a password to access your desktops.
>
> getpassword error: Invalid argument
> Password:FATAL: Failed to run 'vncserver :13' (exit code 1), blacklisting
> display #13; consider adding to your Hudson launch script: killall Xvnc
> Xrealvnc; rm -fv /tmp/.X*-lock /tmp/.X11-unix/X*
> java.io.IOException: Failed to run 'vncserver :13' (exit code 1),
> blacklisting display #13; consider adding to your Hudson launch script:
> killall Xvnc Xrealvnc; rm -fv /tmp/.X*-lock /tmp/.X11-unix/X*
>        at hudson.plugins.xvnc.Xvnc.doSetUp(Xvnc.java:90)
>        at hudson.plugins.xvnc.Xvnc.doSetUp(Xvnc.java:88)
>        at hudson.plugins.xvnc.Xvnc.doSetUp(Xvnc.java:88)
>        at hudson.plugins.xvnc.Xvnc.doSetUp(Xvnc.java:88)
>        at hudson.plugins.xvnc.Xvnc.setUp(Xvnc.java:63)
>        at hudson.model.Build$RunnerImpl.doRun(Build.java:132)
>        at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:416)
>        at hudson.model.Run.run(Run.java:1257)
>        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
>        at hudson.model.ResourceController.execute(ResourceController.java:88)
>        at hudson.model.Executor.run(Executor.java:129)
>
> --
> View this message in context: http://hudson.361315.n4.nabble.com/Error-cannot-open-display-0-0-tp2288363p2290689.html
> Sent from the Hudson users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: cannot open display: :0.0

Michael Cole
Sami, thanks for your help on this.

As a last note, my previous comment worked, but in the end I needed to test https with a self-signed cert.  Selenium couldn't accomplish this so I really needed to get at hudson's firefox to work with it.

This simple command allows the hudson user to use the xserver.

 sudo xhost SI:localuser:hudson

Note that this might be a security risk, but I do all my development in a virtual machine, so it's less risky.

Thanks again Sami, your help was invaluable

Mike

Loading...