/
kube_run_test.go
89 lines (84 loc) · 2.52 KB
/
kube_run_test.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
77
78
79
80
81
82
83
84
85
86
87
88
89
package e2e_kube_run_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
"github.com/werf/werf/test/pkg/werf"
)
var _ = Describe("kube-run", func() {
DescribeTable("should succeed/fail and produce expected output",
func(kubeRunOpts *werf.KubeRunOptions, outputExpectationsFunc func(out string)) {
repoDirname := "repo0"
fixtureRelPath := "state0"
By("preparing test repo")
SuiteData.InitTestRepo(repoDirname, fixtureRelPath)
werfProject := werf.NewProject(SuiteData.WerfBinPath, SuiteData.GetTestRepoPath(repoDirname))
By("execute kube-run")
combinedOut := werfProject.KubeRun(kubeRunOpts)
outputExpectationsFunc(combinedOut)
},
Entry(
"show output and succeed, running non-interactively",
&werf.KubeRunOptions{
Command: []string{"sh", "-c", "cat /etc/os-release"},
Image: "main",
},
func(out string) {
Expect(out).To(ContainSubstring("ID=alpine"))
},
),
Entry(
"show output and succeed, running interactively with TTY",
&werf.KubeRunOptions{
Command: []string{"sh", "-c", "cat /etc/os-release"},
Image: "main",
CommonOptions: werf.CommonOptions{
ExtraArgs: []string{"-i", "-t"},
},
},
func(out string) {
Expect(out).To(ContainSubstring("ID=alpine"))
},
),
Entry(
"show output and fail, running non-interactively",
&werf.KubeRunOptions{
Command: []string{"sh", "-c", "cat /etc/os-release; exit 1"},
Image: "main",
CommonOptions: werf.CommonOptions{
ShouldFail: true,
},
},
func(out string) {
Expect(out).To(ContainSubstring("ID=alpine"))
},
),
Entry(
"show output and fail, running interactively with TTY",
&werf.KubeRunOptions{
Command: []string{"sh", "-c", "cat /etc/os-release; exit 1"},
Image: "main",
CommonOptions: werf.CommonOptions{
ShouldFail: true,
ExtraArgs: []string{"-i", "-t"},
},
},
func(out string) {
Expect(out).To(ContainSubstring("ID=alpine"))
},
),
Entry(
"produce expected --overrides flag, running in dry-run mode",
&werf.KubeRunOptions{
Command: []string{"hostname"},
Image: "main",
CommonOptions: werf.CommonOptions{
ExtraArgs: []string{"--dry-run", "--pod=testpod", "--overrides", `{"spec": {"imagePullSecrets": [{"name": "testsecret"}], "nodeName": "testnode"}}`},
},
},
func(out string) {
Expect(out).To(ContainSubstring(`{"spec":{"imagePullSecrets":[{"name":"testsecret"},{"name":"testpod"}],"nodeName":"testnode"}}`))
},
),
)
})