Jenkins setup and CI siesta tutorial

Get help with testing, discuss unit testing strategies etc.
User avatar
Erik2012
Posts: 12
Joined: Sun Dec 16, 2012 9:55 am

Jenkins setup and CI siesta tutorial

Post by Erik2012 » Tue Feb 05, 2013 10:44 am

Hi all together,

I would like to share my first steps with jenkins continous integration using siesta. In our project we have the goal to set up a well tested automated suite for our building process. Here siesta offers a good mechanism to do that, PhantomJS. We are using ExtJS for our GUI. There we have to write logic in JavaScript e.g. getting components when we need them, overriding existing features and so on. For all these stuff we use our jetty server to test this behaviour emulating database requests with ajax stores and json-files. This server is placed in our subversion system so every developer is able to access it. When jetty is placed in subversion it is really simple to execute our tests in jetty on jenkins For this testing process we need to batch some processes.

First we need a directory in the webapps folder of jetty where the tests are placed. In this folder the following directories are placed in. The test directory, the siesta sources, the test-harness.js and the test-harness.html. This has to commit to subversion to give jenkins the chance of knowing the sources. A setup from test-harness.js and the test-harness.html you can find here: http://www.bryntum.com/docs/siesta/#!/g ... ng_started

After your environment is setted up we have to batch the process for jenkins. The jenkins workflow looks like the following:

- Set up the project by copying the source files of the application under tests in your test folder of the webapps directory from the jetty server

- Run the jetty servers start.jar on jenkins with setting up a stop port and a stop key

- call phantomjs on localhost in jenkins with a JUnit report format

- after phantomjs passes all test with success or fail call the start.jar of jetty with the stop command using the stop key and stop port

- remove the project sources which were copied to the jettys webapps directory in jenkins for cleaning up the project again on jenkins and because of you do not want to have this in your subversion when you run this batch file on your local machine

My batch file Run_Siesta_Tests.bat looks like this:

Code: Select all

set pathToCopyTo=jetty\webapps\myproject_test

xcopy /S /E /H /Y /Q ExtJsmyproject\resources %pathToCopyTo%\resources\
xcopy /S /E /H /Y /Q ExtJsmyproject\app %pathToCopyTo%\app\
xcopy /H /Y /Q ExtJsmyproject\app.js %pathToCopyTo%

xcopy /S /E /H /Y /Q jetty\webapps\myproject\data %pathToCopyTo%\data\
xcopy /S /E /H /Y /Q jetty\webapps\myproject\ext %pathToCopyTo%\ext\
xcopy /S /E /H /Y /Q jetty\webapps\myproject\language_theme_data %pathToCopyTo%\language_theme_data\
xcopy /H /Y /Q jetty\webapps\myproject\index.html %pathToCopyTo%
xcopy /H /Y /Q jetty\webapps\myproject\log4javascript.js %pathToCopyTo%
 
cd jetty
 
CALL start /B java -DSTOP.PORT=8079 -DSTOP.KEY=mysecret -jar start.jar
CALL webapps\myproject_test\siesta-1.1.7-trial\bin\phantomjs http://localhost:8090/myproject_test/test-harness.html --report-format JUnit --report-file ..\ui_unit_test.xml
CALL java -DSTOP.PORT=8079 -DSTOP.KEY=mysecret -jar start.jar --stop

rmdir /S /Q webapps\myproject_test\resources
rmdir /S /Q webapps\myproject_test\app
rmdir /S /Q webapps\myproject_test\data
rmdir /S /Q webapps\myproject_test\ext
rmdir /S /Q webapps\myproject_test\language_theme_data
del /Q webapps\myproject_test\app.js
del /Q webapps\myproject_test\index.html
del /Q webapps\myproject_test\log4javascript.js

@if errorlevel 1 pause
Now lets take a look on Jenkins itself. After you have created a new project on jenkins you have to configure your buildsteps. When the batch process from Run_Siesta_Tests.bat runs on your local machine it should run on jenkins too. The buildstep which has to be set you can see in the image below.The post-build-action has to set up to publish JUnit-Testresults which reference to the xml file which is produced by the phantomJS report.

I hope this post is helpful for all siesta developers.
Thank you for all the help I got in this forum.

Best regards
Erik
Attachments
Jenkins tutorial 2.png
Jenkins tutorial 2.png (13.62 KiB) Viewed 20140 times
Jenkins tutorial.png
Jenkins tutorial.png (65.81 KiB) Viewed 20140 times

User avatar
nickolay
Core Developer
Core Developer
Posts: 3357
Joined: Mon May 16, 2011 10:48 am

Re: Jenkins setup and CI siesta tutorial

Post by nickolay » Tue Feb 05, 2013 11:31 am

Thanks Erik! Stickying this post and we'll try to convert to a new guide in Siesta.
We offer training in both Ext JS and our products, read more here.
Read the API documentation

User avatar
cwtuan
Posts: 24
Joined: Tue Mar 11, 2014 3:19 am

Re: Jenkins setup and CI siesta tutorial

Post by cwtuan » Wed Apr 23, 2014 3:16 pm

Which tool do you use to convert report from junit xml to html?

User avatar
nickolay
Core Developer
Core Developer
Posts: 3357
Joined: Mon May 16, 2011 10:48 am

