Skip to content

Commit c547f05

Browse files
committed
add tests; ensure debug 0 replica dc/rc/deploy does not hang
1 parent dca2dc3 commit c547f05

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

test/cmd/debug.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,45 @@ os::cmd::expect_success_and_not_text "oc debug -f examples/hello-openshift/hello
3333
os::cmd::expect_success_and_not_text "oc debug -f examples/hello-openshift/hello-pod.json -o yaml -- /bin/env" 'tty'
3434
# TODO: write a test that emulates a TTY to verify the correct defaulting of what the pod is created
3535

36+
# Ensure debug does not depend on a container actually existing for the selected resource.
37+
# The command should not hang waiting for an attachable pod. Timeout each cmd after 10s.
38+
os::cmd::expect_success 'oc create -f test/integration/testdata/test-replication-controller.yaml'
39+
os::cmd::expect_success 'oc scale --replicas=0 rc/test-replication-controller'
40+
os::cmd::expect_success_and_text "oc debug --request-timeout=10s -c ruby-helloworld --one-container rc/test-replication-controller -o jsonpath='{.metadata.name}'" 'test-replication-controller-debug'
41+
42+
os::cmd::expect_success 'oc scale --replicas=0 dc/test-deployment-config'
43+
os::cmd::expect_success_and_text "oc debug --request-timeout=10s -c ruby-helloworld --one-container dc/test-deployment-config -o jsonpath='{.metadata.name}'" 'test-deployment-config'
44+
45+
os::cmd::expect_success 'oc create -f - >> cat << __EOF__
46+
apiVersion: extensions/v1beta1
47+
kind: Deployment
48+
metadata:
49+
name: test-deployment
50+
labels:
51+
deployment: test-deployment
52+
spec:
53+
replicas: 0
54+
selector:
55+
matchLabels:
56+
deployment: test-deployment
57+
template:
58+
metadata:
59+
labels:
60+
deployment: test-deployment
61+
name: test-deployment
62+
spec:
63+
containers:
64+
- name: ruby-helloworld
65+
image: openshift/origin-pod
66+
imagePullPolicy: IfNotPresent
67+
resources: {}
68+
status: {}
69+
__EOF__'
70+
os::cmd::expect_success_and_text "oc debug --request-timeout=10s -c ruby-helloworld --one-container deploy/test-deployment -o jsonpath='{.metadata.name}'" 'test-deployment-debug'
71+
72+
# re-scale existing resources
73+
os::cmd::expect_success 'oc scale --replicas=1 dc/test-deployment-config'
74+
3675
os::cmd::expect_success 'oc create -f examples/image-streams/image-streams-centos7.json'
3776
os::cmd::try_until_success 'oc get imagestreamtags wildfly:latest'
3877
os::cmd::expect_success_and_text "oc debug istag/wildfly:latest -o yaml" 'image: openshift/wildfly-101-centos7'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: v1
2+
kind: ReplicationController
3+
metadata:
4+
annotations:
5+
openshift.io/deployment-config.latest-version: "1"
6+
openshift.io/deployment-config.name: test-deployment
7+
openshift.io/deployment.phase: Complete
8+
optnshift.io/deployment.replicas: "1"
9+
name: test-replication-controller
10+
spec:
11+
replicas: 1
12+
selector:
13+
deployment: test-deployment
14+
deploymentconfig: test-deployment
15+
template:
16+
metadata:
17+
labels:
18+
deployment: test-deployment
19+
deploymentconfig: test-deployment
20+
spec:
21+
containers:
22+
- image: openshift/origin-pod
23+
imagePullPolicy: IfNotPresent
24+
name: ruby-helloworld
25+
ports:
26+
- containerPort: 8080
27+
protocol: TCP
28+
resources: {}
29+
dnsPolicy: ClusterFirst
30+
restartPolicy: Always
31+
status: {}

0 commit comments

Comments
 (0)