-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathinstall_test.go
More file actions
173 lines (143 loc) · 4.42 KB
/
Copy pathinstall_test.go
File metadata and controls
173 lines (143 loc) · 4.42 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
package viztest
import (
"fmt"
"os"
"strconv"
"strings"
"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())
}
//////////////////////
/// TEST EXECUTION ///
//////////////////////
// TestInstallLinkerd will install the linkerd control plane to be used in the rest of
// the deep suite tests
func TestInstallLinkerd(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 --crds' 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",
}
// 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)
}
TestHelper.WaitRollout(t, testutil.LinkerdDeployReplicasEdge)
}
// TestInstallVizHA tests a dry run of installing viz in HA mode.
func TestInstallVizHA(t *testing.T) {
cmd := []string{
"viz",
"install",
"--set", fmt.Sprintf("namespace=%s", TestHelper.GetVizNamespace()),
"--ha",
}
if TestHelper.NonNativeSidecar() {
cmd = append(cmd, "--set", "proxy.nativeSidecar=false")
}
out, err := TestHelper.LinkerdRun(cmd...)
if err != nil {
testutil.AnnotatedFatal(t, "'linkerd viz install' command failed", err)
}
out, err = TestHelper.KubectlApplyWithArgs(out, "--dry-run")
if err != nil {
testutil.AnnotatedFatalf(t, "'kubectl apply' command failed",
"'kubectl apply' command failed\n%s", out)
}
}
// TestInstallViz will install the viz extension to be used by the rest of the
// tests in the viz suite
func TestInstallViz(t *testing.T) {
cmd := []string{
"viz",
"install",
"--set", fmt.Sprintf("namespace=%s", TestHelper.GetVizNamespace()),
}
out, err := TestHelper.LinkerdRun(cmd...)
if err != nil {
testutil.AnnotatedFatal(t, "'linkerd viz 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)
}
TestHelper.WaitRollout(t, testutil.LinkerdVizDeployReplicas)
}
func TestCheckViz(t *testing.T) {
if err := TestHelper.TestCheck(); err != nil {
t.Fatalf("'linkerd check' command failed: %s", err)
}
}
func TestDashboard(t *testing.T) {
dashboardPort := 52237
dashboardURL := fmt.Sprintf("http://localhost:%d", dashboardPort)
outputStream, err := TestHelper.LinkerdRunStream("viz", "dashboard", "-p",
strconv.Itoa(dashboardPort), "--show", "url")
if err != nil {
testutil.AnnotatedFatalf(t, "error running command",
"error running command:\n%s", err)
}
defer outputStream.Stop()
outputLines, err := outputStream.ReadUntil(4, 1*time.Minute)
if err != nil {
testutil.AnnotatedFatalf(t, "error running command",
"error running command:\n%s", err)
}
output := strings.Join(outputLines, "")
if !strings.Contains(output, dashboardURL) {
testutil.AnnotatedFatalf(t,
"dashboard command failed", "Expected url [%s] not present", dashboardURL)
}
resp, err := TestHelper.HTTPGetURL(dashboardURL + "/api/version")
if err != nil {
testutil.AnnotatedFatalf(t, "unexpected error",
"unexpected error: %v", err)
}
if !strings.Contains(resp, TestHelper.GetVersion()) {
testutil.AnnotatedFatalf(t, "dashboard command failed; response doesn't contain expected version",
"dashboard command failed. Expected response [%s] to contain version [%s]",
resp, TestHelper.GetVersion())
}
}