-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathinstall_test.go
More file actions
180 lines (153 loc) · 4.67 KB
/
Copy pathinstall_test.go
File metadata and controls
180 lines (153 loc) · 4.67 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package deeptest
import (
"fmt"
"os"
"testing"
"time"
"github.com/linkerd/linkerd2/testutil"
)
//////////////////////
/// TEST SETUP ///
//////////////////////
var (
TestHelper *testutil.TestHelper
)
func TestMain(m *testing.M) {
TestHelper = testutil.NewTestHelper()
os.Exit(m.Run())
}
func TestInstallCalico(t *testing.T) {
if !TestHelper.CNI() {
return
}
// install Calico as per instructions on
// https://k3d.io/v5.8.3/usage/advanced/calico/#1-create-the-cluster-without-flannel
// there's a lot of waiting involved here as the various components come up, so the easiest
// is to retry the steps until they succeed
var out string
err := testutil.RetryFor(time.Minute, func() error {
var err error
out, err = TestHelper.Kubectl("", []string{"apply", "-f", "https://raw.githubusercontent.com/projectcalico/calico/v3.31.0/manifests/tigera-operator.yaml"}...)
if err != nil {
return err
}
deploys := map[string]testutil.DeploySpec{
"tigera-operator": {
Namespace: "tigera-operator",
Replicas: 1,
},
}
TestHelper.WaitRollout(t, deploys)
out, err = TestHelper.Kubectl("", []string{"apply", "-f", "https://raw.githubusercontent.com/projectcalico/calico/v3.31.0/manifests/custom-resources.yaml"}...)
if err != nil {
return err
}
for _, system := range []string{"apiserver", "calico", "goldmane", "ippools", "whisker"} {
out, err = TestHelper.Kubectl("", "wait", "--for=condition=available", "--timeout=120s", "tigerastatus", system)
if err != nil {
return err
}
}
return nil
})
if err != nil {
testutil.AnnotatedFatalf(t, "failed to install calico", "failed to install calico: %s: %s", err, out)
}
}
func TestInstallCNIPlugin(t *testing.T) {
if !TestHelper.CNI() {
return
}
// install the CNI plugin in the cluster
var (
cmd = "install-cni"
args = []string{
"--use-wait-flag",
"--cni-log-level=debug",
// For Flannel (k3d's default CNI) the following settings are required.
// For Calico the default ones are fine.
// "--dest-cni-net-dir=/var/lib/rancher/k3s/agent/etc/cni/net.d",
// "--dest-cni-bin-dir=/bin",
}
)
exec := append([]string{cmd}, args...)
out, err := TestHelper.LinkerdRun(exec...)
if err != nil {
testutil.AnnotatedFatal(t, "'linkerd install-cni' command failed", err)
}
out, err = TestHelper.KubectlApply(out, "")
if err != nil {
testutil.AnnotatedFatalf(t, "'kubectl apply' command failed",
"'kubectl apply' command failed\n%s", out)
}
// perform a linkerd check with --linkerd-cni-enabled
timeout := time.Minute
err = testutil.RetryFor(timeout, func() error {
out, err = TestHelper.LinkerdRun("check", "--pre", "--linkerd-cni-enabled", "--wait=5m")
if err != nil {
return err
}
return nil
})
if err != nil {
testutil.AnnotatedFatal(t, fmt.Sprintf("'linkerd check' command timed-out (%s)", timeout), err)
}
}
// TestInstall will install the linkerd control plane to be used in the rest of
// the deep suite tests.
func TestInstall(t *testing.T) {
err := TestHelper.InstallGatewayAPI()
if err != nil {
testutil.AnnotatedFatal(t, "failed to install gateway-api", err)
}
// Install CRDs
cmd := []string{
"install",
"--crds",
"--controller-log-level", "debug",
"--set", fmt.Sprintf("proxy.image.version=%s", TestHelper.GetVersion()),
"--set", "heartbeatSchedule=1 2 3 4 5",
}
// Pipe cmd & args to `linkerd`
out, err := TestHelper.LinkerdRun(cmd...)
if err != nil {
testutil.AnnotatedFatal(t, "'linkerd install' command failed", err)
}
out, err = TestHelper.KubectlApplyWithArgs(out)
if err != nil {
testutil.AnnotatedFatalf(t, "'kubectl apply' command failed",
"'kubectl apply' command failed\n%s", out)
}
// Install control-plane
cmd = []string{
"install",
"--controller-log-level", "debug",
"--set", fmt.Sprintf("proxy.image.version=%s", TestHelper.GetVersion()),
"--set", "heartbeatSchedule=1 2 3 4 5",
}
// If testing deep suite with CNI, set --cni-enabled to true
if TestHelper.CNI() {
cmd = append(cmd, "--linkerd-cni-enabled")
}
if TestHelper.NonNativeSidecar() {
cmd = append(cmd, "--set", "proxy.nativeSidecar=false")
}
if TestHelper.DualStack() {
cmd = append(cmd, "--set", "disableIPv6=false")
}
// Pipe cmd & args to `linkerd`
out, err = TestHelper.LinkerdRun(cmd...)
if err != nil {
testutil.AnnotatedFatal(t, "'linkerd install' command failed", err)
}
out, err = TestHelper.KubectlApplyWithArgs(out)
if err != nil {
testutil.AnnotatedFatalf(t, "'kubectl apply' command failed",
"'kubectl apply' command failed\n%s", out)
}
out, err = TestHelper.LinkerdRun("check", "--wait=3m")
if err != nil {
testutil.AnnotatedFatalf(t, "'linkerd check' command failed",
"'linkerd check' command failed\n%s", out)
}
}