Testing a Pyramid app with Jenkins

97 views
Skip to first unread message

alain.d...@nrc-cnrc.gc.ca

unread,
Sep 23, 2015, 2:18:43 PM9/23/15
to pylons-devel
I have a Pyramid app called tdddemoPyramidApp.py, for which I wrote a bunch of integration tests using PhantomJS.
 
I want those tests to be run by the Jenkins Continuous Integration server whenever there is a new commit.
 
I have managed to get this mostly working, except for one thing.
 
Before I run the the unit tests, I need restart the tdddemoPyramidApp.py script so that it runs the most recent version of the app. When I run the tests outside of Jenkins, I just Ctrl-C the script and re-issue the command python tdddemoPyramidApp.
 
Not sure how to get Jenkins to do this. I guess I could write a script that looks for a process that is running tdddemoPyramidApp.py and kills it before restarting it, but I was wondering if there is an easier way.
 
Thx.

Tom Lazar

unread,
Sep 23, 2015, 2:34:57 PM9/23/15
to pylons...@googlegroups.com
I recommend running your app via supervisord. 

It's a common option to run pyramid anyway so you should find lots of examples (even in the handbook).

Also, both were written by the same author, so that helps a bit, too, I guess :-)

Sent from a phone, please excuse the brevity.
--
You received this message because you are subscribed to the Google Groups "pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-devel...@googlegroups.com.
To post to this group, send email to pylons...@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.

Jonathan Vanasco

unread,
Sep 23, 2015, 2:53:55 PM9/23/15
to pylons-devel
I wouldn't run this via supervisord, because supervisord is really aimed at managing services that are supposed to be "on" (ie, production or staging environments).  You'll encounter a lot of issues when you need to persist an off-state across reboots or need to tweak certain settings (which will force all supervisord managed services to shut-down then start up again).

It also sounds like you're trying to just keep a version of the app running online somewhere, then update that and run tests against it. 

Personally, I think it would make better sense to just spin up your demo app as a process that belongs to Jenkins, run the tests against that, and then shut it down -- all within your testrun.  This way your  tests are all isolated and ensured against that exact build.  If you want to keep a a staging or other live version, manage it separate depending on the outcome of tests -- If your tests pass, upgrade that app to the new version; if they fail, leave that last functional app as-is.


Gael Pasgrimaud

unread,
Sep 23, 2015, 3:20:07 PM9/23/15
to pylons-devel
Hi


On Wednesday, September 23, 2015 at 8:18:43 PM UTC+2, alain.d...@nrc-cnrc.gc.ca wrote:
I have a Pyramid app called tdddemoPyramidApp.py, for which I wrote a bunch of integration tests using PhantomJS.
 
I want those tests to be run by the Jenkins Continuous Integration server whenever there is a new commit.
 
I have managed to get this mostly working, except for one thing.
 
Before I run the the unit tests, I need restart the tdddemoPyramidApp.py script so that it runs the most recent version of the app. When I run the tests outside of Jenkins, I just Ctrl-C the script and re-issue the command python tdddemoPyramidApp.
 

I'm using a real wsgi server in a specific thread so you can use setUp/tearDown or pytest.fixtures to start/stop it. Then you can use subprocess to launch phantomjs tests

There is one in webtest (search for StopableWSGIServer in the docs) but now I'm using this https://github.com/gawel/aiowsgi/blob/master/aiowsgi/thread.py which I found more robust. It works with py27 even if it use asyncio. Unfortunatly this one is not documented.

Hope this can help.

 

Laurence Rowe

unread,
Sep 25, 2015, 9:48:54 PM9/25/15
to pylons-devel
On Wednesday, 23 September 2015 11:18:43 UTC-7, alain.d...@nrc-cnrc.gc.ca wrote:
Before I run the the unit tests, I need restart the tdddemoPyramidApp.py script so that it runs the most recent version of the app. When I run the tests outside of Jenkins, I just Ctrl-C the script and re-issue the command python tdddemoPyramidApp.
 
Not sure how to get Jenkins to do this. I guess I could write a script that looks for a process that is running tdddemoPyramidApp.py and kills it before restarting it, but I was wondering if there is an easier way.

Assuming your tests are written in Python, then I'd recommend starting a webtest.http.StopableWSGIServer [1] as part of your test setup.


Laurence

Alain Désilets

unread,
Oct 1, 2015, 2:26:03 PM10/1/15
to pylons-devel


On Friday, 25 September 2015 21:48:54 UTC-4, Laurence Rowe wrote:
Assuming your tests are written in Python, then I'd recommend starting a webtest.http.StopableWSGIServer [1] as part of your test setup.

Thx. I have started looking into StopableWSGIServer. 

Alain
Reply all
Reply to author
Forward
0 new messages