akhikhl / gretty

Advanced gradle plugin for running web-apps on jetty and tomcat.
MIT License
654 stars 174 forks source link

farmIntegrationTest does not stop container when integrationTest or container deployment fails #214

Open egaga opened 9 years ago

egaga commented 9 years ago

Running gradlew farmIntegrationTest works perfectly unless some exception occurs.

When integrationTest gradle-task fails, then the container (e.g. jetty) stop command is not run. So after next gradlew farmIntegrationTest the webserver is running, and the gretty prematurely has to end its process.

The gretty workflow for integration test does not specify how errors are handled.

See the gradle log with a protractor nodejs task.

[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
:e2e-test:integrationTest FAILED
:e2e-test:appAfterIntegrationTest SKIPPED

The configuration file:

plugins {
    id "war"
    id "java"
}

apply plugin: 'org.akhikhl.gretty'

gretty {
    httpPort = 8080
    servicePort = 9090
    statusPort = 9091

    jvmArgs = ['-Dspring.profiles.active=development']
}

task killJetty {
    mustRunAfter('integrationTest')

    doLast {
        println("Kill jetty") // this is not called
    }
}

farm {
    webapp '../web-api/build/libs/my-bundle.war'
    webapp project
}

task integrationTest {
    doFirst {
        project(':frontend').tasks['runProtractor'].execute() // execute for demonstration purposes
    }
}
mkobit commented 9 years ago

I see the same behavior with appRun when there is an error on startup - ERROR Error starting server. My expectation would be that the container would be stopped:

gradle -version

------------------------------------------------------------
Gradle 2.8
------------------------------------------------------------

Build time:   2015-10-20 03:46:36 UTC
Build number: none
Revision:     b463d7980c40d44c4657dc80025275b84a29e31f

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_60 (Oracle Corporation 25.60-b23)
OS:           Mac OS X 10.10.5 x86_64
plugins {
    id "war"

    id "org.akhikhl.gretty" version "1.2.4"
}

gretty {
    httpPort = 5656
    scanInterval = 2
    reloadOnClassChange = true
    reloadOnConfigChange = true
    servletContainer = "jetty9"
}