Tested UAT with deploydb running in an environemnt
- Added update of deployment state and promotion result testing for a deployment - Fixes #163
This commit is contained in:
parent
c75b53510b
commit
927312b5cd
|
@ -31,8 +31,8 @@ class IntegrationModelHelper {
|
|||
return response.status == 200
|
||||
}
|
||||
|
||||
boolean sendDeploymentStartedTrigger() {
|
||||
String path = "/api/deployments/1"
|
||||
boolean sendDeploymentStartedTrigger(long deploymentId) {
|
||||
String path = "/api/deployments/" + String.valueOf(deploymentId)
|
||||
String messageBody = """
|
||||
{
|
||||
"status" : "STARTED"
|
||||
|
@ -43,8 +43,8 @@ class IntegrationModelHelper {
|
|||
return response.status == 200
|
||||
}
|
||||
|
||||
boolean sendDeploymentCompletedTrigger() {
|
||||
String path = "/api/deployments/1"
|
||||
boolean sendDeploymentCompletedTrigger(long deploymentId) {
|
||||
String path = "/api/deployments/" + String.valueOf(deploymentId)
|
||||
String messageBody = """
|
||||
{
|
||||
"status" : "COMPLETED"
|
||||
|
@ -55,8 +55,8 @@ class IntegrationModelHelper {
|
|||
return response.status == 200
|
||||
}
|
||||
|
||||
boolean sendPromotionCompletedTrigger() {
|
||||
String path = "/api/deployments/1/promotions"
|
||||
boolean sendPromotionCompletedTrigger(long deploymentId) {
|
||||
String path = "/api/deployments/" + String.valueOf(deploymentId) + "/promotions"
|
||||
String messageBody = """
|
||||
{
|
||||
"name" : "basicPromo",
|
||||
|
|
|
@ -3,8 +3,6 @@ Feature: DeployDB cleanup APIs
|
|||
As a DeployDB administrator
|
||||
I should be able to cleanup the artifact, deployment promotion results models
|
||||
|
||||
|
||||
@dbd
|
||||
Scenario: The model cleanup shall be successful
|
||||
Given there is a deployment
|
||||
When I POST to "/tasks/modelCleanup?group=com.example.cucumber&name=cucumber-artifact&version=1.0.1" from the admin app
|
||||
|
|
|
@ -10,6 +10,7 @@ Given(~/^there is an artifact$/) { ->
|
|||
dao.persist(a)
|
||||
}
|
||||
}
|
||||
|
||||
Given(~/^there are artifacts$/) { ->
|
||||
withSession {
|
||||
ArtifactDAO dao = new ArtifactDAO(sessionFactory)
|
||||
|
@ -41,3 +42,14 @@ And(~/^the (.*?) is over ([1-9][0-9]*) characters$/) { String var, int varSize -
|
|||
}
|
||||
"""
|
||||
}
|
||||
|
||||
And(~/^the artifact doesn't exist$/) { ->
|
||||
boolean artifactFound = true
|
||||
withSession {
|
||||
ArtifactDAO dao = new ArtifactDAO(sessionFactory)
|
||||
artifactFound = dao.artifactExists("com.example.cucumber",
|
||||
"cucumber-artifact",
|
||||
"1.0.1")
|
||||
}
|
||||
artifactFound == false
|
||||
}
|
|
@ -163,6 +163,9 @@ class DeployDBApp extends Application<DeployDBConfiguration> {
|
|||
/** Add admin task for config reload */
|
||||
environment.admin().addTask(new ConfigReloadTask(workFlow))
|
||||
|
||||
/** Add admin task for model cleanup */
|
||||
environment.admin().addTask(new ModelCleanupTask(workFlow))
|
||||
|
||||
/** Register Ldap Authentication */
|
||||
CachingAuthenticator<BasicCredentials, auth.User> authenticator = new CachingAuthenticator<>(
|
||||
environment.metrics(),
|
||||
|
|
|
@ -23,6 +23,9 @@ class FlowDAO extends AbstractDAO<Flow> {
|
|||
ArtifactDAO artifactDAO = new ArtifactDAO(currentSession().getSessionFactory())
|
||||
Artifact artifact = artifactDAO.criteria().add(Restrictions.eq('group', group))
|
||||
.add(Restrictions.eq('name', name)).add(Restrictions.eq('version', version)).uniqueResult()
|
||||
if(artifact == null) {
|
||||
return
|
||||
}
|
||||
Flow flow = criteria().add(Restrictions.eq('artifact.id', artifact.id)).uniqueResult()
|
||||
|
||||
// now delete the found flow
|
||||
|
|
|
@ -40,7 +40,7 @@ class DeploymentCompletedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -68,7 +68,7 @@ class DeploymentCompletedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -95,7 +95,7 @@ class DeploymentCompletedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -123,7 +123,7 @@ class DeploymentCompletedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -151,7 +151,7 @@ class DeploymentCompletedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -178,7 +178,7 @@ class DeploymentCompletedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -207,7 +207,7 @@ class DeploymentCompletedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
|
|
@ -38,7 +38,7 @@ class DeploymentStartedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -66,7 +66,7 @@ class DeploymentStartedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -93,7 +93,7 @@ class DeploymentStartedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -121,7 +121,7 @@ class DeploymentStartedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -148,7 +148,7 @@ class DeploymentStartedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -176,7 +176,7 @@ class DeploymentStartedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -205,7 +205,7 @@ class DeploymentStartedNotificationsSpec extends Specification {
|
|||
integModelHelper.sendCreateArtifact()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger()
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
|
|
@ -65,7 +65,7 @@ class MultipleEnvironmentsNotificationsSpec extends Specification {
|
|||
integAppHelper.webhookRunner.requestWebhookObject.configuredUriPaths =
|
||||
["/job/basicEnv-deploy-created/build", "/job/basicEnv-deploy-completed/build"]
|
||||
|
||||
success = integModelHelper.sendDeploymentCompletedTrigger()
|
||||
success = integModelHelper.sendDeploymentCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -80,7 +80,7 @@ class MultipleEnvironmentsNotificationsSpec extends Specification {
|
|||
["/job/basicEnv-deploy-created/build", "/job/basicEnv-deploy-completed/build",
|
||||
"/job/prodEnv-deploy-created/build"]
|
||||
|
||||
success = integModelHelper.sendPromotionCompletedTrigger()
|
||||
success = integModelHelper.sendPromotionCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
|
|
@ -34,8 +34,8 @@ class PromotionCompletedNotificationsSpec extends Specification {
|
|||
|
||||
|
||||
integModelHelper.sendCreateArtifact()
|
||||
integModelHelper.sendDeploymentStartedTrigger()
|
||||
integModelHelper.sendDeploymentCompletedTrigger()
|
||||
integModelHelper.sendDeploymentStartedTrigger(1L)
|
||||
integModelHelper.sendDeploymentCompletedTrigger(1L)
|
||||
}
|
||||
|
||||
def "no webhook should be called when you receive promotion completed trigger if there is no webhook config" () {
|
||||
|
@ -51,7 +51,7 @@ class PromotionCompletedNotificationsSpec extends Specification {
|
|||
setupDeploymentForPromotionTrigger()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger()
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -78,7 +78,7 @@ class PromotionCompletedNotificationsSpec extends Specification {
|
|||
setupDeploymentForPromotionTrigger()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger()
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -104,7 +104,7 @@ class PromotionCompletedNotificationsSpec extends Specification {
|
|||
setupDeploymentForPromotionTrigger()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger()
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -131,7 +131,7 @@ class PromotionCompletedNotificationsSpec extends Specification {
|
|||
setupDeploymentForPromotionTrigger()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger()
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -158,7 +158,7 @@ class PromotionCompletedNotificationsSpec extends Specification {
|
|||
setupDeploymentForPromotionTrigger()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger()
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -184,7 +184,7 @@ class PromotionCompletedNotificationsSpec extends Specification {
|
|||
setupDeploymentForPromotionTrigger()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger()
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -212,7 +212,7 @@ class PromotionCompletedNotificationsSpec extends Specification {
|
|||
setupDeploymentForPromotionTrigger()
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger()
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger(1L)
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
|
|
@ -3,12 +3,13 @@ apply plugin: 'eclipse'
|
|||
apply plugin: 'groovy'
|
||||
apply plugin: 'application'
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
apply plugin: 'com.jfrog.bintray'
|
||||
|
||||
version = '0.1'
|
||||
group = 'com.github.lookout.deploydb.uat'
|
||||
description = 'User Acceptance Testing artifact for deploydb'
|
||||
|
||||
mainClassName = 'uat.UatMainApp'
|
||||
mainClassName = 'deploydb.UatMainApp'
|
||||
|
||||
project.targetCompatibility = 1.7
|
||||
|
||||
|
@ -51,4 +52,43 @@ shadowJar {
|
|||
manifest {
|
||||
attributes 'Main-Class' : mainClassName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assemble.dependsOn shadowJar
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLISHING TASKS
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
artifacts {
|
||||
archives distShadowTar, distShadowZip, shadowJar
|
||||
}
|
||||
/* Disabling the addition of a jar to the archives which gets in the way of our
|
||||
* means to publish artifacts. It appears that the java plugin doesn't give you
|
||||
* the means to remove the 'default jar' from the artifacts list by any other
|
||||
* means
|
||||
*/
|
||||
jar.enabled = false
|
||||
configurations.archives.artifacts.removeAll { it.archiveTask.is jar }
|
||||
|
||||
bintray {
|
||||
user = project.bintrayUser
|
||||
key = project.bintrayKey
|
||||
publish = true
|
||||
dryRun = false
|
||||
configurations = ['archives']
|
||||
|
||||
pkg {
|
||||
userOrg = 'lookout'
|
||||
repo = 'systems'
|
||||
name = 'DeployDB'
|
||||
labels = []
|
||||
|
||||
version {
|
||||
name = project.version
|
||||
vcsTag = "v${project.version}"
|
||||
desc = project.description
|
||||
}
|
||||
}
|
||||
}
|
||||
bintrayUpload.dependsOn assemble
|
|
@ -1,23 +1,44 @@
|
|||
package uat
|
||||
package deploydb
|
||||
|
||||
import spock.lang.*
|
||||
import dropwizardintegtest.IntegrationModelHelper
|
||||
import dropwizardintegtest.IntegrationRestApiClient
|
||||
|
||||
import javax.ws.rs.core.Response
|
||||
|
||||
class ArtifactTriggerSpec extends Specification {
|
||||
|
||||
IntegrationRestApiClient integrationRestApiClient = new IntegrationRestApiClient()
|
||||
IntegrationModelHelper integModelHelper = new IntegrationModelHelper(integrationRestApiClient)
|
||||
|
||||
def setup() {
|
||||
//integrationRestApiClient.host = "http://10.32.10.63"
|
||||
integrationRestApiClient.host = "http://localhost"
|
||||
integrationRestApiClient.host = "http://" + System.getProperty("DeploydbHost")
|
||||
integrationRestApiClient.port = Integer.valueOf(System.getProperty("DeploydbPort"))
|
||||
}
|
||||
|
||||
boolean sendCreateArtifact() {
|
||||
String path = "/api/artifacts"
|
||||
String messageBody = """
|
||||
{
|
||||
"group" : "basic.group.1",
|
||||
"name" : "bg1",
|
||||
"version" : "1.2.345",
|
||||
"sourceUrl" : "http://example.com/cucumber.jar"
|
||||
}
|
||||
"""
|
||||
Response response = integrationRestApiClient.postJsonToPath(path, messageBody, false)
|
||||
UatArtifact uatArtifact = response.readEntity(UatArtifact)
|
||||
System.setProperty("artifactId", String.valueOf(uatArtifact.id))
|
||||
response.close()
|
||||
|
||||
return response.status == 201
|
||||
|
||||
}
|
||||
|
||||
def "create artifact should return success"() {
|
||||
|
||||
when:
|
||||
boolean success = integModelHelper.sendCreateArtifact()
|
||||
boolean success = sendCreateArtifact()
|
||||
|
||||
then:
|
||||
success == true
|
||||
|
@ -25,9 +46,10 @@ class ArtifactTriggerSpec extends Specification {
|
|||
|
||||
def "read artifact should return success"() {
|
||||
when:
|
||||
boolean success = integModelHelper.sendGetApi("/api/artifacts/1")
|
||||
String path = "/api/artifacts/" + System.getProperty("artifactId")
|
||||
boolean success = integModelHelper.sendGetApi(path)
|
||||
|
||||
then:
|
||||
success == true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package uat
|
||||
package deploydb
|
||||
|
||||
import dropwizardintegtest.IntegrationRestApiClient
|
||||
|
||||
|
@ -9,18 +9,18 @@ class ConsulClient {
|
|||
|
||||
IntegrationRestApiClient restApiClient = new IntegrationRestApiClient()
|
||||
|
||||
List<String> getDeploydbHosts() {
|
||||
def getDeploydbHosts() {
|
||||
|
||||
restApiClient.port = 8500
|
||||
String path = "/v1/health/service/deploydb?passing"
|
||||
Response response = restApiClient.getFromPath(path, false)
|
||||
List<String> hosts = new ArrayList()
|
||||
def hosts = [:]
|
||||
|
||||
List<ServiceHealth> serviceHealthList = response.readEntity(new GenericType<List<ServiceHealth>>(){})
|
||||
serviceHealthList.each {
|
||||
hosts << it.node.address + ":" + it.service.port
|
||||
hosts[it.node.address] = it.service.port
|
||||
}
|
||||
|
||||
return hosts
|
||||
hosts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,65 @@
|
|||
package uat
|
||||
package deploydb
|
||||
|
||||
import spock.lang.*
|
||||
import dropwizardintegtest.IntegrationModelHelper
|
||||
import dropwizardintegtest.IntegrationRestApiClient
|
||||
|
||||
import javax.ws.rs.core.GenericType
|
||||
import javax.ws.rs.core.Response
|
||||
|
||||
class DeploymentTriggerSpec extends Specification {
|
||||
|
||||
IntegrationRestApiClient integrationRestApiClient = new IntegrationRestApiClient()
|
||||
IntegrationModelHelper integModelHelper = new IntegrationModelHelper(integrationRestApiClient)
|
||||
static List<UatDeployment> uatDeployments
|
||||
|
||||
def setup() {
|
||||
//integrationRestApiClient.host = "http://10.32.10.63"
|
||||
integrationRestApiClient.host = "http://localhost"
|
||||
integrationRestApiClient.host = "http://" + System.getProperty("DeploydbHost")
|
||||
integrationRestApiClient.port = Integer.valueOf(System.getProperty("DeploydbPort"))
|
||||
}
|
||||
|
||||
def "read artifact should return success"() {
|
||||
boolean sendGetDeployments() {
|
||||
String path = "/api/deployments/by-artifact/" + System.getProperty("artifactId")
|
||||
|
||||
Response response = integrationRestApiClient.getFromPath(path, false)
|
||||
|
||||
uatDeployments = response.readEntity(new GenericType<List<UatDeployment>>(){})
|
||||
|
||||
response.close()
|
||||
return response.status == 200
|
||||
|
||||
}
|
||||
|
||||
def "read deployments should return success"() {
|
||||
when:
|
||||
boolean success = integModelHelper.sendGetApi("/api/deployments/1")
|
||||
boolean success = sendGetDeployments()
|
||||
|
||||
then:
|
||||
success == true
|
||||
}
|
||||
|
||||
def "update the deployments to started should return success"() {
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentStartedTrigger(uatDeployments[0].id)
|
||||
|
||||
then:
|
||||
success == true
|
||||
}
|
||||
|
||||
def "update the deployments to completed should return success"() {
|
||||
when:
|
||||
boolean success = integModelHelper.sendDeploymentCompletedTrigger(uatDeployments[0].id)
|
||||
|
||||
then:
|
||||
success == true
|
||||
}
|
||||
|
||||
def "update the deployments promotion completed should return success"() {
|
||||
when:
|
||||
boolean success = integModelHelper.sendPromotionCompletedTrigger(uatDeployments[0].id)
|
||||
|
||||
then:
|
||||
success == true
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package uat
|
||||
package deploydb
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package uat
|
||||
package deploydb
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package uat
|
||||
package deploydb
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package uat
|
||||
package deploydb
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package uat
|
||||
package deploydb
|
||||
|
||||
import spock.util.EmbeddedSpecRunner
|
||||
import dropwizardintegtest.IntegrationRestApiClient
|
||||
|
||||
import javax.ws.rs.core.Response
|
||||
|
||||
class TestRunner {
|
||||
private EmbeddedSpecRunner embeddedSpecRunner = new EmbeddedSpecRunner()
|
||||
|
@ -20,4 +23,18 @@ class TestRunner {
|
|||
embeddedSpecRunner.runClass(it)
|
||||
}
|
||||
}
|
||||
|
||||
boolean cleanupModels() {
|
||||
IntegrationRestApiClient integrationRestApiClient = new IntegrationRestApiClient()
|
||||
integrationRestApiClient.host = "http://" + System.getProperty("DeploydbHost")
|
||||
|
||||
// admin port in one more than the application by convention
|
||||
integrationRestApiClient.port = Integer.valueOf(System.getProperty("DeploydbPort")) + 1
|
||||
|
||||
String path = "/tasks/modelCleanup?group=basic.group.1&name=bg1&version=1.2.345"
|
||||
Response response = integrationRestApiClient.postJsonToPath(path, "", false)
|
||||
response.close()
|
||||
|
||||
return response.status == 200
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package deploydb
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class UatArtifact {
|
||||
|
||||
@JsonProperty
|
||||
long id
|
||||
|
||||
UatArtifact() { }
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package deploydb
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class UatDeployment {
|
||||
|
||||
@JsonProperty
|
||||
long id
|
||||
|
||||
UatDeployment() { }
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package uat
|
||||
package deploydb
|
||||
|
||||
import org.codehaus.groovy.testng.TestNgRunner
|
||||
|
||||
|
@ -6,12 +6,19 @@ import org.codehaus.groovy.testng.TestNgRunner
|
|||
class UatMainApp {
|
||||
|
||||
static void main(String[] args) {
|
||||
uat.TestRunner testRunner = new uat.TestRunner()
|
||||
deploydb.TestRunner testRunner = new deploydb.TestRunner()
|
||||
ConsulClient consulClient = new ConsulClient()
|
||||
|
||||
consulClient.getDeploydbHosts()
|
||||
boolean success = testRunner.runTests()
|
||||
boolean success = true
|
||||
consulClient.getDeploydbHosts().each { key, value ->
|
||||
System.setProperty("DeploydbHost", key)
|
||||
System.setProperty("DeploydbPort", String.valueOf(value))
|
||||
if(false == testRunner.cleanupModels()) {
|
||||
System.exit(1)
|
||||
}
|
||||
success &= testRunner.runTests()
|
||||
}
|
||||
|
||||
success ? System.exit(0):System.exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue