Skip to content

Commit c5810fd

Browse files
committed
[sig-cli] oc: Migrate DCs to Deployments and remove [apigroup:apps.openshift.io] API dependency
1 parent 5cea7d1 commit c5810fd

13 files changed

+1001
-404
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: 33 additions & 11 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"
@@ -30,40 +33,57 @@ var _ = g.Describe("[sig-cli] oc debug", func() {
3033
helloPod := exutil.FixturePath("..", "..", "examples", "hello-openshift", "hello-pod.json")
3134
imageStreamsCentos := exutil.FixturePath("..", "..", "examples", "image-streams", "image-streams-centos7.json")
3235

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

4969
g.By("should print the imagestream-based container entrypoint/command")
5070
var out string
51-
out, err = oc.Run("debug").Args("dc/local-busybox1").Output()
71+
out, err = oc.Run("debug").Args("deployment/local-busybox1").Output()
5272
o.Expect(err).NotTo(o.HaveOccurred())
53-
o.Expect(out).To(o.MatchRegexp("Starting pod/local-busybox1-debug.*, command was: /usr/bin/bash\n"))
73+
o.Expect(out).To(o.MatchRegexp("Starting pod/local-busybox1-debug.* ...\n"))
5474

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

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

6585
g.By("should print the overridden container image-based container entrypoint/command")
66-
out, err = oc.Run("debug").Args("dc/busybox2").Output()
86+
out, err = oc.Run("debug").Args("deployment/busybox2").Output()
6787
o.Expect(err).NotTo(o.HaveOccurred())
6888
o.Expect(out).To(o.MatchRegexp("Starting pod/busybox2-debug.*, command was: foo bar baz qux\n"))
6989
})
@@ -196,8 +216,10 @@ var _ = g.Describe("[sig-cli] oc debug", func() {
196216
out, err = oc.Run("debug").Args("--request-timeout=10s", "-c", "ruby-helloworld", "--one-container", "dc/test-deployment-config", "-o", "jsonpath='{.metadata.name}").Output()
197217
o.Expect(err).NotTo(o.HaveOccurred())
198218
o.Expect(out).To(o.ContainSubstring("test-deployment-config"))
219+
})
199220

200-
err = oc.Run("create").Args("-f", "-").InputString(`
221+
g.It("ensure debug does not depend on a container actually existing for the selected resource for deployment", func() {
222+
err := oc.Run("create").Args("-f", "-").InputString(`
201223
apiVersion: apps/v1
202224
kind: Deployment
203225
metadata:
@@ -222,7 +244,7 @@ spec:
222244
`).Execute()
223245
o.Expect(err).NotTo(o.HaveOccurred())
224246

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

test/extended/cli/status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ var _ = g.Describe("[sig-cli] oc status", func() {
1919

2020
var oc = exutil.NewCLI("oc-status")
2121

22-
g.It("returns expected help messages [apigroup:project.openshift.io][apigroup:build.openshift.io][apigroup:image.openshift.io][apigroup:apps.openshift.io][apigroup:route.openshift.io]", func() {
22+
g.It("returns expected help messages [apigroup:project.openshift.io][apigroup:build.openshift.io][apigroup:image.openshift.io][apigroup:route.openshift.io]", func() {
2323
out, err := oc.Run("status").Args("-h").Output()
2424
o.Expect(err).NotTo(o.HaveOccurred())
2525
o.Expect(out).To(o.ContainSubstring("oc describe buildconfig"))
2626

27-
out, err = oc.Run("status").Output()
27+
out, err = oc.Run("status").Args("--suggest").Output()
2828
o.Expect(err).NotTo(o.HaveOccurred())
2929
o.Expect(out).To(o.ContainSubstring("oc new-app"))
3030
})

test/extended/cli/template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var _ = g.Describe("[sig-cli] templates", func() {
3333
multilinePath = filepath.Join(testDataPath, "templates", "multiline.txt")
3434
)
3535

36-
g.It("process [apigroup:apps.openshift.io][apigroup:template.openshift.io][Skipped:Disconnected]", func() {
36+
g.It("process [apigroup:template.openshift.io][Skipped:Disconnected]", func() {
3737
err := oc.Run("get").Args("templates").Execute()
3838
o.Expect(err).NotTo(o.HaveOccurred())
3939
err = oc.Run("create").Args("-f", appTemplatePath).Execute()

0 commit comments

Comments
 (0)