Skip to content

Commit 1fdda50

Browse files
committed
Test Apply commands on Kubernetes/Images
1 parent a069261 commit 1fdda50

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

tests/examples/source/devfiles/nodejs/devfile-for-run.yaml

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
schemaVersion: 2.0.0
1+
schemaVersion: 2.2.0
22
metadata:
33
name: nodejs
44
projectType: nodejs
@@ -17,6 +17,20 @@ components:
1717
- name: "3000-tcp"
1818
targetPort: 3000
1919
mountSources: true
20+
- name: config
21+
kubernetes:
22+
inlined: |
23+
apiVersion: v1
24+
kind: ConfigMap
25+
metadata:
26+
name: my-config
27+
- name: image
28+
image:
29+
imageName: my-image
30+
dockerfile:
31+
uri: ./Dockerfile
32+
buildContext: ${PROJECTS_ROOT}
33+
rootRequired: false
2034
commands:
2135
- id: devbuild
2236
exec:
@@ -53,3 +67,9 @@ commands:
5367
component: runtime
5468
commandLine: touch /tmp/new-file
5569
workingDir: ${PROJECTS_ROOT}
70+
- id: deploy-config
71+
apply:
72+
component: config
73+
- id: build-image
74+
apply:
75+
component: image

tests/integration/cmd_run_test.go

+25-5
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,35 @@ var _ = Describe("odo run command tests", func() {
8989
devSession.WaitEnd()
9090
})
9191

92-
It("should execute a command", func() {
92+
It("should execute commands", func() {
9393
platform := "cluster"
9494
if podman {
9595
platform = "podman"
9696
}
97-
output := helper.Cmd("odo", "run", "create-file", "--platform", platform).ShouldPass().Out()
98-
Expect(output).To(ContainSubstring("Executing command in container (command: create-file)"))
99-
component := helper.NewComponent(cmpName, "app", labels.ComponentDevMode, commonVar.Project, commonVar.CliRunner)
100-
component.Exec("runtime", []string{"ls", "/tmp/new-file"}, pointer.Bool(true))
97+
98+
By("executing an exec command", func() {
99+
output := helper.Cmd("odo", "run", "create-file", "--platform", platform).ShouldPass().Out()
100+
Expect(output).To(ContainSubstring("Executing command in container (command: create-file)"))
101+
component := helper.NewComponent(cmpName, "app", labels.ComponentDevMode, commonVar.Project, commonVar.CliRunner)
102+
component.Exec("runtime", []string{"ls", "/tmp/new-file"}, pointer.Bool(true))
103+
})
104+
105+
if !podman {
106+
By("executing apply command on Kubernetes component", func() {
107+
output := helper.Cmd("odo", "run", "deploy-config", "--platform", platform).ShouldPass().Out()
108+
Expect(output).To(ContainSubstring("Creating resource ConfigMap/my-config"))
109+
out := commonVar.CliRunner.Run("get", "configmap", "my-config", "-n",
110+
commonVar.Project).Wait().Out.Contents()
111+
Expect(out).To(ContainSubstring("my-config"))
112+
})
113+
}
114+
115+
By("executing apply command on Image component", func() {
116+
// Will fail because Dockerfile is not present, but we just want to check the build is started
117+
// We cannot use PODMAN_CMD=echo with --platform=podman
118+
output := helper.Cmd("odo", "run", "build-image", "--platform", platform).ShouldFail().Out()
119+
Expect(output).To(ContainSubstring("Building image locally"))
120+
})
101121
})
102122
}))
103123
}

0 commit comments

Comments
 (0)