How do I run, test, and terminate an HTTP server using Jenkins? -


i'm working on team building restful http service. we're having trouble setting jenkins ci job build service, run in background, execute tests, , terminate servers.

specifics

  • the server built in node.js using hapi framework , has unit tests written in mocha.
  • the tests written in java using maven. (why not node.js-based tests? because our testing dept. has invested time in creating java-based rest-testing framework.)
  • the build should fail if node-based unit tests fail or if java tests fail.
  • our jenkins box run support team elsewhere in company; our builds execute on linux slave.

current attempt

we've got kind-of works right now, it's unreliable. use 3 build steps:

the first build step execute shell step following commands:

npm install npm test node server.js ./test-config.json & 

second invoke maven 3 step points test pom.xml.

and third run invoke standalone sonar analysis static code analysis.

this works, depend on jenkins' processtreekiller stop services once job completes. warnings stating: process leaked file descriptors. see http://wiki.jenkins-ci.org/display/jenkins/spawning+processes+from+buildfor more information

unfortunately, we've had cases service terminated (before tests complete) or service doesn't terminated @ (causing subsequent builds fail because port in use).

so need more reliable.

failed attempt

we tried setting single shell script handled starting service, running maven, killing service, outputting exit code. didn't work out because mvn command wasn't available on command-line. our jenkins has multiple maven versions available (and jdks too) , don't know live on slaves or how @ them without using invoke maven 3 build step.

ideas

we've toyed around ideas solve problem, hoping guidance others may have solved similar problems jenkins.

  1. have service self-terminate after period of time. problem figuring out how long let them run.
  2. add build step kill services after we're done. problem if maven execution fails, subsequent steps won't run. (and if tell maven ignore test failures, build doesn't show broken if fail.)
  3. try killing existing service process first , last steps of build. problem other teams use these jenkins slaves need make sure service terminated when we're done our build.
  4. start , stop node.js services via maven doing this blog suggests. problem don't know if jenkins identify spawned background task "leaked file descriptor" , kill before we're done testing.

it nice if jenkins had "post-build action" let run clean-up script. or if had "execute background process" build step kill background items @ end of build. can't find that.

has managed jenkins remotely this?

some brainstorming:

  • you can turn off jenkins processtreekiller, either globally or per invocation. not sure why not option you.

  • in response #2, several options:

    1. post-build actions executed regardless if build steps had failed or not. great way trigger "service cleanup" task run regardless of build state.
    2. you can setup build step post-build action, using any build step plugin, or can use post build tasks plugin, latter gives options define triggering criteria.
  • you can change build state, based on regex criteria using text-finder plugin

  • you can setup conditional build steps. "condition" result of script execution


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -