librelist archives

« back to archive

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

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

From:
Phil Hagelberg
Date:
2013-01-29 @ 18:16
Korny Sietsma writes:

> 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?

If you don't use a subprocess then Leiningen's own dependencies will
interfere with your project's, which you really don't want. Forking off
a background process is essentially what pdo is supposed to do. If it's
a bit flaky I'd recommend looking into why and seeing if you can improve
it instead of starting your own implementation.

I would structure your test run like so:

    $ lein pdo run -m myproject.server, wait-for-port 3000 test

where wait-for-port is a new higher-order plugin which simply polls for
the given port as the first argument and runs the second argument as a
task once it's able to establish a connection.

Of course it's much simpler if your tests can launch jetty themselves,
but if you insist on having two isolated processes this would be the way
to do it. The pdo approach will also be slower since it won't even
attempt to launch the test JVM until the server is up even though that's
a bit wasteful; it could launch the test JVM while the Jetty server is
starting.

Hope that makes sense.

-Phil

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

From:
Korny Sietsma
Date:
2013-01-29 @ 23:48
Makes sense - I think for now I'll work something towards getting the tests
to start jetty if it's not already running, start it manually when for some
reason we want a long-running test server, and work on getting pdo to run
jetty as a separate task when time permits.

- Korny


On 30 January 2013 05:16, Phil Hagelberg <phil@hagelb.org> wrote:

>
> Korny Sietsma writes:
>
> > 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?
>
> If you don't use a subprocess then Leiningen's own dependencies will
> interfere with your project's, which you really don't want. Forking off
> a background process is essentially what pdo is supposed to do. If it's
> a bit flaky I'd recommend looking into why and seeing if you can improve
> it instead of starting your own implementation.
>
> I would structure your test run like so:
>
>     $ lein pdo run -m myproject.server, wait-for-port 3000 test
>
> where wait-for-port is a new higher-order plugin which simply polls for
> the given port as the first argument and runs the second argument as a
> task once it's able to establish a connection.
>
> Of course it's much simpler if your tests can launch jetty themselves,
> but if you insist on having two isolated processes this would be the way
> to do it. The pdo approach will also be slower since it won't even
> attempt to launch the test JVM until the server is up even though that's
> a bit wasteful; it could launch the test JVM while the Jetty server is
> starting.
>
> Hope that makes sense.
>
> -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