@@ -48,7 +48,7 @@ import (
48
48
func TestGetInstanceData (t * testing.T ) {
49
49
log := zaptest .Logger (t ).Sugar ()
50
50
testCase := map [string ]struct {
51
- clusterName string
51
+ deploymentName string
52
52
projectName string
53
53
providerName string
54
54
regionName string
@@ -59,7 +59,7 @@ func TestGetInstanceData(t *testing.T) {
59
59
expErrMsg string
60
60
}{
61
61
"Nominal" : {
62
- clusterName : "myCluster " ,
62
+ deploymentName : "myDeployment " ,
63
63
projectName : "myProject" ,
64
64
providerName : "GCP" ,
65
65
regionName : "GCP_REGION" ,
@@ -69,8 +69,8 @@ func TestGetInstanceData(t *testing.T) {
69
69
expInstanceSizeName : "M10" ,
70
70
expErrMsg : "" ,
71
71
},
72
- "MissingClusterName " : {
73
- clusterName : "" ,
72
+ "MissingDeploymentName " : {
73
+ deploymentName : "" ,
74
74
projectName : "myProject" ,
75
75
providerName : "GCP" ,
76
76
regionName : "GCP_REGION" ,
@@ -81,7 +81,7 @@ func TestGetInstanceData(t *testing.T) {
81
81
expErrMsg : "missing clusterName" ,
82
82
},
83
83
"MissingProjectName" : {
84
- clusterName : "myCluster " ,
84
+ deploymentName : "myDeployment " ,
85
85
projectName : "" ,
86
86
providerName : "GCP" ,
87
87
regionName : "GCP_REGION" ,
@@ -92,7 +92,7 @@ func TestGetInstanceData(t *testing.T) {
92
92
expErrMsg : "missing projectName" ,
93
93
},
94
94
"UseDefaultProvider" : {
95
- clusterName : "myCluster " ,
95
+ deploymentName : "myDeployment " ,
96
96
projectName : "myProject" ,
97
97
providerName : "" ,
98
98
regionName : "AWS_REGION" ,
@@ -103,7 +103,7 @@ func TestGetInstanceData(t *testing.T) {
103
103
expErrMsg : "" ,
104
104
},
105
105
"UseDefaultRegion" : {
106
- clusterName : "myCluster " ,
106
+ deploymentName : "myDeployment " ,
107
107
projectName : "myProject" ,
108
108
providerName : "AWS" ,
109
109
regionName : "" ,
@@ -114,7 +114,7 @@ func TestGetInstanceData(t *testing.T) {
114
114
expErrMsg : "" ,
115
115
},
116
116
"UseDefaultInstanceSizeName" : {
117
- clusterName : "myCluster " ,
117
+ deploymentName : "myDeployment " ,
118
118
projectName : "myProject" ,
119
119
providerName : "AWS" ,
120
120
regionName : "US_EAST_1" ,
@@ -142,7 +142,7 @@ func TestGetInstanceData(t *testing.T) {
142
142
Name : fmt .Sprintf ("inventory-%s" , tcName ),
143
143
Namespace : "dbaas-operator" ,
144
144
},
145
- Name : tc .clusterName ,
145
+ Name : tc .deploymentName ,
146
146
CloudProvider : tc .providerName ,
147
147
CloudRegion : tc .regionName ,
148
148
OtherInstanceParams : map [string ]string {
@@ -154,7 +154,7 @@ func TestGetInstanceData(t *testing.T) {
154
154
155
155
expected := & InstanceData {
156
156
ProjectName : tc .projectName ,
157
- ClusterName : tc .clusterName ,
157
+ ClusterName : tc .deploymentName ,
158
158
ProviderName : tc .expProviderName ,
159
159
RegionName : tc .expRegionName ,
160
160
InstanceSizeName : tc .expInstanceSizeName ,
@@ -210,25 +210,25 @@ func setupMockAltasServer(t *testing.T) (client *mongodbatlas.Client, teardown f
210
210
}
211
211
}).Methods (http .MethodGet )
212
212
213
- router .HandleFunc ("/api/atlas/v1.0/groups/{group-id}/clusters/{cluster -name}" , func (w http.ResponseWriter , r * http.Request ) {
213
+ router .HandleFunc ("/api/atlas/v1.0/groups/{group-id}/clusters/{deployment -name}" , func (w http.ResponseWriter , r * http.Request ) {
214
214
vars := mux .Vars (r )
215
215
groupID , ok := vars ["group-id" ]
216
216
if ! ok {
217
217
fmt .Fprint (w , "group-id is missing in parameters" )
218
218
}
219
- clusterName , ok := vars ["cluster -name" ]
219
+ deploymentName , ok := vars ["deployment -name" ]
220
220
if ! ok {
221
- fmt .Fprint (w , "cluster -name is missing in parameters" )
221
+ fmt .Fprint (w , "deployment -name is missing in parameters" )
222
222
}
223
- data , err := ioutil .ReadFile (fmt .Sprintf ("../../../test/e2e/data/atlasclusterget_ %s_%s.json" , groupID , clusterName ))
223
+ data , err := ioutil .ReadFile (fmt .Sprintf ("../../../test/e2e/data/atlasdeploymentget_ %s_%s.json" , groupID , deploymentName ))
224
224
if err == nil {
225
225
assert .NoError (t , err )
226
226
w .WriteHeader (http .StatusOK )
227
227
fmt .Fprint (w , string (data ))
228
228
} else {
229
229
w .WriteHeader (http .StatusNotFound )
230
- f := "{\" detail\" :\" No cluster named %s exists in group %s.\" ,\" error\" :404,\" errorCode\" :\" CLUSTER_NOT_FOUND\" ,\" parameters\" :[\" %s\" ,\" groupid123\" ],\" reason\" :\" Not Found\" }"
231
- fmt .Fprintf (w , f , clusterName , groupID , clusterName )
230
+ f := "{\" detail\" :\" No deployment named %s exists in group %s.\" ,\" error\" :404,\" errorCode\" :\" CLUSTER_NOT_FOUND\" ,\" parameters\" :[\" %s\" ,\" groupid123\" ],\" reason\" :\" Not Found\" }"
231
+ fmt .Fprintf (w , f , deploymentName , groupID , deploymentName )
232
232
}
233
233
}).Methods (http .MethodGet )
234
234
@@ -244,43 +244,43 @@ func setupMockAltasServer(t *testing.T) (client *mongodbatlas.Client, teardown f
244
244
return client , server .Close
245
245
}
246
246
247
- func TestSetInstanceStatusWithClusterInfo (t * testing.T ) {
247
+ func TestSetInstanceStatusWithDeploymentInfo (t * testing.T ) {
248
248
atlasClient , teardown := setupMockAltasServer (t )
249
249
defer teardown ()
250
250
251
251
namespace := "default"
252
252
testCase := map [string ]struct {
253
- clusterName string
254
- projectName string
255
- expErrMsg string
256
- expPhase dbaasv1alpha1.DBaasInstancePhase
257
- expStatus string
253
+ deploymentName string
254
+ projectName string
255
+ expErrMsg string
256
+ expPhase dbaasv1alpha1.DBaasInstancePhase
257
+ expStatus string
258
258
}{
259
- "ClusterCreating " : {
260
- clusterName : "myclustercreating " ,
261
- projectName : "myproject" ,
262
- expErrMsg : "" ,
263
- expPhase : dbaasv1alpha1 .InstancePhaseCreating ,
264
- expStatus : "True" ,
259
+ "DeploymentCreating " : {
260
+ deploymentName : "mydeploymentcreating " ,
261
+ projectName : "myproject" ,
262
+ expErrMsg : "" ,
263
+ expPhase : dbaasv1alpha1 .InstancePhaseCreating ,
264
+ expStatus : "True" ,
265
265
},
266
- "ClusterReady " : {
267
- clusterName : "myclusterready " ,
268
- projectName : "myproject" ,
269
- expErrMsg : "" ,
270
- expPhase : dbaasv1alpha1 .InstancePhaseReady ,
271
- expStatus : "True" ,
266
+ "DeploymentReady " : {
267
+ deploymentName : "mydeploymentready " ,
268
+ projectName : "myproject" ,
269
+ expErrMsg : "" ,
270
+ expPhase : dbaasv1alpha1 .InstancePhaseReady ,
271
+ expStatus : "True" ,
272
272
},
273
273
"InvalidProject" : {
274
- clusterName : "myclusterready " ,
275
- projectName : "myproject-invalid" ,
276
- expErrMsg : "NOT_IN_GROUP" ,
274
+ deploymentName : "mydeploymentready " ,
275
+ projectName : "myproject-invalid" ,
276
+ expErrMsg : "NOT_IN_GROUP" ,
277
277
},
278
278
}
279
279
for tcName , tc := range testCase {
280
280
t .Run (tcName , func (t * testing.T ) {
281
281
atlasDeployment := & v1.AtlasDeployment {
282
282
ObjectMeta : metav1.ObjectMeta {
283
- Name : "my-cluster -free" ,
283
+ Name : "my-deployment -free" ,
284
284
Namespace : namespace ,
285
285
},
286
286
Spec : v1.AtlasDeploymentSpec {
@@ -289,7 +289,7 @@ func TestSetInstanceStatusWithClusterInfo(t *testing.T) {
289
289
Namespace : namespace ,
290
290
},
291
291
DeploymentSpec : & v1.DeploymentSpec {
292
- Name : tc .clusterName ,
292
+ Name : tc .deploymentName ,
293
293
ProviderSettings : & v1.ProviderSettingsSpec {
294
294
BackingProviderName : "AWS" ,
295
295
InstanceSizeName : "M0" ,
@@ -307,7 +307,7 @@ func TestSetInstanceStatusWithClusterInfo(t *testing.T) {
307
307
LastTransitionTime : metav1 .Now (),
308
308
},
309
309
{
310
- Type : status .ConditionType ("ClusterReady " ),
310
+ Type : status .ConditionType ("DeploymentReady " ),
311
311
Status : corev1 .ConditionTrue ,
312
312
LastTransitionTime : metav1 .Now (),
313
313
},
@@ -325,13 +325,13 @@ func TestSetInstanceStatusWithClusterInfo(t *testing.T) {
325
325
Name : "my-inventory" ,
326
326
Namespace : namespace ,
327
327
},
328
- Name : tc .clusterName ,
328
+ Name : tc .deploymentName ,
329
329
OtherInstanceParams : map [string ]string {
330
330
"projectName" : tc .projectName ,
331
331
},
332
332
},
333
333
}
334
- result := setInstanceStatusWithClusterInfo (atlasClient , inst , atlasDeployment , tc .projectName )
334
+ result := setInstanceStatusWithDeploymentInfo (atlasClient , inst , atlasDeployment , tc .projectName )
335
335
if len (tc .expErrMsg ) == 0 {
336
336
cond := dbaas .GetInstanceCondition (inst , dbaasv1alpha1 .DBaaSInstanceProviderSyncType )
337
337
assert .NotNil (t , cond )
@@ -366,7 +366,7 @@ func TestAtlasInstanceReconcile(t *testing.T) {
366
366
}
367
367
368
368
tcName := "mytest"
369
- clusterName := "myclusternew "
369
+ deploymentName := "mydeploymentnew "
370
370
projectName := "myproject"
371
371
expectedPhase := dbaasv1alpha1 .InstancePhasePending
372
372
expectedErrString := "CLUSTER_NOT_FOUND"
@@ -414,7 +414,7 @@ func TestAtlasInstanceReconcile(t *testing.T) {
414
414
Namespace : "dbaas-operator" ,
415
415
},
416
416
Spec : dbaasv1alpha1.DBaaSInstanceSpec {
417
- Name : clusterName ,
417
+ Name : deploymentName ,
418
418
InventoryRef : dbaasv1alpha1.NamespacedName {
419
419
Name : inventory .Name ,
420
420
Namespace : inventory .Namespace ,
0 commit comments