This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 558
/
orchestrators_test.go
154 lines (132 loc) · 3.94 KB
/
orchestrators_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
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
package api
import (
"testing"
"github.com/Azure/acs-engine/pkg/api/common"
"github.com/Masterminds/semver"
. "github.com/onsi/gomega"
)
func TestInvalidVersion(t *testing.T) {
RegisterTestingT(t)
invalid := []string{
"invalid number",
"invalid.number",
"a4.b7.c3",
"31.29.",
".17.02",
"43.156.89.",
"1.2.a"}
for _, v := range invalid {
_, e := semver.NewVersion(v)
Expect(e).NotTo(BeNil())
}
}
func TestVersionCompare(t *testing.T) {
RegisterTestingT(t)
type record struct {
v1, v2 string
isGreater bool
}
records := []record{
{"37.48.59", "37.48.59", false},
{"17.4.5", "3.1.1", true},
{"9.6.5", "9.45.5", false},
{"2.3.8", "2.3.24", false}}
for _, r := range records {
ver, e := semver.NewVersion(r.v1)
Expect(e).To(BeNil())
constraint, e := semver.NewConstraint(">" + r.v2)
Expect(e).To(BeNil())
Expect(r.isGreater).To(Equal(constraint.Check(ver)))
}
}
func TestOrchestratorUpgradeInfo(t *testing.T) {
RegisterTestingT(t)
// 1.6.8 is upgradable to 1.6.x and 1.7.x
csOrch := &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.6.8",
}
orch, e := GetOrchestratorVersionProfile(csOrch)
Expect(e).To(BeNil())
// 1.6.9, 1.6.11, 1.6.12, 1.6.13, 1.7.0, 1.7.1, 1.7.2, 1.7.4, 1.7.5, 1.7.7, 1.7.9, 1.7.10, 1.7.12, 1.7.13, 1.7.14, 1.7.15
Expect(len(orch.Upgrades)).To(Equal(16))
// 1.7.0 is upgradable to 1.7.x and 1.8.x
csOrch = &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.7.0",
}
orch, e = GetOrchestratorVersionProfile(csOrch)
Expect(e).To(BeNil())
// 1.7.1, 1.7.2, 1.7.4, 1.7.5, 1.7.7, 1.7.9, 1.7.10, 1.7.12, 1.7.13, 1.7.14, 1.7.15, 1.8.0, 1.8.1, 1.8.2, 1.8.4, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.8.10
Expect(len(orch.Upgrades)).To(Equal(20))
// 1.7.15 is upgradable to 1.8.x
csOrch = &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.7.15",
}
orch, e = GetOrchestratorVersionProfile(csOrch)
Expect(e).To(BeNil())
// 1.8.0, 1.8.1, 1.8.2, 1.8.4, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.8.10
Expect(len(orch.Upgrades)).To(Equal(9))
// 1.8.4 is upgradable to 1.8.x and 1.9.x
csOrch = &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.8.4",
}
orch, e = GetOrchestratorVersionProfile(csOrch)
Expect(e).To(BeNil())
// 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.8.10, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.9.5, 1.9.6
Expect(len(orch.Upgrades)).To(Equal(12))
// 1.9.6 is upgradable to 1.10.x
csOrch = &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.9.6",
}
orch, e = GetOrchestratorVersionProfile(csOrch)
Expect(e).To(BeNil())
// 1.10.0-beta.2, 1.10.0-beta.4, 1.10.0-rc.1
Expect(len(orch.Upgrades)).To(Equal(3))
// 1.10.0-beta.4 is upgradable to 1.10.x
csOrch = &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.10.0-beta.4",
}
orch, e = GetOrchestratorVersionProfile(csOrch)
Expect(e).To(BeNil())
Expect(len(orch.Upgrades)).To(Equal(1))
// 1.10.0-rc.1 is not upgradable
csOrch = &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.10.0-rc.1",
}
orch, e = GetOrchestratorVersionProfile(csOrch)
Expect(e).To(BeNil())
Expect(len(orch.Upgrades)).To(Equal(0))
// v20170930 - all orchestrators
list, e := GetOrchestratorVersionProfileListV20170930("", "")
Expect(e).To(BeNil())
Expect(len(list.Properties.Orchestrators)).To(Equal(41))
// v20170930 - kubernetes only
list, e = GetOrchestratorVersionProfileListV20170930(common.Kubernetes, "")
Expect(e).To(BeNil())
Expect(len(list.Properties.Orchestrators)).To(Equal(36))
}
func TestKubernetesInfo(t *testing.T) {
RegisterTestingT(t)
invalid := []string{
"invalid number",
"invalid.number",
"a4.b7.c3",
"31.29.",
".17.02",
"43.156.89.",
"1.2.a"}
for _, v := range invalid {
csOrch := &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: v,
}
_, e := kubernetesInfo(csOrch)
Expect(e).NotTo(BeNil())
}
}