Re: Jenkins setup and CI siesta tutorial

Post by nickolay » Wed Apr 23, 2014 3:32 pm

You can open this report in some continuous integration tool, like TeamCity or Jenkins.
We offer training in both Ext JS and our products, read more here.
Read the API documentation

User avatar
nickolay
Core Developer
Core Developer
Posts: 3357
Joined: Mon May 16, 2011 10:48 am

Re: Jenkins setup and CI siesta tutorial

Post by nickolay » Tue May 06, 2014 4:45 pm

Testing notifications.
We offer training in both Ext JS and our products, read more here.
Read the API documentation

User avatar
mats
Core Developer
Core Developer
Posts: 14658
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: Jenkins setup and CI siesta tutorial

Post by mats » Tue May 06, 2014 4:46 pm

Works?
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
cwtuan
Posts: 24
Joined: Tue Mar 11, 2014 3:19 am

Re: Jenkins setup and CI siesta tutorial

Post by cwtuan » Wed May 07, 2014 7:54 am

I got the notification.

User avatar
Kurt
Posts: 8
Joined: Sat Apr 07, 2012 8:15 pm

Here is our setup

Post by Kurt » Thu Jul 31, 2014 6:16 pm

Because the setup in this tutorial did not work right away for us and we spent tons of time to get this working with Jenkins, I would like to share our setup.

We were confronted with two problems in our task:
1. We had to use a shell script
2. In our case the PhantomJS command had some issues when we tried to use it on Jenkins. Using it locally works


Before be begin with the project, we installed phantomjs on our linux server to use it with Jenkins and put the jetty server in the project.

So we go:
We copy the content in the same way as in the tutorial:

Code: Select all

#    Some definitions to get it shorter ################################################
JETTY="src/test/Jetty"
JETTYWEB="$JETTY/webapps"
DIR="$WORKSPACE/$JETTYWEB/myProject/Siesta_Framework/bin"

#    You need to install a version of phantomJS on jenkins itself, NOT the one in the Framework!
PHANTOM="$HOME/bin/phantomjs-1.9.7-linux-x86_64/bin"

#    Clean the test report ##########################################################
rm -r "$JETTYWEB/ myProject /"
rm -r "$JETTYWEB/main/"

#    Create a testfolder in the localhost and copy all relevant data ########################
mkdir "$JETTYWEB/ myProject /"

cp -pr "src/test/Siesta_Framework" "$JETTYWEB/ myProject /"
cp -pr "src/test/browse-automation.html" "$JETTYWEB/ myProject /"
cp -pr "src/test/index.js" "$JETTYWEB/ myProject /"
cp -pr "src/test/index.html" "$JETTYWEB/ myProject /"
cp -pr "src/test/myApp-Tests" "$JETTYWEB/ myProject /"
cp -pr "src/main" "$JETTYWEB/"
Then add executable rigths

Code: Select all

#    Give them the rights to get executed ##############################################
chmod u+x -R $JETTYWEB/
Change in the jetty directory and start the server

Code: Select all

cd $WORKSPACE/$JETTY

# Start the servers ################################################################
java -DSTOP.PORT=11183 -jar start.jar -DSTOP.KEY=tadam & 
sleep 5
Here the magic happens because of the issues with the phantomjs:
We change directory into the phantomjs of our machine, NOT to phantomjs of the framework and call the phantomjs inclusive the path of the project as the parameters

Code: Select all

cd $PHANTOM

#     use the phantomjs on the localhost with following options: ########################
#     --jenkins -> give the framework the information you use a jenkins-server, otherwise the build will be always false.
#     --report-format JUnit -> you want the report in JUnit format
#     --report-file -> the path you want to store the test.xml , relevant if you want to publish the results
#     ./phantomjs --help
#     --web-security=false 
#     --local-to-remote-url-access=true
#     --ignore-ssl-errors=true --> this three are needed to avoid a Access-Control-Allow-Origin.

./phantomjs --web-security=false --local-to-remote-url-access=true --ignore-ssl-errors=true "$DIR/phantomjs-launcher.js" $DIR http://127.0.0.1:11182/ myProject /browse-automation.html \
    --jenkins \
    --report-format=JUnit \
    --report-file=$WORKSPACE/src/test/ui_unit_test.xml \
    --web-security=false \
    --local-to-remote-url-access=true \
    --ignore-ssl-errors=true \
At least stop the server

Code: Select all

# Stop the server - ################################################################
cd $WORKSPACE/$JETTY
java -DSTOP.PORT=11183 -DSTOP.KEY=tadam -jar start.jar --stop ]
I hope it will help you and save you some research time

User avatar
cwtuan
Posts: 24
Joined: Tue Mar 11, 2014 3:19 am

Re: Jenkins setup and CI siesta tutorial

Post by cwtuan » Fri Aug 01, 2014 6:41 am

thanks a lot!

User avatar
akansha85
Posts: 127
Joined: Thu Sep 18, 2014 7:30 pm

Re: Jenkins setup and CI siesta tutorial

Post by akansha85 » Thu Sep 18, 2014 7:37 pm

I have recently started building test suites for my extjs application, was curious to know if these test suites can also be triggered through maven/jenkins build?

Can you please suggest the best way to trigger the test suite from Jenkins?

Post Reply