Skip to content

Commit c981735

Browse files
committed
[sig-cli] oc ...
1 parent e5d212a commit c981735

18 files changed

+555
-560
lines changed

examples/sample-app/application-template-stibuild.json

Lines changed: 14 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -164,75 +164,24 @@
164164
}
165165
},
166166
{
167-
"kind": "DeploymentConfig",
168-
"apiVersion": "apps.openshift.io/v1",
167+
"kind": "Deployment",
168+
"apiVersion": "apps/v1",
169169
"metadata": {
170170
"name": "frontend",
171171
"annotations": {
172-
"template.alpha.openshift.io/wait-for-ready": "true"
172+
"template.alpha.openshift.io/wait-for-ready": "true",
173+
"image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"origin-ruby-sample:latest\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
173174
}
174175
},
175176
"spec": {
176177
"strategy": {
177-
"type": "Rolling",
178-
"rollingParams": {
179-
"updatePeriodSeconds": 1,
180-
"intervalSeconds": 1,
181-
"timeoutSeconds": 120,
182-
"pre": {
183-
"failurePolicy": "Abort",
184-
"execNewPod": {
185-
"command": [
186-
"/bin/true"
187-
],
188-
"env": [
189-
{
190-
"name": "CUSTOM_VAR1",
191-
"value": "custom_value1"
192-
}
193-
],
194-
"containerName": "ruby-helloworld"
195-
}
196-
},
197-
"post": {
198-
"failurePolicy": "Ignore",
199-
"execNewPod": {
200-
"command": [
201-
"/bin/true"
202-
],
203-
"env": [
204-
{
205-
"name": "CUSTOM_VAR2",
206-
"value": "custom_value2"
207-
}
208-
],
209-
"containerName": "ruby-helloworld"
210-
}
211-
}
212-
},
213-
"resources": {}
178+
"type": "RollingUpdate"
214179
},
215-
"triggers": [
216-
{
217-
"type": "ImageChange",
218-
"imageChangeParams": {
219-
"automatic": true,
220-
"containerNames": [
221-
"ruby-helloworld"
222-
],
223-
"from": {
224-
"kind": "ImageStreamTag",
225-
"name": "origin-ruby-sample:latest"
226-
}
227-
}
228-
},
229-
{
230-
"type": "ConfigChange"
231-
}
232-
],
233180
"replicas": 2,
234181
"selector": {
235-
"name": "frontend"
182+
"matchLabels": {
183+
"name": "frontend"
184+
}
236185
},
237186
"template": {
238187
"metadata": {
@@ -317,8 +266,8 @@
317266
}
318267
},
319268
{
320-
"kind": "DeploymentConfig",
321-
"apiVersion": "apps.openshift.io/v1",
269+
"kind": "Deployment",
270+
"apiVersion": "apps/v1",
322271
"metadata": {
323272
"name": "database",
324273
"annotations": {
@@ -327,67 +276,13 @@
327276
},
328277
"spec": {
329278
"strategy": {
330-
"type": "Recreate",
331-
"recreateParams": {
332-
"pre": {
333-
"failurePolicy": "Abort",
334-
"execNewPod": {
335-
"command": [
336-
"/bin/true"
337-
],
338-
"env": [
339-
{
340-
"name": "CUSTOM_VAR1",
341-
"value": "custom_value1"
342-
}
343-
],
344-
"containerName": "ruby-helloworld-database",
345-
"volumes": ["ruby-helloworld-data"]
346-
}
347-
},
348-
"mid": {
349-
"failurePolicy": "Abort",
350-
"execNewPod": {
351-
"command": [
352-
"/bin/true"
353-
],
354-
"env": [
355-
{
356-
"name": "CUSTOM_VAR2",
357-
"value": "custom_value2"
358-
}
359-
],
360-
"containerName": "ruby-helloworld-database",
361-
"volumes": ["ruby-helloworld-data"]
362-
}
363-
},
364-
"post": {
365-
"failurePolicy": "Ignore",
366-
"execNewPod": {
367-
"command": [
368-
"/bin/true"
369-
],
370-
"env": [
371-
{
372-
"name": "CUSTOM_VAR2",
373-
"value": "custom_value2"
374-
}
375-
],
376-
"containerName": "ruby-helloworld-database",
377-
"volumes": ["ruby-helloworld-data"]
378-
}
379-
}
380-
},
381-
"resources": {}
279+
"type": "Recreate"
382280
},
383-
"triggers": [
384-
{
385-
"type": "ConfigChange"
386-
}
387-
],
388281
"replicas": 1,
389282
"selector": {
390-
"name": "database"
283+
"matchLabels": {
284+
"name": "database"
285+
}
391286
},
392287
"template": {
393288
"metadata": {

test/extended/cli/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ var _ = g.Describe("[sig-cli] oc adm", func() {
443443
o.Expect(out).To(o.ContainSubstring("createuser2"))
444444
})
445445

446-
g.It("build-chain [apigroup:build.openshift.io][apigroup:image.openshift.io][apigroup:project.openshift.io][apigroup:apps.openshift.io]", func() {
446+
g.It("build-chain [apigroup:build.openshift.io][apigroup:image.openshift.io][apigroup:project.openshift.io]", func() {
447447
// Test building a dependency tree
448448
s2iBuildPath := exutil.FixturePath("..", "..", "examples", "sample-app", "application-template-stibuild.json")
449449
out, _, err := ocns.Run("process").Args("-f", s2iBuildPath, "-l", "build=sti").Outputs()

test/extended/cli/builds.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ var _ = g.Describe("[sig-cli] oc builds", func() {
226226
o.Expect(err).NotTo(o.HaveOccurred())
227227
})
228228

229-
g.It("webhooks CRUD [apigroup:build.openshift.io][apigroup:apps.openshift.io]", func() {
229+
g.It("webhooks CRUD [apigroup:build.openshift.io]", func() {
230230
g.By("check bc webhooks")
231231
out, err := oc.Run("describe").Args("buildConfigs", "ruby-sample-build").Output()
232232
o.Expect(err).NotTo(o.HaveOccurred())
@@ -284,7 +284,7 @@ var _ = g.Describe("[sig-cli] oc builds", func() {
284284
))
285285
})
286286

287-
g.It("start-build [apigroup:build.openshift.io][apigroup:apps.openshift.io]", func() {
287+
g.It("start-build [apigroup:build.openshift.io]", func() {
288288
g.By("valid build")
289289
out, err := oc.Run("start-build").Args("--from-webhook", getTriggerURL("secret101", "generic")).Output()
290290
o.Expect(err).NotTo(o.HaveOccurred())

test/extended/cli/debug.go

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package cli
22

33
import (
4+
"context"
45
"fmt"
56
"time"
67

78
g "github.com/onsi/ginkgo/v2"
89
o "github.com/onsi/gomega"
910

11+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1012
"k8s.io/apimachinery/pkg/util/wait"
13+
"k8s.io/klog/v2"
1114
admissionapi "k8s.io/pod-security-admission/api"
1215

1316
configv1 "github.com/openshift/api/config/v1"
@@ -29,85 +32,102 @@ var _ = g.Describe("[sig-cli] oc debug", func() {
2932
helloPod := exutil.FixturePath("..", "..", "examples", "hello-openshift", "hello-pod.json")
3033
imageStreamsCentos := exutil.FixturePath("..", "..", "examples", "image-streams", "image-streams-centos7.json")
3134

32-
g.It("deployment configs from a build [apigroup:image.openshift.io][apigroup:apps.openshift.io]", func() {
33-
err := oc.Run("create").Args("-f", testCLIDebug).Execute()
35+
g.It("deployment from a build [apigroup:image.openshift.io]", func() {
36+
projectName, err := oc.Run("project").Args("-q").Output()
37+
o.Expect(err).NotTo(o.HaveOccurred())
38+
39+
err = oc.Run("create").Args("-f", testCLIDebug).Execute()
3440
o.Expect(err).NotTo(o.HaveOccurred())
3541
// wait for image stream to be present which means the build has completed
3642
err = wait.Poll(cliInterval, buildTimeout, func() (bool, error) {
3743
err := oc.Run("get").Args("imagestreamtags", "local-busybox:latest").Execute()
3844
return err == nil, nil
3945
})
4046
o.Expect(err).NotTo(o.HaveOccurred())
41-
// and for replication controller which means we can kick of debug session
47+
48+
// and for replicaset which means we can kick of debug session
49+
var rsName string
4250
err = wait.Poll(cliInterval, deployTimeout, func() (bool, error) {
43-
err := oc.Run("get").Args("replicationcontrollers", "local-busybox1-1").Execute()
51+
rsList, err := oc.AdminKubeClient().AppsV1().ReplicaSets(projectName).List(context.TODO(), metav1.ListOptions{LabelSelector: "deployment=local-busybox1"})
52+
o.Expect(err).NotTo(o.HaveOccurred())
53+
for _, item := range rsList.Items {
54+
if item.Annotations["deployment.kubernetes.io/revision"] == "2" {
55+
rsName = rsList.Items[0].Name
56+
}
57+
}
58+
if rsName == "" {
59+
klog.Infof("Waiting for a replicaset with deployment.kubernetes.io/revision=2")
60+
return false, nil
61+
}
62+
rsName = rsList.Items[0].Name
63+
err = oc.Run("get").Args("replicasets", rsName).Execute()
4464
return err == nil, nil
4565
})
4666
o.Expect(err).NotTo(o.HaveOccurred())
4767

4868
g.By("should print the imagestream-based container entrypoint/command")
4969
var out string
50-
out, err = oc.Run("debug").Args("dc/local-busybox1").Output()
70+
out, err = oc.Run("debug").Args("deployment/local-busybox1").Output()
5171
o.Expect(err).NotTo(o.HaveOccurred())
52-
o.Expect(out).To(o.MatchRegexp("Starting pod/local-busybox1-debug.*, command was: /usr/bin/bash\n"))
72+
o.Expect(out).To(o.MatchRegexp("Starting pod/local-busybox1-debug.* ...\n"))
5373

5474
g.By("should print the overridden imagestream-based container entrypoint/command")
55-
out, err = oc.Run("debug").Args("dc/local-busybox2").Output()
75+
out, err = oc.Run("debug").Args("deployment/local-busybox2").Output()
5676
o.Expect(err).NotTo(o.HaveOccurred())
5777
o.Expect(out).To(o.MatchRegexp("Starting pod/local-busybox2-debug.*, command was: foo bar baz qux\n"))
5878

5979
g.By("should print the container image-based container entrypoint/command")
60-
out, err = oc.Run("debug").Args("dc/busybox1").Output()
80+
out, err = oc.Run("debug").Args("deployment/busybox1").Output()
6181
o.Expect(err).NotTo(o.HaveOccurred())
6282
o.Expect(out).To(o.MatchRegexp("Starting pod/busybox1-debug.* ...\n"))
6383

6484
g.By("should print the overridden container image-based container entrypoint/command")
65-
out, err = oc.Run("debug").Args("dc/busybox2").Output()
85+
out, err = oc.Run("debug").Args("deployment/busybox2").Output()
6686
o.Expect(err).NotTo(o.HaveOccurred())
6787
o.Expect(out).To(o.MatchRegexp("Starting pod/busybox2-debug.*, command was: foo bar baz qux\n"))
6888
})
6989

70-
g.It("dissect deployment config debug [apigroup:apps.openshift.io]", func() {
90+
g.It("dissect deployment debug", func() {
7191
err := oc.Run("create").Args("-f", testDeploymentConfig).Execute()
7292
o.Expect(err).NotTo(o.HaveOccurred())
7393

7494
var out string
75-
out, err = oc.Run("debug").Args("dc/test-deployment-config", "-oyaml").Output()
95+
out, err = oc.Run("debug").Args("deployment/test-deployment", "-oyaml").Output()
7696
o.Expect(err).NotTo(o.HaveOccurred())
7797
o.Expect(out).To(o.ContainSubstring("- /bin/sh"))
7898

79-
out, err = oc.Run("debug").Args("dc/test-deployment-config", "--keep-annotations", "-oyaml").Output()
99+
out, err = oc.Run("debug").Args("deployment/test-deployment", "--keep-annotations", "-oyaml").Output()
80100
o.Expect(err).NotTo(o.HaveOccurred())
81101
o.Expect(out).To(o.ContainSubstring("annotations:"))
82102

83-
out, err = oc.Run("debug").Args("dc/test-deployment-config", "--as-root", "-oyaml").Output()
103+
out, err = oc.Run("debug").Args("deployment/test-deployment", "--as-root", "-oyaml").Output()
84104
o.Expect(err).NotTo(o.HaveOccurred())
85105
o.Expect(out).To(o.ContainSubstring("runAsUser: 0"))
86106

87-
out, err = oc.Run("debug").Args("dc/test-deployment-config", "--as-root=false", "-oyaml").Output()
107+
out, err = oc.Run("debug").Args("deployment/test-deployment", "--as-root=false", "-oyaml").Output()
88108
o.Expect(err).NotTo(o.HaveOccurred())
89109
o.Expect(out).To(o.ContainSubstring("runAsNonRoot: true"))
90110

91-
out, err = oc.Run("debug").Args("dc/test-deployment-config", "--as-user=1", "-oyaml").Output()
111+
out, err = oc.Run("debug").Args("deployment/test-deployment", "--as-user=1", "-oyaml").Output()
92112
o.Expect(err).NotTo(o.HaveOccurred())
93113
o.Expect(out).To(o.ContainSubstring("runAsUser: 1"))
94114

95-
out, err = oc.Run("debug").Args("dc/test-deployment-config", "-t", "-oyaml").Output()
115+
out, err = oc.Run("debug").Args("deployment/test-deployment", "-t", "-oyaml").Output()
96116
o.Expect(err).NotTo(o.HaveOccurred())
97117
o.Expect(out).To(o.ContainSubstring("stdinOnce"))
98118
o.Expect(out).To(o.ContainSubstring("tty"))
99119

100-
out, err = oc.Run("debug").Args("dc/test-deployment-config", "--tty=false", "-oyaml").Output()
120+
out, err = oc.Run("debug").Args("deployment/test-deployment", "--tty=false", "-oyaml").Output()
101121
o.Expect(err).NotTo(o.HaveOccurred())
102122
o.Expect(out).NotTo(o.ContainSubstring("tty"))
103123

104-
out, err = oc.Run("debug").Args("dc/test-deployment-config", "-oyaml", "--", "/bin/env").Output()
124+
out, err = oc.Run("debug").Args("deployment/test-deployment", "-oyaml", "--", "/bin/env").Output()
105125
o.Expect(err).NotTo(o.HaveOccurred())
106126
o.Expect(out).To(o.ContainSubstring("- /bin/env"))
107127
o.Expect(out).NotTo(o.ContainSubstring("stdin"))
108128
o.Expect(out).NotTo(o.ContainSubstring("tty"))
109129

110-
out, err = oc.Run("debug").Args("dc/test-deployment-config", "--node-name=invalid", "--", "/bin/env").Output()
130+
out, err = oc.Run("debug").Args("deployment/test-deployment", "--node-name=invalid", "--", "/bin/env").Output()
111131
o.Expect(err).To(o.HaveOccurred())
112132
o.Expect(out).To(o.ContainSubstring(`on node "invalid"`))
113133
})
@@ -150,8 +170,10 @@ var _ = g.Describe("[sig-cli] oc debug", func() {
150170
out, err = oc.Run("debug").Args("--request-timeout=10s", "-c", "ruby-helloworld", "--one-container", "dc/test-deployment-config", "-o", "jsonpath='{.metadata.name}").Output()
151171
o.Expect(err).NotTo(o.HaveOccurred())
152172
o.Expect(out).To(o.ContainSubstring("test-deployment-config"))
173+
})
153174

154-
err = oc.Run("create").Args("-f", "-").InputString(`
175+
g.It("ensure debug does not depend on a container actually existing for the selected resource for deployment", func() {
176+
err := oc.Run("create").Args("-f", "-").InputString(`
155177
apiVersion: apps/v1
156178
kind: Deployment
157179
metadata:
@@ -176,7 +198,7 @@ spec:
176198
`).Execute()
177199
o.Expect(err).NotTo(o.HaveOccurred())
178200

179-
out, err = oc.Run("debug").Args("--request-timeout=10s", "-c", "ruby-helloworld", "--one-container", "deploy/test-deployment", "-o", "jsonpath='{.metadata.name}").Output()
201+
out, err := oc.Run("debug").Args("--request-timeout=10s", "-c", "ruby-helloworld", "--one-container", "deploy/test-deployment", "-o", "jsonpath='{.metadata.name}").Output()
180202
o.Expect(err).NotTo(o.HaveOccurred())
181203
o.Expect(out).To(o.ContainSubstring("test-deployment-debug"))
182204
})

0 commit comments

Comments
 (0)