This repository has been archived by the owner on Jul 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
scl.go
76 lines (63 loc) · 2.69 KB
/
scl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package images
import (
"fmt"
g "github.com/onsi/ginkgo"
o "github.com/onsi/gomega"
exutil "github.com/openshift/origin/test/extended/util"
kapi "k8s.io/kubernetes/pkg/api"
)
func getPodNameForTest(image string, t tc) string {
return fmt.Sprintf("%s-%s-%s", image, t.Version, t.BaseOS)
}
var _ = g.Describe("[images][Slow] openshift images should be SCL enabled", func() {
defer g.GinkgoRecover()
var oc = exutil.NewCLI("s2i-usage", exutil.KubeConfigPath())
g.JustBeforeEach(func() {
g.By("waiting for builder service account")
err := exutil.WaitForBuilderAccount(oc.KubeREST().ServiceAccounts(oc.Namespace()))
o.Expect(err).NotTo(o.HaveOccurred())
})
for image, tcs := range GetTestCaseForImages(AllImages) {
for _, t := range tcs {
g.Describe("returning s2i usage when running the image", func() {
g.It(fmt.Sprintf("%q should print the usage", t.DockerImageReference), func() {
g.By(fmt.Sprintf("creating a sample pod for %q", t.DockerImageReference))
pod := exutil.GetPodForContainer(kapi.Container{
Name: "test",
Image: t.DockerImageReference,
})
oc.KubeFramework().TestContainerOutput(getPodNameForTest(image, t), pod, 0, []string{"Sample invocation"})
})
})
g.Describe("using the SCL in s2i images", func() {
g.It(fmt.Sprintf("%q should be SCL enabled", t.DockerImageReference), func() {
g.By(fmt.Sprintf("creating a sample pod for %q with /bin/bash -c command", t.DockerImageReference))
pod := exutil.GetPodForContainer(kapi.Container{
Image: t.DockerImageReference,
Name: "test",
Command: []string{"/bin/bash", "-c", t.Cmd},
})
oc.KubeFramework().TestContainerOutput(getPodNameForTest(image, t), pod, 0, []string{t.Expected})
g.By(fmt.Sprintf("creating a sample pod for %q", t.DockerImageReference))
pod = exutil.GetPodForContainer(kapi.Container{
Image: t.DockerImageReference,
Name: "test",
Command: []string{"/usr/bin/sleep", "infinity"},
})
_, err := oc.KubeREST().Pods(oc.Namespace()).Create(pod)
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.KubeFramework().WaitForPodRunning(pod.Name)
o.Expect(err).NotTo(o.HaveOccurred())
g.By("calling the binary using 'oc exec /bin/bash -c'")
out, err := oc.Run("exec").Args("-p", pod.Name, "--", "/bin/bash", "-c", t.Cmd).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(out).Should(o.ContainSubstring(t.Expected))
g.By("calling the binary using 'oc exec /bin/sh -ic'")
out, err = oc.Run("exec").Args("-p", pod.Name, "--", "/bin/sh", "-ic", t.Cmd).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(out).Should(o.ContainSubstring(t.Expected))
})
})
}
}
})