Added a spock test to catch deployment premarturely marked as success

References #172
This commit is contained in:
Mahesh V Kelkar 2015-05-04 09:15:23 -04:00
parent 068951bfa1
commit 7b6efb297b
3 changed files with 69 additions and 4 deletions

View File

@ -55,10 +55,12 @@ description: "Basic Smoke test for the Basic Service"
promotionFile.write(fileContents)
}
def createAnotherPromotionConfigFile() {
def createManualPromotionConfigFile() {
String fileContents = """
type: deploydb.models.promotion.ManualLDAPPromotionImpl
description: "Advanced Smoke test for the Basic Service"
description: "Manual LDAP Promotion"
attributes:
allowedGroup: ManualPromotionGroup
"""
/* Create temp file */
File promotionsDir = new File("${baseCfgDirName}/promotions")
@ -66,7 +68,7 @@ description: "Advanced Smoke test for the Basic Service"
promotionsDir.mkdirs()
}
File promotionFile = new File(promotionsDir, "advancedPromo.yml")
File promotionFile = new File(promotionsDir, "manualPromo.yml")
promotionFile.write(fileContents)
}
@ -180,6 +182,28 @@ environments:
pipelineFile.write(fileContents)
}
def createMultiPromoServiceConfigFile() {
String fileContents = """
description: "Basic Service"
artifacts:
- basic.group.1:bg1
- basic.group.2:bg2
pipelines:
- basicPipe
promotions:
- basicPromo
- manualPromo
"""
/* Create temp file */
File servicesDir = new File("${baseCfgDirName}/services")
if (!servicesDir.exists()) {
servicesDir.mkdirs()
}
File serviceFile = new File(servicesDir, "basicServ.yml")
serviceFile.write(fileContents)
}
}
class WebhooksModelConfigHelper extends deploydb.ModelConfigHelper {

View File

@ -215,4 +215,45 @@ class PromotionCompletedNotificationsSpec extends Specification {
sleep(1000)
integAppHelper.webhookRunner.requestWebhookObject.requestMessageBodies.size() == 4
}
def "With multiple promotions, deployment status is not updated with first promotion completed trigger" () {
given:
// Create the required config
mcfgHelper.createPromotionConfigFile()
mcfgHelper.createManualPromotionConfigFile()
mcfgHelper.createEnvironmentNoWebhooksConfigFile()
mcfgHelper.createPipelineConfigFile()
mcfgHelper.createMultiPromoServiceConfigFile()
// load up the configuration
integAppHelper.runner.getApplication().loadModelConfiguration()
// Setup deployment for promotion trigger
setupDeploymentForPromotionTrigger()
when:
boolean success = integModelHelper.sendPromotionCompletedTrigger()
models.Deployment deployment
Long deploymentId = 1
integAppHelper.withSession {
deployment = integAppHelper.runner.getApplication().workFlow.deploymentDAO
.get(deploymentId)
}
println "***MVK: deployment=${deployment}"
then:
success == true
sleep(1000)
deployment != null
deployment.promotionResultSet.size() == 2
deployment.status == Status.COMPLETED
models.PromotionResult manualPromoResult = deployment.promotionResultSet.find() {
pr -> pr.promotionIdent == "manualPromo"
}
manualPromoResult.status == Status.STARTED
models.PromotionResult basicPromoResult = deployment.promotionResultSet.find() {
pr -> pr.promotionIdent == "basicPromo"
}
basicPromoResult.status == Status.SUCCESS
}
}

View File

@ -125,7 +125,7 @@ class WorkFlowWithArgsSpec extends Specification {
modelConfigHelper.createWebhookConfigFile()
workFlow.loadConfigModels()
String oldChecksum = app.configChecksum
modelConfigHelper.createAnotherPromotionConfigFile()
modelConfigHelper.createManualPromotionConfigFile()
mdao.persist(_) >> _
when: