33
33
cancel context.CancelFunc
34
34
)
35
35
36
+ const (
37
+ feature_flag_1 = "feature_flag_1"
38
+ feature_flag_2 = "feature_flag_2"
39
+ )
40
+
36
41
func init () {
37
42
// Create context
38
43
ctx , cancel = context .WithCancel (context .Background ())
@@ -44,8 +49,8 @@ func init() {
44
49
// Scenario 2: FSS is disabled both in SV and GC
45
50
func TestIsFSSEnabledInGcWithSync (t * testing.T ) {
46
51
svFSS := map [string ]string {
47
- "volume-extend" : "true" ,
48
- "volume-health" : "false" ,
52
+ feature_flag_1 : "true" ,
53
+ feature_flag_2 : "false" ,
49
54
}
50
55
svFSSConfigMapInfo := FSSConfigMapInfo {
51
56
configMapName : cnsconfig .DefaultSupervisorFSSConfigMapName ,
@@ -54,8 +59,8 @@ func TestIsFSSEnabledInGcWithSync(t *testing.T) {
54
59
featureStatesLock : & sync.RWMutex {},
55
60
}
56
61
internalFSS := map [string ]string {
57
- "volume-extend" : "true" ,
58
- "volume-health" : "false" ,
62
+ feature_flag_1 : "true" ,
63
+ feature_flag_2 : "false" ,
59
64
}
60
65
internalFSSConfigMapInfo := FSSConfigMapInfo {
61
66
configMapName : cnsconfig .DefaultInternalFSSConfigMapName ,
@@ -68,13 +73,13 @@ func TestIsFSSEnabledInGcWithSync(t *testing.T) {
68
73
clusterFlavor : cnstypes .CnsClusterFlavorGuest ,
69
74
internalFSS : internalFSSConfigMapInfo ,
70
75
}
71
- isEnabled := k8sOrchestrator .IsFSSEnabled (ctx , "volume-extend" )
76
+ isEnabled := k8sOrchestrator .IsFSSEnabled (ctx , feature_flag_1 )
72
77
if ! isEnabled {
73
- t .Errorf ("volume-extend feature state is disabled!" )
78
+ t .Errorf ("%s feature state is disabled!" , feature_flag_1 )
74
79
}
75
- isEnabled = k8sOrchestrator .IsFSSEnabled (ctx , "volume-health" )
80
+ isEnabled = k8sOrchestrator .IsFSSEnabled (ctx , feature_flag_2 )
76
81
if isEnabled {
77
- t .Errorf ("volume-health feature state is enabled!" )
82
+ t .Errorf ("%s feature state is enabled!" , feature_flag_2 )
78
83
}
79
84
}
80
85
@@ -83,8 +88,8 @@ func TestIsFSSEnabledInGcWithSync(t *testing.T) {
83
88
// Scenario 2: FSS is disabled in SV but enabled in GC
84
89
func TestIsFSSEnabledInGcWithoutSync (t * testing.T ) {
85
90
svFSS := map [string ]string {
86
- "volume-extend" : "true" ,
87
- "volume-health" : "false" ,
91
+ feature_flag_1 : "true" ,
92
+ feature_flag_2 : "false" ,
88
93
}
89
94
svFSSConfigMapInfo := FSSConfigMapInfo {
90
95
configMapName : cnsconfig .DefaultSupervisorFSSConfigMapName ,
@@ -93,8 +98,8 @@ func TestIsFSSEnabledInGcWithoutSync(t *testing.T) {
93
98
featureStatesLock : & sync.RWMutex {},
94
99
}
95
100
internalFSS := map [string ]string {
96
- "volume-extend" : "false" ,
97
- "volume-health" : "true" ,
101
+ feature_flag_1 : "false" ,
102
+ feature_flag_2 : "true" ,
98
103
}
99
104
internalFSSConfigMapInfo := FSSConfigMapInfo {
100
105
configMapName : cnsconfig .DefaultInternalFSSConfigMapName ,
@@ -107,13 +112,13 @@ func TestIsFSSEnabledInGcWithoutSync(t *testing.T) {
107
112
clusterFlavor : cnstypes .CnsClusterFlavorGuest ,
108
113
internalFSS : internalFSSConfigMapInfo ,
109
114
}
110
- isEnabled := k8sOrchestrator .IsFSSEnabled (ctx , "volume-extend" )
115
+ isEnabled := k8sOrchestrator .IsFSSEnabled (ctx , feature_flag_1 )
111
116
if isEnabled {
112
- t .Errorf ("volume-extend feature state is enabled!" )
117
+ t .Errorf ("%s feature state is enabled!" , feature_flag_1 )
113
118
}
114
- isEnabled = k8sOrchestrator .IsFSSEnabled (ctx , "volume-health" )
119
+ isEnabled = k8sOrchestrator .IsFSSEnabled (ctx , feature_flag_2 )
115
120
if isEnabled {
116
- t .Errorf ("volume-health feature state is enabled!" )
121
+ t .Errorf ("%s feature state is enabled!" , feature_flag_2 )
117
122
}
118
123
}
119
124
@@ -122,8 +127,8 @@ func TestIsFSSEnabledInGcWithoutSync(t *testing.T) {
122
127
// Scenario 2: Missing feature state
123
128
func TestIsFSSEnabledInGcWrongValues (t * testing.T ) {
124
129
svFSS := map [string ]string {
125
- "volume-extend" : "true" ,
126
- "volume-health" : "true" ,
130
+ feature_flag_1 : "true" ,
131
+ feature_flag_2 : "true" ,
127
132
}
128
133
svFSSConfigMapInfo := FSSConfigMapInfo {
129
134
configMapName : cnsconfig .DefaultSupervisorFSSConfigMapName ,
@@ -132,7 +137,7 @@ func TestIsFSSEnabledInGcWrongValues(t *testing.T) {
132
137
featureStatesLock : & sync.RWMutex {},
133
138
}
134
139
internalFSS := map [string ]string {
135
- "volume-extend" : "enabled" ,
140
+ feature_flag_1 : "enabled" ,
136
141
}
137
142
internalFSSConfigMapInfo := FSSConfigMapInfo {
138
143
configMapName : cnsconfig .DefaultInternalFSSConfigMapName ,
@@ -146,22 +151,22 @@ func TestIsFSSEnabledInGcWrongValues(t *testing.T) {
146
151
internalFSS : internalFSSConfigMapInfo ,
147
152
}
148
153
// Wrong value given
149
- isEnabled := k8sOrchestrator .IsFSSEnabled (ctx , "volume-extend" )
154
+ isEnabled := k8sOrchestrator .IsFSSEnabled (ctx , feature_flag_1 )
150
155
if isEnabled {
151
- t .Errorf ("volume-extend feature state is enabled even when it was assigned a wrong value!" )
156
+ t .Errorf ("%s feature state is enabled even when it was assigned a wrong value!" , feature_flag_1 )
152
157
}
153
158
// Feature state missing
154
- isEnabled = k8sOrchestrator .IsFSSEnabled (ctx , "volume-health" )
159
+ isEnabled = k8sOrchestrator .IsFSSEnabled (ctx , feature_flag_2 )
155
160
if isEnabled {
156
- t .Errorf ("Non existing feature state volume-health is enabled!" )
161
+ t .Errorf ("Non existing feature state %s is enabled!" , feature_flag_2 )
157
162
}
158
163
}
159
164
160
165
// TestIsFSSEnabledInSV tests IsFSSEnabled in Supervisor flavor - all scenarios
161
166
func TestIsFSSEnabledInSV (t * testing.T ) {
162
167
svFSS := map [string ]string {
163
- "volume-extend" : "true" ,
164
- "volume-health" : "false" ,
168
+ feature_flag_1 : "true" ,
169
+ feature_flag_2 : "false" ,
165
170
"csi-migration" : "enabled" ,
166
171
}
167
172
svFSSConfigMapInfo := FSSConfigMapInfo {
@@ -174,13 +179,13 @@ func TestIsFSSEnabledInSV(t *testing.T) {
174
179
supervisorFSS : svFSSConfigMapInfo ,
175
180
clusterFlavor : cnstypes .CnsClusterFlavorWorkload ,
176
181
}
177
- isEnabled := k8sOrchestrator .IsFSSEnabled (ctx , "volume-extend" )
182
+ isEnabled := k8sOrchestrator .IsFSSEnabled (ctx , feature_flag_1 )
178
183
if ! isEnabled {
179
- t .Errorf ("volume-extend feature state is disabled!" )
184
+ t .Errorf ("%s feature state is disabled!" , feature_flag_1 )
180
185
}
181
- isEnabled = k8sOrchestrator .IsFSSEnabled (ctx , "volume-health" )
186
+ isEnabled = k8sOrchestrator .IsFSSEnabled (ctx , feature_flag_2 )
182
187
if isEnabled {
183
- t .Errorf ("volume-health feature state is enabled!" )
188
+ t .Errorf ("%s feature state is enabled!" , feature_flag_2 )
184
189
}
185
190
// Wrong value given
186
191
isEnabled = k8sOrchestrator .IsFSSEnabled (ctx , "csi-migration" )
@@ -218,9 +223,9 @@ func TestIsFSSEnabledWithWrongClusterFlavor(t *testing.T) {
218
223
k8sOrchestrator := K8sOrchestrator {
219
224
clusterFlavor : "Vanila" ,
220
225
}
221
- isEnabled := k8sOrchestrator .IsFSSEnabled (ctx , "volume-extend" )
226
+ isEnabled := k8sOrchestrator .IsFSSEnabled (ctx , feature_flag_1 )
222
227
if isEnabled {
223
- t .Errorf ("volume-extend feature state enabled even when cluster flavor is wrong" )
228
+ t .Errorf ("%s feature state enabled even when cluster flavor is wrong" , feature_flag_1 )
224
229
}
225
230
}
226
231
0 commit comments