Skip to content

Commit

Permalink
add tests; ensure debug 0 replica dc/rc/deploy does not hang
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Sep 25, 2017
1 parent dca2dc3 commit 7588e37
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/cmd/debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,45 @@ os::cmd::expect_success_and_not_text "oc debug -f examples/hello-openshift/hello
os::cmd::expect_success_and_not_text "oc debug -f examples/hello-openshift/hello-pod.json -o yaml -- /bin/env" 'tty'
# TODO: write a test that emulates a TTY to verify the correct defaulting of what the pod is created

# Ensure debug does not depend on a container actually existing for the selected resource.
# The command should not hang waiting for an attachable pod. Timeout each cmd after 5s.
os::cmd::expect_success 'oc create -f test/integration/testdata/test-replication-controller.yaml'
os::cmd::expect_success 'oc scale --replicas=0 rc/test-replication-controller'
os::cmd::expect_success_and_text "oc debug -c ruby-helloworld --one-container rc/test-replication-controller -o jsonpath='{.metadata.name}'" 'test-replication-controller-debug'

os::cmd::expect_success 'oc scale --replicas=0 dc/test-deployment-config'
os::cmd::expect_success_and_text "oc debug -c ruby-helloworld --one-container dc/test-deployment-config -o jsonpath='{.metadata.name}'" 'test-deployment-config'

os::cmd::expect_success 'oc create -f - >> cat << __EOF__
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test-deployment
labels:
deployment: test-deployment
spec:
replicas: 0
selector:
matchLabels:
deployment: test-deployment
template:
metadata:
labels:
deployment: test-deployment
name: test-deployment
spec:
containers:
- name: ruby-helloworld
image: openshift/origin-pod
imagePullPolicy: IfNotPresent
resources: {}
status: {}
__EOF__'
os::cmd::expect_success_and_text "oc debug -c ruby-helloworld --one-container deploy/test-deployment -o jsonpath='{.metadata.name}'" 'test-deployment-debug'

# re-scale existing resources
os::cmd::expect_success 'oc scale --replicas=1 dc/test-deployment-config'

os::cmd::expect_success 'oc create -f examples/image-streams/image-streams-centos7.json'
os::cmd::try_until_success 'oc get imagestreamtags wildfly:latest'
os::cmd::expect_success_and_text "oc debug istag/wildfly:latest -o yaml" 'image: openshift/wildfly-101-centos7'
Expand Down
31 changes: 31 additions & 0 deletions test/integration/testdata/test-replication-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v1
kind: ReplicationController
metadata:
annotations:
openshift.io/deployment-config.latest-version: "1"
openshift.io/deployment-config.name: test-deployment
openshift.io/deployment.phase: Complete
optnshift.io/deployment.replicas: "1"
name: test-replication-controller
spec:
replicas: 1
selector:
deployment: test-deployment
deploymentconfig: test-deployment
template:
metadata:
labels:
deployment: test-deployment
deploymentconfig: test-deployment
spec:
containers:
- image: openshift/origin-pod
imagePullPolicy: IfNotPresent
name: ruby-helloworld
ports:
- containerPort: 8080
protocol: TCP
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}

0 comments on commit 7588e37

Please sign in to comment.