Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #136 from rebeccaSimmonds19/issue134
Browse files Browse the repository at this point in the history
Stop race conditions in deleteeph.sh
  • Loading branch information
rebeccaSimmonds19 authored Oct 16, 2018
2 parents 27634eb + b289cf4 commit fbef515
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/cmd/deleteeph.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/../../hack/lib/init.sh"
TEMPLATE="$(dirname "${BASH_SOURCE}")/../test.json"
trap os::test::junit::reconcile_output EXIT

os::test::junit::declare_suite_start "cmd/deleteeph"
Expand All @@ -23,18 +24,19 @@ os::cmd::expect_failure_and_text "_output/oshinko delete_eph bob --app=sam-1" "B
os::cmd::expect_failure_and_text "_output/oshinko delete_eph bob --app-status=completed" "Both --app and --app-status must be set"
os::cmd::expect_failure_and_text "_output/oshinko delete_eph bob --app=sam-1 --app-status=wrong" "INVALID app-status value, only completed|terminated allowed"

oc new-app hello-world
os::cmd::try_until_success "oc get rc hello-world-1"
os::cmd::expect_success_and_text "_output/oshinko create_eph -e cluster --app=hello-world-1" 'ephemeral cluster cluster'
oc create -f $TEMPLATE
oc new-app test-loop
os::cmd::try_until_success "oc get rc test-loop-dc-1"
os::cmd::expect_success_and_text "_output/oshinko create_eph -e cluster --app=test-loop-dc-1" 'ephemeral cluster cluster'

# replica count won't work for hack/test-cmd, so only do this test when we're started from run.sh
if [ "${USING_OPENSHIFT_INSTANCE:-false}" == true ]; then
os::cmd::try_until_text 'oc get pod -l deploymentconfig=cluster-m --template="{{index .items 0 \"status\" \"phase\"}}"' "Running" $((5*minute))
os::cmd::try_until_text 'oc get pod -l deploymentconfig=cluster-w --template="{{index .items 0 \"status\" \"phase\"}}"' "Running" $((5*minute))
os::cmd::expect_failure_and_text "_output/oshinko delete_eph cluster --app=hello-world-1 --app-status=terminated" "driver replica count > 0 \(or > 1 for completed app\)"
os::cmd::expect_failure_and_text "_output/oshinko delete_eph cluster --app=test-loop-dc-1 --app-status=terminated" "driver replica count > 0 \(or > 1 for completed app\)"
fi
os::cmd::expect_failure_and_text "_output/oshinko delete_eph cluster --app=someother --app-status=terminated" "cluster is not linked to app"

os::cmd::expect_success "_output/oshinko delete_eph cluster --app=hello-world-1 --app-status=completed"
os::cmd::expect_success "_output/oshinko delete_eph cluster --app=test-loop-dc-1 --app-status=completed"

os::test::junit::declare_suite_end
101 changes: 101 additions & 0 deletions test/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"kind": "Template",
"apiVersion": "v1",
"metadata": {
"name": "test-loop"
},
"labels": {
"application": "test-loop"
},
"objects": [
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "test-loop-is"
},
"spec": {
"dockerImageRepository": "test-loop",
"lookupPolicy": {
"local": true
},
"tags": [
{
"name": "latest"
}
]
}
},
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "test-loop-build"
},
"spec": {
"source": {
"type":"Dockerfile",
"dockerfile": "FROM centos:latest\nCMD while true ; do continue ; done"
},
"strategy": {
"type": "Docker",
"dockerStrategy": {
"from": {
"kind": "DockerImage",
"name": "centos:latest",
"forcePull": false
}
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "test-loop-is:latest"
}
},
"triggers": [
{
"type": "ConfigChange"
}
]
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name":"test-loop-dc"
},
"spec":{
"replicas": 1,
"selector": {
"deploymentConfig": "test-loop-dc"
},
"strategy":{
"type": "Recreate"
},
"template":{
"metadata": {
"labels": {
"deploymentConfig": "test-loop-dc"
},
"name": "test-loop"
},
"spec":{
"containers":[
{
"name": "test-loop",
"image": "test-loop-is:latest",
"imagePullPolicy": "Always"
}
]
}
}
},

"strategy": {
"type": "rolling"
}
}
]
}

0 comments on commit fbef515

Please sign in to comment.