PMC:QA:Sahi with Hudson
Contents
Hudson with Sahi
please review document PMC:QA:Sahi integrate with Ant brfore browse this document
Integrate Hudson with Sahi
job Sahi
open Hudson and create a new job(eg.Sahi)
Configuration
Sahi -> Configure -> Build -> Add build step -> Invoke Ant
configure it as follow:
save your configuration,then you can build it.
view result by Build History -> Console Output
result:
logs
Sahi test has log,the default directory is sahi_HOME/userdata/logs/playback
In order to view the log by hudson,we need to make the log directory point to the job's workspace
goto Sahi's workspace,in linux the directory is /root/.hudson/jobs/Sahi/workspace
create a new directory logs
workbox workspace # mkdir logs
and add script as follow to zkdemo.xml after script "threads="3" >"
<report type="html" logdir="/root/.hudson/jobs/Sahi/workspace/logs"/>
Built it again.
after build,you can view logs by Workspace -> logs
Problem
you can find the name of log file include chinese(i haven't research that),so maybe cause problem can't open log page:
Solution:
modify server.xml(tomcat_Home/conf),
addURIEncoding="UTF-8"
like this:
<Connector debug="0" maxProcessors="100" minProcessors="5" port="8080" URIEncoding="UTF-8" />
restart tomcat,then you can access log page.
Playing Back Headless with Sahi
the above test,we must install Firefox.
In order to run your Sahi tests in headless mode you must do two things:
* Provide a virtual graphical environment in which to run the browser. To do this we'll use Xvfb, the X-Windows virtual frame buffer.
* Instruct the browser to use the virtual graphical environment. To accomplish this, we'll modify the <sahi> ANT task.
install Xvfb
In the X Window System, Xvfb or X virtual framebuffer is an X11 server that performs all graphical operations in memory, not showing any screen output. From the point of view of the client, it acts exactly like any other server, serving requests and sending events and errors as appropriate. However, no output is shown. This virtual server does not require the computer it is running on to even have a screen or any input device. Only a network layer is necessary.
Actually you don't need install it if you have installed xorg-server,you can just type Xvfb to test whether it works.
Assuming you've installed Xvfb successfully, you can launch it into a background process with the following command:
$ Xvfb :99 -ac &
Here we have instructed Xvfb to use the DISPLAY number :99 and to allow all connections (-ac).
or we can create a new file in /etc/init.d named xvfb
the content is:
XVFB=/usr/bin/Xvfb XVFBARGS=":99 -screen 0 800x600x8 -fbdir home" PIDFILE=/var/run/xvfb.pid case "$1" in start) echo -n "Starting virtual X frame buffer: Xvfb" start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS echo "." ;; stop) echo -n "Stopping virtual X frame buffer: Xvfb" start-stop-daemon --stop --quiet --pidfile $PIDFILE echo "." ;; restart) $0 stop $0 start ;; *) echo "Usage: /etc/init.d/xvfb {start|stop|restart}" exit 1 esac exit 0
Then We can use /etc/init.d/xvfb start to run it. More Info about Xvfb:http://en.wikipedia.org/wiki/Xvfb
update Ant task
Now, the only modification we must make to our previous ANT script is to instruct Firefox to use this DISPLAY that is being provided by Xvfb. To accomplish this, we only need to modify the browseroption line within the sahi ANT task by adding the argument "--display=:99". The updated sahi ANT task is now:
<sahi suite="${user.data}/scripts/zkdemo/zkdemo.suite" browser="/usr/lib/firefox-3.0.16/firefox" baseurl="${urlbase}" sahihost="localhost" sahiport="9999" failureproperty="sahi.failed" haltonfailure="false" browseroption="--display=:99 -profile ${user.data}/browser/ff/profiles/sahi1 -no-remote" browserProcessName="firefox" threads="1"> <report type="html"/> <report type="junit" logdir="${user.data}/temp/junit"/> </sahi>
Now that you have Xvfb running in the background, and the updated ANT script, you won't see the browser launch during the tests; it's all happening in memory. This is exactly what we need for our continuous integration system.
built the job.
Result:
you can see **the test is failed**
may be because Xvfb.in console i get info
AUDIT: Tue Mar 16 17:37:29 2010: 26941 Xvfb: client 1 rejected from local host (uid 0)
my test about Xvfb
workbox bin # Xvfb :99 -screen 0 1024x768x24 & [5] 27261
but test follow is failed
bin # DISPLAY=:99 firefox & [6] 27266 AUDIT: Tue Mar 16 17:59:11 2010: 27261 Xvfb: client 1 rejected from local host (uid 0) Xlib: connection to ":99.0" refused by server Xlib: No protocol specified Error: cannot open display: :99
solution:
made a file
/etc/X99.hosts
containing the single line:
localhost
and call Xvfb thus:
</pre>Xvfb :99 -auth /etc/X99.hosts -screen 0 800x600x24 &</pre>
modify /etc/init.d/xvfb
# nano /etc/init.d/xvfb
XVFBARGS=":99 -auth /etc/X99.hosts -screen 0 800x600x24"
then start Xvfb
/etc/init.d/xvfb start
can see we have started xvfb:
# ps aux|grep Xvfb root 15643 0.3 0.6 11280 6532 ? Ss 13:36 0:00 /usr/bin/Xvfb :99 -auth /etc/X99.hosts -screen 0 800x600x24
you can run follow command to test xvfb.
DISPLAY=:99 firefox & [3] 11821
also have error info:
workbox bin # sh: kde-config: command not found sh: kde-config: command not found Xlib: extension "XInputExtension" missing on display ":99.0". Failed to get list of devices
test again
the result:
you can find the last step testing is failed,i don't konw why?
if delete the last step and test again,it is successful!
Reference
Links
- Go back to PMC:QA