diff --git a/build.gradle b/build.gradle index c603df7..e29e551 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ dependencies { 'dropwizard-views-mustache', 'dropwizard-testing', ].each { - compile withSources("io.dropwizard:${it}:0.8.1") + compile withSources("io.dropwizard:${it}:${dropwizardVersion}") } /* Used instead of the default HTTP connector for the Jersey client to diff --git a/dropwizard-integtest/src/main/groovy/IntegrationModelHelper.groovy b/dropwizard-integtest/src/main/groovy/IntegrationModelHelper.groovy index e2e89a1..6ca7a60 100644 --- a/dropwizard-integtest/src/main/groovy/IntegrationModelHelper.groovy +++ b/dropwizard-integtest/src/main/groovy/IntegrationModelHelper.groovy @@ -2,6 +2,10 @@ package dropwizardintegtest import javax.ws.rs.core.Response +/** + * This class is used by the spock integration test suites and UAT tests. This will be used by + * clients of deploydb to verify the contract of deploydb interface + */ class IntegrationModelHelper { private IntegrationRestApiClient integrationRestApiClient = null diff --git a/dropwizard-integtest/src/main/groovy/IntegrationRestApiClient.groovy b/dropwizard-integtest/src/main/groovy/IntegrationRestApiClient.groovy index f3e97b9..6770ead 100644 --- a/dropwizard-integtest/src/main/groovy/IntegrationRestApiClient.groovy +++ b/dropwizard-integtest/src/main/groovy/IntegrationRestApiClient.groovy @@ -12,6 +12,11 @@ import org.glassfish.jersey.client.JerseyInvocation import javax.ws.rs.core.Response import javax.ws.rs.client.Entity +/** + * This class is used by the spock integration test suites and UAT tests. This will be used by + * clients to send REST calls to servers and return responses from the server for further + * processing in the client code + */ class IntegrationRestApiClient { private Client jerseyClient = null String host = "http://localhost" diff --git a/features/api/cleanup.feature b/features/api/cleanup.feature index 6e8174a..a48ebb6 100644 --- a/features/api/cleanup.feature +++ b/features/api/cleanup.feature @@ -1,7 +1,7 @@ Feature: DeployDB cleanup APIs As a DeployDB administrator - I should be able to cleanup the artifact, deployment promotion results models + I should be able to delete the artifact, deployment promotion results models from deploydb Scenario: The model cleanup shall be successful Given there is a deployment diff --git a/gradle.properties b/gradle.properties index 46fe7b6..7635c4c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ org.gradle.daemon=false bintrayUser= bintrayKey= +dropwizardVersion = 0.8.1 \ No newline at end of file diff --git a/src/test/groovy/deploydb/DeploymentCompletedNotificationsSpec.groovy b/src/test/groovy/deploydb/DeploymentCompletedNotificationsSpec.groovy index 983a691..816aa8e 100644 --- a/src/test/groovy/deploydb/DeploymentCompletedNotificationsSpec.groovy +++ b/src/test/groovy/deploydb/DeploymentCompletedNotificationsSpec.groovy @@ -11,6 +11,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { IntegrationRestApiClient integrationRestApiClient = new IntegrationRestApiClient() IntegrationModelHelper integModelHelper = new IntegrationModelHelper(integrationRestApiClient) private WebhooksModelConfigHelper mcfgHelper = new WebhooksModelConfigHelper() + private long deploymentId = 1L def setup() { mcfgHelper.setup() @@ -30,7 +31,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { def "no webhook should be called when you receive deployment completed trigger if there is no webhook config" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createEnvironmentNoWebhooksConfigFile() // load up the configuration @@ -40,7 +41,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L) + boolean success = integModelHelper.sendDeploymentCompletedTrigger(deploymentId) then: success == true @@ -51,7 +52,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { def "webhook should be called when you receive deployment completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createDeploymentCompletedWebhookConfigFile() mcfgHelper.createEnvironmentNoWebhooksConfigFile() @@ -68,7 +69,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L) + boolean success = integModelHelper.sendDeploymentCompletedTrigger(deploymentId) then: success == true @@ -79,7 +80,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { def "environment webhook should be called when you receive deployment completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createDeploymentCompletedEnvironmentWebhookConfigFile() // load up the configuration @@ -95,7 +96,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L) + boolean success = integModelHelper.sendDeploymentCompletedTrigger(deploymentId) then: success == true @@ -106,7 +107,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { def "both global and environment webhooks should be called when you receive deployment completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createDeploymentCompletedWebhookConfigFile() mcfgHelper.createDeploymentCompletedEnvironmentWebhookConfigFile() @@ -123,7 +124,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L) + boolean success = integModelHelper.sendDeploymentCompletedTrigger(deploymentId) then: success == true @@ -134,7 +135,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { def "multiple webhooks should be called when you receive deployment completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultipleDeploymentCompletedWebhooksConfigFile() mcfgHelper.createEnvironmentNoWebhooksConfigFile() @@ -151,7 +152,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L) + boolean success = integModelHelper.sendDeploymentCompletedTrigger(deploymentId) then: success == true @@ -162,7 +163,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { def "multiple environments webhook should be called when you receive deployment completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultipleDeploymentCompletedEnvironmentWebhooksConfigFile() // load up the configuration @@ -178,7 +179,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L) + boolean success = integModelHelper.sendDeploymentCompletedTrigger(deploymentId) then: success == true @@ -189,7 +190,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { def "both multiple global and environment webhooks should be called when you receive deployment completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultipleDeploymentCompletedWebhooksConfigFile() mcfgHelper.createMultipleDeploymentCompletedEnvironmentWebhooksConfigFile() @@ -207,7 +208,7 @@ class DeploymentCompletedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentCompletedTrigger(1L) + boolean success = integModelHelper.sendDeploymentCompletedTrigger(deploymentId) then: success == true diff --git a/src/test/groovy/deploydb/DeploymentCreatedNotificationsSpec.groovy b/src/test/groovy/deploydb/DeploymentCreatedNotificationsSpec.groovy index 2c22054..66a9348 100644 --- a/src/test/groovy/deploydb/DeploymentCreatedNotificationsSpec.groovy +++ b/src/test/groovy/deploydb/DeploymentCreatedNotificationsSpec.groovy @@ -30,7 +30,7 @@ class DeploymentCreatedNotificationsSpec extends Specification { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createEnvironmentNoWebhooksConfigFile() // load up the configuration @@ -50,7 +50,7 @@ class DeploymentCreatedNotificationsSpec extends Specification { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createWebhookConfigFile() mcfgHelper.createEnvironmentNoWebhooksConfigFile() @@ -77,7 +77,7 @@ class DeploymentCreatedNotificationsSpec extends Specification { given: // create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createEnvironmentConfigFile() // load up the config @@ -102,7 +102,7 @@ class DeploymentCreatedNotificationsSpec extends Specification { given: // create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createWebhookConfigFile() mcfgHelper.createEnvironmentConfigFile() @@ -128,7 +128,7 @@ class DeploymentCreatedNotificationsSpec extends Specification { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultipleWebhooksConfigFile() mcfgHelper.createEnvironmentNoWebhooksConfigFile() @@ -154,7 +154,7 @@ class DeploymentCreatedNotificationsSpec extends Specification { given: // create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultipleWebhooksEnvironmentConfigFile() // load up the config @@ -179,7 +179,7 @@ class DeploymentCreatedNotificationsSpec extends Specification { given: // create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultipleWebhooksConfigFile() mcfgHelper.createMultipleWebhooksEnvironmentConfigFile() diff --git a/src/test/groovy/deploydb/DeploymentStartedNotificationsSpec.groovy b/src/test/groovy/deploydb/DeploymentStartedNotificationsSpec.groovy index b653074..ee0967e 100644 --- a/src/test/groovy/deploydb/DeploymentStartedNotificationsSpec.groovy +++ b/src/test/groovy/deploydb/DeploymentStartedNotificationsSpec.groovy @@ -11,6 +11,7 @@ class DeploymentStartedNotificationsSpec extends Specification { IntegrationRestApiClient integrationRestApiClient = new IntegrationRestApiClient() IntegrationModelHelper integModelHelper = new IntegrationModelHelper(integrationRestApiClient) private WebhooksModelConfigHelper mcfgHelper = new WebhooksModelConfigHelper() + private long deploymentId = 1L def setup() { mcfgHelper.setup() @@ -30,7 +31,7 @@ class DeploymentStartedNotificationsSpec extends Specification { def "no webhook should be called when you receive deployment started trigger if there is no webhook config" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createEnvironmentNoWebhooksConfigFile() // load up the configuration @@ -38,7 +39,7 @@ class DeploymentStartedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentStartedTrigger(1L) + boolean success = integModelHelper.sendDeploymentStartedTrigger(deploymentId) then: success == true @@ -49,7 +50,7 @@ class DeploymentStartedNotificationsSpec extends Specification { def "webhook should be called when you receive deployment started trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createDeploymentStartedWebhookConfigFile() mcfgHelper.createEnvironmentNoWebhooksConfigFile() @@ -66,7 +67,7 @@ class DeploymentStartedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentStartedTrigger(1L) + boolean success = integModelHelper.sendDeploymentStartedTrigger(deploymentId) then: success == true @@ -77,7 +78,7 @@ class DeploymentStartedNotificationsSpec extends Specification { def "environment webhook should be called when you receive deployment started trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createDeploymentStartedEnvironmentWebhookConfigFile() // load up the configuration @@ -93,7 +94,7 @@ class DeploymentStartedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentStartedTrigger(1L) + boolean success = integModelHelper.sendDeploymentStartedTrigger(deploymentId) then: success == true @@ -104,7 +105,7 @@ class DeploymentStartedNotificationsSpec extends Specification { def "both global and environment webhooks should be called when you receive deployment started trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createDeploymentStartedWebhookConfigFile() mcfgHelper.createDeploymentStartedEnvironmentWebhookConfigFile() @@ -121,7 +122,7 @@ class DeploymentStartedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentStartedTrigger(1L) + boolean success = integModelHelper.sendDeploymentStartedTrigger(deploymentId) then: success == true @@ -132,7 +133,7 @@ class DeploymentStartedNotificationsSpec extends Specification { def "multiple webhooks should be called when you receive deployment started trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultipleDeploymentStartedWebhooksConfigFile() mcfgHelper.createEnvironmentNoWebhooksConfigFile() @@ -148,7 +149,7 @@ class DeploymentStartedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentStartedTrigger(1L) + boolean success = integModelHelper.sendDeploymentStartedTrigger(deploymentId) then: success == true @@ -159,7 +160,7 @@ class DeploymentStartedNotificationsSpec extends Specification { def "multiple environments webhook should be called when you receive deployment started trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultipleDeploymentStartedEnvironmentWebhooksConfigFile() // load up the configuration @@ -176,7 +177,7 @@ class DeploymentStartedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentStartedTrigger(1L) + boolean success = integModelHelper.sendDeploymentStartedTrigger(deploymentId) then: success == true @@ -187,7 +188,7 @@ class DeploymentStartedNotificationsSpec extends Specification { def "both multiple global and environment webhooks should be called when you receive deployment started trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultipleDeploymentStartedWebhooksConfigFile() mcfgHelper.createMultipleDeploymentStartedEnvironmentWebhooksConfigFile() @@ -205,7 +206,7 @@ class DeploymentStartedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() when: - boolean success = integModelHelper.sendDeploymentStartedTrigger(1L) + boolean success = integModelHelper.sendDeploymentStartedTrigger(deploymentId) then: success == true diff --git a/src/test/groovy/deploydb/ModelConfigHelper.groovy b/src/test/groovy/deploydb/ModelConfigHelper.groovy index 35c3ad8..bbfa73b 100644 --- a/src/test/groovy/deploydb/ModelConfigHelper.groovy +++ b/src/test/groovy/deploydb/ModelConfigHelper.groovy @@ -204,13 +204,13 @@ promotions: serviceFile.write(fileContents) } - def createServicePromoitionPipelineModelsConfigFiles() { + def createServicePromotionPipelineModelsConfigFiles() { createPromotionConfigFile() createPipelineConfigFile() createServiceConfigFile() } - def createBasicProdServicePromoitionPipelineModelsConfigFiles() { + def createBasicProdServicePromotionPipelineModelsConfigFiles() { createEnvironmentConfigFile() createProdEnvironmentConfigFile() createPromotionConfigFile() diff --git a/src/test/groovy/deploydb/MultipleEnvironmentsNotificationsSpec.groovy b/src/test/groovy/deploydb/MultipleEnvironmentsNotificationsSpec.groovy index 4677e8d..4b26a7a 100644 --- a/src/test/groovy/deploydb/MultipleEnvironmentsNotificationsSpec.groovy +++ b/src/test/groovy/deploydb/MultipleEnvironmentsNotificationsSpec.groovy @@ -11,6 +11,7 @@ class MultipleEnvironmentsNotificationsSpec extends Specification { IntegrationRestApiClient integrationRestApiClient = new IntegrationRestApiClient() IntegrationModelHelper integModelHelper = new IntegrationModelHelper(integrationRestApiClient) private WebhooksModelConfigHelper mcfgHelper = new WebhooksModelConfigHelper() + private long deploymentId = 1L def setup() { mcfgHelper.setup() @@ -38,7 +39,7 @@ class MultipleEnvironmentsNotificationsSpec extends Specification { given: // Create the required config - mcfgHelper.createBasicProdServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createBasicProdServicePromotionPipelineModelsConfigFiles() // load up the configuration integAppHelper.runner.getApplication().loadModelConfiguration() @@ -65,7 +66,7 @@ class MultipleEnvironmentsNotificationsSpec extends Specification { integAppHelper.webhookRunner.requestWebhookObject.configuredUriPaths = ["/job/basicEnv-deploy-created/build", "/job/basicEnv-deploy-completed/build"] - success = integModelHelper.sendDeploymentCompletedTrigger(1L) + success = integModelHelper.sendDeploymentCompletedTrigger(deploymentId) then: success == true @@ -80,7 +81,7 @@ class MultipleEnvironmentsNotificationsSpec extends Specification { ["/job/basicEnv-deploy-created/build", "/job/basicEnv-deploy-completed/build", "/job/prodEnv-deploy-created/build"] - success = integModelHelper.sendPromotionCompletedTrigger(1L) + success = integModelHelper.sendPromotionCompletedTrigger(deploymentId) then: success == true diff --git a/src/test/groovy/deploydb/PromotionCompletedNotificationSpec.groovy b/src/test/groovy/deploydb/PromotionCompletedNotificationSpec.groovy index ac83455..5baa5e8 100644 --- a/src/test/groovy/deploydb/PromotionCompletedNotificationSpec.groovy +++ b/src/test/groovy/deploydb/PromotionCompletedNotificationSpec.groovy @@ -11,6 +11,7 @@ class PromotionCompletedNotificationsSpec extends Specification { IntegrationRestApiClient integrationRestApiClient = new IntegrationRestApiClient() IntegrationModelHelper integModelHelper = new IntegrationModelHelper(integrationRestApiClient) private WebhooksModelConfigHelper mcfgHelper = new WebhooksModelConfigHelper() + private long deploymentId = 1L def setup() { mcfgHelper.setup() @@ -34,14 +35,14 @@ class PromotionCompletedNotificationsSpec extends Specification { integModelHelper.sendCreateArtifact() - integModelHelper.sendDeploymentStartedTrigger(1L) - integModelHelper.sendDeploymentCompletedTrigger(1L) + integModelHelper.sendDeploymentStartedTrigger(deploymentId) + integModelHelper.sendDeploymentCompletedTrigger(deploymentId) } def "no webhook should be called when you receive promotion completed trigger if there is no webhook config" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createEnvironmentNoWebhooksConfigFile() // load up the configuration @@ -51,7 +52,7 @@ class PromotionCompletedNotificationsSpec extends Specification { setupDeploymentForPromotionTrigger() when: - boolean success = integModelHelper.sendPromotionCompletedTrigger(1L) + boolean success = integModelHelper.sendPromotionCompletedTrigger(deploymentId) then: success == true @@ -62,7 +63,7 @@ class PromotionCompletedNotificationsSpec extends Specification { def "webhook should be called when you receive promotion completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createPromotionCompletedWebhookConfigFile() mcfgHelper.createEnvironmentNoWebhooksConfigFile() @@ -78,7 +79,7 @@ class PromotionCompletedNotificationsSpec extends Specification { setupDeploymentForPromotionTrigger() when: - boolean success = integModelHelper.sendPromotionCompletedTrigger(1L) + boolean success = integModelHelper.sendPromotionCompletedTrigger(deploymentId) then: success == true @@ -89,7 +90,7 @@ class PromotionCompletedNotificationsSpec extends Specification { def "environment webhook should be called when you receive promotion completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createPromotionCompletedEnvironmentWebhookConfigFile() // load up the configuration @@ -104,7 +105,7 @@ class PromotionCompletedNotificationsSpec extends Specification { setupDeploymentForPromotionTrigger() when: - boolean success = integModelHelper.sendPromotionCompletedTrigger(1L) + boolean success = integModelHelper.sendPromotionCompletedTrigger(deploymentId) then: success == true @@ -115,7 +116,7 @@ class PromotionCompletedNotificationsSpec extends Specification { def "both global and environment webhooks should be called when you receive promotion completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createPromotionCompletedWebhookConfigFile() mcfgHelper.createPromotionCompletedEnvironmentWebhookConfigFile() @@ -131,7 +132,7 @@ class PromotionCompletedNotificationsSpec extends Specification { setupDeploymentForPromotionTrigger() when: - boolean success = integModelHelper.sendPromotionCompletedTrigger(1L) + boolean success = integModelHelper.sendPromotionCompletedTrigger(deploymentId) then: success == true @@ -142,7 +143,7 @@ class PromotionCompletedNotificationsSpec extends Specification { def "multiple webhooks should be called when you receive promotion completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultiplePromotionCompletedWebhookConfigFile() mcfgHelper.createEnvironmentNoWebhooksConfigFile() @@ -158,7 +159,7 @@ class PromotionCompletedNotificationsSpec extends Specification { setupDeploymentForPromotionTrigger() when: - boolean success = integModelHelper.sendPromotionCompletedTrigger(1L) + boolean success = integModelHelper.sendPromotionCompletedTrigger(deploymentId) then: success == true @@ -169,7 +170,7 @@ class PromotionCompletedNotificationsSpec extends Specification { def "multiple environment webhooks should be called when you receive promotion completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultiplePromotionCompletedEnvironmentWebhookConfigFile() // load up the configuration @@ -184,7 +185,7 @@ class PromotionCompletedNotificationsSpec extends Specification { setupDeploymentForPromotionTrigger() when: - boolean success = integModelHelper.sendPromotionCompletedTrigger(1L) + boolean success = integModelHelper.sendPromotionCompletedTrigger(deploymentId) then: success == true @@ -195,7 +196,7 @@ class PromotionCompletedNotificationsSpec extends Specification { def "both multiple global and environment webhooks should be called when you receive promotion completed trigger" () { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createMultiplePromotionCompletedEnvironmentWebhookConfigFile() mcfgHelper.createMultiplePromotionCompletedWebhookConfigFile() @@ -212,7 +213,7 @@ class PromotionCompletedNotificationsSpec extends Specification { setupDeploymentForPromotionTrigger() when: - boolean success = integModelHelper.sendPromotionCompletedTrigger(1L) + boolean success = integModelHelper.sendPromotionCompletedTrigger(deploymentId) then: success == true @@ -236,9 +237,8 @@ class PromotionCompletedNotificationsSpec extends Specification { setupDeploymentForPromotionTrigger() when: - boolean success = integModelHelper.sendPromotionCompletedTrigger(1L) + boolean success = integModelHelper.sendPromotionCompletedTrigger(deploymentId) models.Deployment deployment - Long deploymentId = 1 integAppHelper.withSession { deployment = integAppHelper.runner.getApplication().workFlow.deploymentDAO .get(deploymentId) diff --git a/src/test/groovy/deploydb/dao/DeploymentDAOSpec.groovy b/src/test/groovy/deploydb/dao/DeploymentDAOSpec.groovy index 3175254..e8f07d3 100644 --- a/src/test/groovy/deploydb/dao/DeploymentDAOSpec.groovy +++ b/src/test/groovy/deploydb/dao/DeploymentDAOSpec.groovy @@ -62,7 +62,7 @@ class DeploymentDAOSpec extends Specification { def "getByEnvironmentIdent() should returns deployments for the environment ident"() { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createEnvironmentNoWebhooksConfigFile() // load up the configuration diff --git a/src/test/groovy/deploydb/models/FlowSpec.groovy b/src/test/groovy/deploydb/models/FlowSpec.groovy index 1b34048..9ef212e 100644 --- a/src/test/groovy/deploydb/models/FlowSpec.groovy +++ b/src/test/groovy/deploydb/models/FlowSpec.groovy @@ -320,7 +320,7 @@ class FlowCleanupSpec extends Specification { def "delete of existing flow cleans up deployments and artifact"() { given: // Create the required config - mcfgHelper.createServicePromoitionPipelineModelsConfigFiles() + mcfgHelper.createServicePromotionPipelineModelsConfigFiles() mcfgHelper.createEnvironmentNoWebhooksConfigFile() // load up the configuration diff --git a/uat/build.gradle b/uat/build.gradle index d8366db..20b0524 100644 --- a/uat/build.gradle +++ b/uat/build.gradle @@ -5,13 +5,11 @@ apply plugin: 'application' apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.jfrog.bintray' -version = '0.1' -group = 'com.github.lookout.deploydb.uat' +version = rootProject.version +group = 'com.github.lookout.uat' description = 'User Acceptance Testing artifact for deploydb' -mainClassName = 'deploydb.UatMainApp' - -project.targetCompatibility = 1.7 +mainClassName = 'uat.UatMainApp' dependencies { compile ('org.codehaus.groovy:groovy-all:2.4.0+') @@ -23,7 +21,7 @@ dependencies { 'dropwizard-views-mustache', 'dropwizard-testing', ].each { - compile ("io.dropwizard:${it}:0.8.1") + compile ("io.dropwizard:${it}:${dropwizardVersion}") } /* Used instead of the default HTTP connector for the Jersey client to @@ -37,14 +35,6 @@ dependencies { repositories { jcenter() - - mavenCentral() - maven { url 'http://dl.bintray.com/lookout/systems' } -} - -task generateScript(type: CreateStartScripts) { - applicationName = "uatDeploydb" - outputDir = new File("build/dist/") } shadowJar { diff --git a/uat/src/main/groovy/ArtifactTriggerSpec.groovy b/uat/src/main/groovy/ArtifactTriggerSpec.groovy index 91902ec..c78bc8a 100644 --- a/uat/src/main/groovy/ArtifactTriggerSpec.groovy +++ b/uat/src/main/groovy/ArtifactTriggerSpec.groovy @@ -1,4 +1,4 @@ -package deploydb +package uat import spock.lang.* import dropwizardintegtest.IntegrationModelHelper @@ -28,7 +28,12 @@ class ArtifactTriggerSpec extends Specification { """ Response response = integrationRestApiClient.postJsonToPath(path, messageBody, false) UatArtifact uatArtifact = response.readEntity(UatArtifact) - System.setProperty("artifactId", String.valueOf(uatArtifact.id)) + /** + * We can't hard code the id to fetch the deployment because in some environments there + * will be more artifacts than test artifacts created by UAT + * Let's save the created artifact id and use them to read artifact and deployments + */ + System.setProperty("artifactId", String.valueOf(uatArtifact.id)) response.close() return response.status == 201 diff --git a/uat/src/main/groovy/ConsulClient.groovy b/uat/src/main/groovy/ConsulClient.groovy index 9424b66..90ed1fc 100644 --- a/uat/src/main/groovy/ConsulClient.groovy +++ b/uat/src/main/groovy/ConsulClient.groovy @@ -1,6 +1,7 @@ -package deploydb +package uat import dropwizardintegtest.IntegrationRestApiClient +import uat.consul.ServiceHealth import javax.ws.rs.core.Response import javax.ws.rs.core.GenericType diff --git a/uat/src/main/groovy/DeploymentTriggerSpec.groovy b/uat/src/main/groovy/DeploymentTriggerSpec.groovy index e168aae..1fe1cf9 100644 --- a/uat/src/main/groovy/DeploymentTriggerSpec.groovy +++ b/uat/src/main/groovy/DeploymentTriggerSpec.groovy @@ -1,4 +1,4 @@ -package deploydb +package uat import spock.lang.* import dropwizardintegtest.IntegrationModelHelper @@ -19,6 +19,12 @@ class DeploymentTriggerSpec extends Specification { } boolean sendGetDeployments() { + /** + * We can't hard code the id to fetch the deployment because in some environments there + * will be more artifacts than test artifacts created by UAT + * Let's use the artifact id of that was created as part of ArtifactTriggerSpec and use + * that to fectch the deployment. + */ String path = "/api/deployments/by-artifact/" + System.getProperty("artifactId") Response response = integrationRestApiClient.getFromPath(path, false) diff --git a/uat/src/main/groovy/TestRunner.groovy b/uat/src/main/groovy/TestRunner.groovy index 46a864e..712d798 100644 --- a/uat/src/main/groovy/TestRunner.groovy +++ b/uat/src/main/groovy/TestRunner.groovy @@ -1,4 +1,4 @@ -package deploydb +package uat import spock.util.EmbeddedSpecRunner import dropwizardintegtest.IntegrationRestApiClient @@ -24,14 +24,15 @@ class TestRunner { } } - boolean cleanupModels() { + boolean cleanupModels(String artifactGroup, String artifactName, String artifactVersion) { 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" + String path = "/tasks/modelCleanup?group="+artifactGroup+"&name="+artifactName+"&version="+artifactVersion +// String path = "/tasks/modelCleanup?group=basic.group.1&name=bg1&version=1.2.345" Response response = integrationRestApiClient.postJsonToPath(path, "", false) response.close() diff --git a/uat/src/main/groovy/UatArtifact.groovy b/uat/src/main/groovy/UatArtifact.groovy index 35dce9d..e5df3d5 100644 --- a/uat/src/main/groovy/UatArtifact.groovy +++ b/uat/src/main/groovy/UatArtifact.groovy @@ -1,9 +1,19 @@ -package deploydb +package uat import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonIgnoreProperties +/** + * For UAT tests we need to deserialize the Artifact model. + * We can't use the deploydb models because of gradle sub projects dependencies issue. + * Ideally we should have a top level "api" directory for deploydb that has models in them. + * + * Class to access the Artifact returned by deploydb REST API + */ @JsonIgnoreProperties(ignoreUnknown = true) +/* + * We only need id property to run UAT tests, so ignore the rest + */ public class UatArtifact { @JsonProperty diff --git a/uat/src/main/groovy/UatDeployment.groovy b/uat/src/main/groovy/UatDeployment.groovy index b0cf43b..78965e5 100644 --- a/uat/src/main/groovy/UatDeployment.groovy +++ b/uat/src/main/groovy/UatDeployment.groovy @@ -1,9 +1,19 @@ -package deploydb +package uat import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonIgnoreProperties +/** + * For UAT tests we need to deserialize the Deployment model. + * We can't use the deploydb models because of gradle sub projects dependencies issue. + * Ideally we should have a top level "api" directory for deploydb that has models in them. + * + * Class to access the Deployment returned by deploydb REST API + */ @JsonIgnoreProperties(ignoreUnknown = true) +/* + * We only need id property to run UAT tests, so ignore the rest + */ public class UatDeployment { @JsonProperty diff --git a/uat/src/main/groovy/UatMainApp.groovy b/uat/src/main/groovy/UatMainApp.groovy index eb3c7ff..b72ad2f 100644 --- a/uat/src/main/groovy/UatMainApp.groovy +++ b/uat/src/main/groovy/UatMainApp.groovy @@ -1,4 +1,4 @@ -package deploydb +package uat import org.codehaus.groovy.testng.TestNgRunner @@ -6,14 +6,19 @@ import org.codehaus.groovy.testng.TestNgRunner class UatMainApp { static void main(String[] args) { - deploydb.TestRunner testRunner = new deploydb.TestRunner() + uat.TestRunner testRunner = new uat.TestRunner() ConsulClient consulClient = new ConsulClient() boolean success = true consulClient.getDeploydbHosts().each { key, value -> System.setProperty("DeploydbHost", key) System.setProperty("DeploydbPort", String.valueOf(value)) - if(false == testRunner.cleanupModels()) { + + /* + * Delete the test artifact, deployments and promotion results if they already present. + * This will allow the UAT tests to rerun for long lived environment + */ + if(false == testRunner.cleanupModels("basic.group.1", "bg1","1.2.345")) { System.exit(1) } success &= testRunner.runTests() diff --git a/uat/src/main/groovy/HealthCheck.groovy b/uat/src/main/groovy/consul/HealthCheck.groovy similarity index 83% rename from uat/src/main/groovy/HealthCheck.groovy rename to uat/src/main/groovy/consul/HealthCheck.groovy index fea2bb3..01d4b93 100644 --- a/uat/src/main/groovy/HealthCheck.groovy +++ b/uat/src/main/groovy/consul/HealthCheck.groovy @@ -1,10 +1,13 @@ -package deploydb +package uat.consul import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +/** + * Consul health check model. Used in UAT's service discovery of deploydb + */ @JsonIgnoreProperties(ignoreUnknown = true) -public class HealthCheck { +class HealthCheck { @JsonProperty("Node") private String node diff --git a/uat/src/main/groovy/Node.groovy b/uat/src/main/groovy/consul/Node.groovy similarity index 72% rename from uat/src/main/groovy/Node.groovy rename to uat/src/main/groovy/consul/Node.groovy index f49f8e5..c676d18 100644 --- a/uat/src/main/groovy/Node.groovy +++ b/uat/src/main/groovy/consul/Node.groovy @@ -1,10 +1,13 @@ -package deploydb +package uat.consul import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +/** + * Consul Node model. Used in UAT's service discovery of deploydb + */ @JsonIgnoreProperties(ignoreUnknown = true) -public class Node { +class Node { @JsonProperty("Node") private String node diff --git a/uat/src/main/groovy/Service.groovy b/uat/src/main/groovy/consul/Service.groovy similarity index 76% rename from uat/src/main/groovy/Service.groovy rename to uat/src/main/groovy/consul/Service.groovy index 93f5c00..5c866d9 100644 --- a/uat/src/main/groovy/Service.groovy +++ b/uat/src/main/groovy/consul/Service.groovy @@ -1,10 +1,13 @@ -package deploydb +package uat.consul import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +/** + * Consul Service check model. Used in UAT's service discovery of deploydb + */ @JsonIgnoreProperties(ignoreUnknown = true) -public class Service { +class Service { @JsonProperty("ID") private String id diff --git a/uat/src/main/groovy/ServiceHealth.groovy b/uat/src/main/groovy/consul/ServiceHealth.groovy similarity index 80% rename from uat/src/main/groovy/ServiceHealth.groovy rename to uat/src/main/groovy/consul/ServiceHealth.groovy index 73fe381..e28b74c 100644 --- a/uat/src/main/groovy/ServiceHealth.groovy +++ b/uat/src/main/groovy/consul/ServiceHealth.groovy @@ -1,4 +1,4 @@ -package deploydb +package uat.consul import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty @@ -7,8 +7,11 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.ArrayList import java.util.List +/** + * Consul ServiceHealth check model. Used in UAT's service discovery of deploydb + */ @JsonIgnoreProperties(ignoreUnknown = true) -public class ServiceHealth { +class ServiceHealth { @JsonProperty("Node") private Node node