librelist archives

« back to archive

Running a web application for acceptance tests in CI environment

Running a web application for acceptance tests in CI environment

From:
Rikesh Dhokia
Date:
2013-01-25 @ 03:45
Im trying to figure out a way to run my web application in a CI environment
so that I can run a suite of acceptance tests.

My application is using ring and am using a jetty web server

I want to be able to run a leiningen task as follows: lein
run-acceptance-test.  This task would ideally start jetty with my
application deployed; run my suite of midje tests; and finally tear down
jetty

I currently have a task that starts my app in jetty.

Now when I am putting this all together I would like jetty to start in a
forked process so that the initial run-acceptance-test task can continue
with the next task.

Any new ideas or suggestions would be very welcome

thanks
rikesh

Re: [leiningen] Running a web application for acceptance tests in CI environment

From:
Phil Hagelberg
Date:
2013-01-27 @ 00:26
There is a lein-pdo plugin for running multiple tasks in parallel, that
might get you what you need.

-Phil

Re: [leiningen] Running a web application for acceptance tests in CI environment

From:
Korny Sietsma
Date:
2013-01-29 @ 10:30
Hi - I've been playing with this a bit more.  (I share a team with Rikesh)

As far as I can tell, the problem seems to be that Leiningen always runs
tasks in a subprocess - and a subprocess that runs jetty (directly or via
ring.server) doesn't return to the caller until the jetty server is stopped
somehow.

I tried using a custom task with (roughly):
  (eval-in-project start-server)
  (apply-task "midje")
  (eval-in-project stop-server)
but still the first eval-in-project spawns a subprocess which never
returns, as the jetty thread is still running.

I tried using pdo, but found that (a) it's a little flakey as far as I can
tell, and (b) even then we'd have to do a lot of coordinating between the
tasks to make sure the jetty server was completely started before the tests
ran, and somehow schedule a way to stop the server once all tests were
finished.

Am I missing something?  Is there a way to get Leiningen to do the
equivalent of eval-in-project, but without using a subprocess?  Or is there
a way to get it to fork a background process?

Otherwise our options seem to be to use shell scripts to run a background
task - or to set up our midje tests to start and stop jetty themselves.

- Korny


On 27 January 2013 11:26, Phil Hagelberg <phil@hagelb.org> wrote:

> There is a lein-pdo plugin for running multiple tasks in parallel, that
> might get you what you need.
>
> -Phil
>



-- 
Kornelis Sietsma  korny at my surname dot com http://korny.info
"We do not quit playing because we grow old, we grow old because we quit
playing" - O.W. Holmes

Re: [leiningen] Running a web application for acceptance tests in CI environment

From:
Sean Corfield
Date:
2013-01-29 @ 17:46
Isn't there an option to start the Ring server as another process and
have the mainline code just continue? I seem to recall a thread where
starting a Ring server in the REPL was discussed but can't find it
right now...

On Tue, Jan 29, 2013 at 2:30 AM, Korny Sietsma <korny@sietsma.com> wrote:
> Hi - I've been playing with this a bit more.  (I share a team with Rikesh)
>
> As far as I can tell, the problem seems to be that Leiningen always runs
> tasks in a subprocess - and a subprocess that runs jetty (directly or via
> ring.server) doesn't return to the caller until the jetty server is stopped
> somehow.
>
> I tried using a custom task with (roughly):
>   (eval-in-project start-server)
>   (apply-task "midje")
>   (eval-in-project stop-server)
> but still the first eval-in-project spawns a subprocess which never returns,
> as the jetty thread is still running.
>
> I tried using pdo, but found that (a) it's a little flakey as far as I can
> tell, and (b) even then we'd have to do a lot of coordinating between the
> tasks to make sure the jetty server was completely started before the tests
> ran, and somehow schedule a way to stop the server once all tests were
> finished.
>
> Am I missing something?  Is there a way to get Leiningen to do the
> equivalent of eval-in-project, but without using a subprocess?  Or is there
> a way to get it to fork a background process?
>
> Otherwise our options seem to be to use shell scripts to run a background
> task - or to set up our midje tests to start and stop jetty themselves.
>
> - Korny
>
>
> On 27 January 2013 11:26, Phil Hagelberg <phil@hagelb.org> wrote:
>>
>> There is a lein-pdo plugin for running multiple tasks in parallel, that
>> might get you what you need.
>>
>> -Phil
>
>
>
>
> --
> Kornelis Sietsma  korny at my surname dot com http://korny.info
> "We do not quit playing because we grow old, we grow old because we quit
> playing" - O.W. Holmes



-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Re: [leiningen] Running a web application for acceptance tests in CI environment

From:
Jeremy Heiler
Date:
2013-01-29 @ 17:54
You can pass in {:join? false} to the run-jetty function[0]. Then, with the
server instance returned to you, you will have to call (.stop server) when
you're done. I'm not sure how this can be done with lein-ring, though.

[0]

https://github.com/ring-clojure/ring/blob/master/ring-jetty-adapter/src/ring/adapter/jetty.clj#L68


On Tue, Jan 29, 2013 at 12:46 PM, Sean Corfield <seancorfield@gmail.com>wrote:

> Isn't there an option to start the Ring server as another process and
> have the mainline code just continue? I seem to recall a thread where
> starting a Ring server in the REPL was discussed but can't find it
> right now...
>
> On Tue, Jan 29, 2013 at 2:30 AM, Korny Sietsma <korny@sietsma.com> wrote:
> > Hi - I've been playing with this a bit more.  (I share a team with
> Rikesh)
> >
> > As far as I can tell, the problem seems to be that Leiningen always runs
> > tasks in a subprocess - and a subprocess that runs jetty (directly or via
> > ring.server) doesn't return to the caller until the jetty server is
> stopped
> > somehow.
> >
> > I tried using a custom task with (roughly):
> >   (eval-in-project start-server)
> >   (apply-task "midje")
> >   (eval-in-project stop-server)
> > but still the first eval-in-project spawns a subprocess which never
> returns,
> > as the jetty thread is still running.
> >
> > I tried using pdo, but found that (a) it's a little flakey as far as I
> can
> > tell, and (b) even then we'd have to do a lot of coordinating between the
> > tasks to make sure the jetty server was completely started before the
> tests
> > ran, and somehow schedule a way to stop the server once all tests were
> > finished.
> >
> > Am I missing something?  Is there a way to get Leiningen to do the
> > equivalent of eval-in-project, but without using a subprocess?  Or is
> there
> > a way to get it to fork a background process?
> >
> > Otherwise our options seem to be to use shell scripts to run a background
> > task - or to set up our midje tests to start and stop jetty themselves.
> >
> > - Korny
> >
> >
> > On 27 January 2013 11:26, Phil Hagelberg <phil@hagelb.org> wrote:
> >>
> >> There is a lein-pdo plugin for running multiple tasks in parallel, that
> >> might get you what you need.
> >>
> >> -Phil
> >
> >
> >
> >
> > --
> > Kornelis Sietsma  korny at my surname dot com http://korny.info
> > "We do not quit playing because we grow old, we grow old because we quit
> > playing" - O.W. Holmes
>
>
>
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>