Fix the step definitons rearrange all model steps to appropriate files and

upgrade gradle to 2.3
 - Use model helper to create the deployment
 - Upgrage gradle to 2.3 in hope of fixing the codenarc dependency issue
   but it didn't make any difference
 - Fixes #108
This commit is contained in:
Giri Dandu 2015-04-06 14:01:23 -04:00
parent d68b57b94e
commit aad71d3d0c
6 changed files with 55 additions and 66 deletions

View File

@ -34,7 +34,7 @@ Feature: Flow READ APIs
"createdAt" : "{{created_timestamp}}"
},
"environment" : "pre-production",
"service" : "bluffdale",
"service" : "faas",
"promotions":[],
"status" : "STARTED",
"createdAt" : "{{created_timestamp}}"
@ -50,12 +50,12 @@ Feature: Flow READ APIs
"createdAt" : "{{created_timestamp}}"
},
"environment" : "production",
"service" : "bluffdale",
"service" : "faas",
"promotions":[],
"status" : "STARTED",
"createdAt" : "{{created_timestamp}}"
}],
"service":"bluffdale"
"service":"faas"
}
"""

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip

View File

@ -1,6 +1,7 @@
package deploydb.cucumber
import deploydb.models.Artifact
import deploydb.models.Deployment
import deploydb.models.Promotion
import deploydb.models.Service
import deploydb.models.Webhook.Webhook
@ -80,4 +81,10 @@ class ModelHelper {
return pipeline
}
Deployment sampleDeployment(Artifact a, String env, deploydb.Status s) {
deploydb.models.Deployment deployment = new deploydb.models.Deployment(a,
env, "faas", s)
return deployment
}
}

View File

@ -29,10 +29,7 @@ Given(~/^there is a deployment$/) { ->
/**
* Create deployment
*/
Deployment d1 = new Deployment(a1,
"pre-prod",
"faas",
Status.STARTED)
Deployment d1 = sampleDeployment(a1, "pre-prod",Status.STARTED)
d1.addPromotionResult(p1)
/* Create a flow */
@ -69,15 +66,9 @@ Given(~/^there are deployments$/) { ->
/**
* Create deployment
*/
Deployment d1 = new Deployment(adao.persist(a1),
"pre-prod",
"faas",
Status.STARTED)
Deployment d1 = sampleDeployment(adao.persist(a1), "pre-prod", Status.STARTED)
d1.addPromotionResult(p1)
Deployment d2 = new Deployment(adao.persist(a2),
"pre-prod",
"faas",
Status.STARTED)
Deployment d2 = sampleDeployment(adao.persist(a2), "pre-prod", Status.STARTED)
d2.addPromotionResult(p2)
/**
@ -104,7 +95,7 @@ Given(~/^there are deployments for artifacts$/) { ->
List<Deployment> deployments = []
[a1, a2].each { Artifact artifact ->
['dev-integ', 'integ', 'pre-prod', 'prod'].each { String env ->
deployments << new Deployment(adao.persist(artifact), env, 'faas', Status.STARTED)
deployments << sampleDeployment(adao.persist(artifact), env, Status.STARTED)
}
}
@ -112,3 +103,40 @@ Given(~/^there are deployments for artifacts$/) { ->
deployments.each { dao.persist(it) }
}
}
When(~/I trigger deployment PATCH with:$/) { String path ->
response = postJsonToPath(path, requestBody, false)
}
And(~/there is a deployment in "(.*?)" state$/) { String deploymentState ->
withSession {
/**
* Create sample artifact
*/
ArtifactDAO adao = new ArtifactDAO(sessionFactory)
Artifact a1 = sampleArtifact()
adao.persist(a1)
/**
* Create sample promotionResult(s)
*/
PromotionResult p1 = new PromotionResult("jenkins-smoke", Status.STARTED, null)
/**
* Create deployment
*/
Deployment d1 = sampleDeployment(a1, "pre-prod", Status."${deploymentState}")
d1.addPromotionResult(p1)
/* Create a flow */
Flow f = new Flow(a1, "faas")
f.addDeployment(d1)
/**
* Save flow in DB, which will save the deployments & promotionResults as well
*/
FlowDAO fdao = new FlowDAO(sessionFactory)
fdao.persist(f)
}
}

View File

@ -17,12 +17,12 @@ Given(~/^there is a flow$/) { ->
FlowDAO fdao = new FlowDAO(sessionFactory)
Artifact a = sampleArtifact()
Deployment d = new Deployment(adao.persist(a), "pre-production", "bluffdale", Status.STARTED)
Deployment d1 = new Deployment(adao.persist(a), "production", "bluffdale", Status.STARTED)
Deployment d = sampleDeployment(adao.persist(a), "pre-production", Status.STARTED)
Deployment d1 = sampleDeployment(adao.persist(a), "production", Status.STARTED)
Flow f = new Flow()
f.setArtifact(a)
f.setService("bluffdale")
f.setService("faas")
d.setFlow(f)
d1.setFlow(f)

View File

@ -4,14 +4,7 @@ this.metaClass.mixin(cucumber.api.groovy.EN)
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import deploydb.ModelLoader
import deploydb.Status
import deploydb.dao.ArtifactDAO
import deploydb.dao.FlowDAO
import deploydb.models.Artifact
import deploydb.models.Deployment
import deploydb.models.Environment
import deploydb.models.Flow
import deploydb.models.PromotionResult
import deploydb.models.Webhook.Webhook
import deploydb.registry.ModelRegistry
import org.joda.time.DateTime
@ -130,46 +123,7 @@ Then(~/^the webhook ([1-9][0-9]*) should be invoked with the JSON:$/) { int webh
}
}
When(~/I trigger deployment PATCH with:$/) { String path ->
response = postJsonToPath(path, requestBody, false)
}
And(~/there is a deployment in "(.*?)" state$/) { String deploymentState ->
withSession {
/**
* Create sample artifact
*/
ArtifactDAO adao = new ArtifactDAO(sessionFactory)
Artifact a1 = sampleArtifact()
adao.persist(a1)
/**
* Create sample promotionResult(s)
*/
PromotionResult p1 = new PromotionResult("jenkins-smoke", Status.STARTED, null)
/**
* Create deployment
*/
Deployment d1 = new Deployment(a1,
"pre-prod",
"faas",
Status."${deploymentState}")
d1.addPromotionResult(p1)
/* Create a flow */
Flow f = new Flow(a1, "faas")
f.addDeployment(d1)
/**
* Save flow in DB, which will save the deployments & promotionResults as well
*/
FlowDAO fdao = new FlowDAO(sessionFactory)
fdao.persist(f)
}
}
And (~/the webhook should have the headers:$/){ DataTable headers ->