@@ -70,33 +70,33 @@ func deploymentSubTest(t *testing.T, mode api.DeploymentMode, engine api.Storage
70
70
// check environment
71
71
longOrSkip (t )
72
72
73
- k8sNameSpace := getNamespace (t )
74
- k8sClient := mustNewKubeClient (t )
75
- deploymentClient := kubeArangoClient .MustNewInCluster ()
73
+ ns := getNamespace (t )
74
+ kubecli := mustNewKubeClient (t )
75
+ c := kubeArangoClient .MustNewInCluster ()
76
76
77
77
// Prepare deployment config
78
- deploymentTemplate := newDeployment ("test-1 -deployment-" + string (mode ) + "-" + string (engine ) + "-" + uniuri .NewLen (4 ))
79
- deploymentTemplate .Spec .Mode = api .NewMode (mode )
80
- deploymentTemplate .Spec .StorageEngine = api .NewStorageEngine (engine )
81
- deploymentTemplate .Spec .TLS = api.TLSSpec {} // should auto-generate cert
82
- deploymentTemplate .Spec .SetDefaults (deploymentTemplate .GetName ()) // this must be last
78
+ depl := newDeployment ("test-deployment-" + string (mode ) + "-" + string (engine ) + "-" + uniuri .NewLen (4 ))
79
+ depl .Spec .Mode = api .NewMode (mode )
80
+ depl .Spec .StorageEngine = api .NewStorageEngine (engine )
81
+ depl .Spec .TLS = api.TLSSpec {} // should auto-generate cert
82
+ depl .Spec .SetDefaults (depl .GetName ()) // this must be last
83
83
84
84
// Create deployment
85
- _ , err := deploymentClient .DatabaseV1alpha ().ArangoDeployments (k8sNameSpace ).Create (deploymentTemplate )
85
+ _ , err := c .DatabaseV1alpha ().ArangoDeployments (ns ).Create (depl )
86
86
require .NoError (t , err , fmt .Sprintf ("Create deployment failed: %v" , err ))
87
- defer deferedCleanupDeployment (deploymentClient , deploymentTemplate .GetName (), k8sNameSpace )
87
+ defer deferedCleanupDeployment (c , depl .GetName (), ns )
88
88
89
89
// Wait for deployment to be ready
90
- deployment , err := waitUntilDeployment (deploymentClient , deploymentTemplate .GetName (), k8sNameSpace , deploymentIsReady ())
90
+ deployment , err := waitUntilDeployment (c , depl .GetName (), ns , deploymentIsReady ())
91
91
require .NoError (t , err , fmt .Sprintf ("Deployment not running in time: %v" , err ))
92
92
93
93
// Create a database client
94
94
ctx := context .Background ()
95
- DBClient := mustNewArangodDatabaseClient (ctx , k8sClient , deployment , t )
96
- require .NoError (t , waitUntilArangoDeploymentHealthy (deployment , DBClient , k8sClient , "" ), fmt .Sprintf ("Deployment not healthy in time: %v" , err ))
95
+ DBClient := mustNewArangodDatabaseClient (ctx , kubecli , deployment , t )
96
+ require .NoError (t , waitUntilArangoDeploymentHealthy (deployment , DBClient , kubecli , "" ), fmt .Sprintf ("Deployment not healthy in time: %v" , err ))
97
97
98
98
// Cleanup
99
- removeDeployment (deploymentClient , deploymentTemplate .GetName (), k8sNameSpace )
99
+ removeDeployment (c , depl .GetName (), ns )
100
100
101
101
return nil
102
102
}
@@ -105,47 +105,47 @@ func deploymentSubTest(t *testing.T, mode api.DeploymentMode, engine api.Storage
105
105
func TestMultiDeployment (t * testing.T ) {
106
106
longOrSkip (t )
107
107
108
- k8sNameSpace := getNamespace (t )
109
- k8sClient := mustNewKubeClient (t )
110
- deploymentClient := kubeArangoClient .MustNewInCluster ()
108
+ ns := getNamespace (t )
109
+ kubecli := mustNewKubeClient (t )
110
+ c := kubeArangoClient .MustNewInCluster ()
111
111
112
112
// Prepare deployment configurations
113
- deploymentTemplate1 := newDeployment ("test-multidep1 -1-" + uniuri .NewLen (4 ))
114
- deploymentTemplate1 .Spec .Mode = api .NewMode (api .DeploymentModeCluster )
115
- deploymentTemplate1 .Spec .StorageEngine = api .NewStorageEngine (api .StorageEngineRocksDB )
116
- deploymentTemplate1 .Spec .TLS = api.TLSSpec {} // should auto-generate cert
117
- deploymentTemplate1 .Spec .SetDefaults (deploymentTemplate1 .GetName ()) // this must be last
118
-
119
- deploymentTemplate2 := newDeployment ("test-multidep1 -2-" + uniuri .NewLen (4 ))
120
- deploymentTemplate2 .Spec .Mode = api .NewMode (api .DeploymentModeSingle )
121
- deploymentTemplate2 .Spec .StorageEngine = api .NewStorageEngine (api .StorageEngineMMFiles )
122
- deploymentTemplate2 .Spec .TLS = api.TLSSpec {} // should auto-generate cert
123
- deploymentTemplate2 .Spec .SetDefaults (deploymentTemplate2 .GetName ()) // this must be last
113
+ depl1 := newDeployment ("test-multidep -1-" + uniuri .NewLen (4 ))
114
+ depl1 .Spec .Mode = api .NewMode (api .DeploymentModeCluster )
115
+ depl1 .Spec .StorageEngine = api .NewStorageEngine (api .StorageEngineRocksDB )
116
+ depl1 .Spec .TLS = api.TLSSpec {} // should auto-generate cert
117
+ depl1 .Spec .SetDefaults (depl1 .GetName ()) // this must be last
118
+
119
+ depl2 := newDeployment ("test-multidep -2-" + uniuri .NewLen (4 ))
120
+ depl2 .Spec .Mode = api .NewMode (api .DeploymentModeSingle )
121
+ depl2 .Spec .StorageEngine = api .NewStorageEngine (api .StorageEngineMMFiles )
122
+ depl2 .Spec .TLS = api.TLSSpec {} // should auto-generate cert
123
+ depl2 .Spec .SetDefaults (depl2 .GetName ()) // this must be last
124
124
125
125
// Create deployments
126
- _ , err := deploymentClient .DatabaseV1alpha ().ArangoDeployments (k8sNameSpace ).Create (deploymentTemplate1 )
126
+ _ , err := c .DatabaseV1alpha ().ArangoDeployments (ns ).Create (depl1 )
127
127
require .NoError (t , err , fmt .Sprintf ("Deployment creation failed: %v" , err ))
128
- defer deferedCleanupDeployment (deploymentClient , deploymentTemplate1 .GetName (), k8sNameSpace )
128
+ defer deferedCleanupDeployment (c , depl1 .GetName (), ns )
129
129
130
- _ , err = deploymentClient .DatabaseV1alpha ().ArangoDeployments (k8sNameSpace ).Create (deploymentTemplate2 )
130
+ _ , err = c .DatabaseV1alpha ().ArangoDeployments (ns ).Create (depl2 )
131
131
require .NoError (t , err , fmt .Sprintf ("Deployment creation failed: %v" , err ))
132
- defer deferedCleanupDeployment (deploymentClient , deploymentTemplate2 .GetName (), k8sNameSpace )
132
+ defer deferedCleanupDeployment (c , depl2 .GetName (), ns )
133
133
134
134
// Wait for deployments to be ready
135
- deployment1 , err := waitUntilDeployment (deploymentClient , deploymentTemplate1 .GetName (), k8sNameSpace , deploymentIsReady ())
135
+ deployment1 , err := waitUntilDeployment (c , depl1 .GetName (), ns , deploymentIsReady ())
136
136
require .NoError (t , err , fmt .Sprintf ("Deployment not running in time: %v" , err ))
137
137
138
- deployment2 , err := waitUntilDeployment (deploymentClient , deploymentTemplate2 .GetName (), k8sNameSpace , deploymentIsReady ())
138
+ deployment2 , err := waitUntilDeployment (c , depl2 .GetName (), ns , deploymentIsReady ())
139
139
require .NoError (t , err , fmt .Sprintf ("Deployment not running in time: %v" , err ))
140
140
141
141
require .True (t , deployment1 != nil && deployment2 != nil , "deployment is nil" )
142
142
143
143
// Create a database clients
144
144
ctx := context .Background ()
145
- DBClient1 := mustNewArangodDatabaseClient (ctx , k8sClient , deployment1 , t )
146
- require .NoError (t , waitUntilArangoDeploymentHealthy (deployment1 , DBClient1 , k8sClient , "" ), fmt .Sprintf ("Deployment not healthy in time: %v" , err ))
147
- DBClient2 := mustNewArangodDatabaseClient (ctx , k8sClient , deployment2 , t )
148
- require .NoError (t , waitUntilArangoDeploymentHealthy (deployment1 , DBClient1 , k8sClient , "" ), fmt .Sprintf ("Deployment not healthy in time: %v" , err ))
145
+ DBClient1 := mustNewArangodDatabaseClient (ctx , kubecli , deployment1 , t )
146
+ require .NoError (t , waitUntilArangoDeploymentHealthy (deployment1 , DBClient1 , kubecli , "" ), fmt .Sprintf ("Deployment not healthy in time: %v" , err ))
147
+ DBClient2 := mustNewArangodDatabaseClient (ctx , kubecli , deployment2 , t )
148
+ require .NoError (t , waitUntilArangoDeploymentHealthy (deployment1 , DBClient1 , kubecli , "" ), fmt .Sprintf ("Deployment not healthy in time: %v" , err ))
149
149
150
150
// Test if we are able to create a collections in both deployments.
151
151
db1 , err := DBClient1 .Database (ctx , "_system" )
@@ -171,8 +171,8 @@ func TestMultiDeployment(t *testing.T) {
171
171
assert .False (t , containsCollection (collections2 , "col1" ), "collection must not be in this deployment" )
172
172
173
173
// Cleanup
174
- removeDeployment (deploymentClient , deploymentTemplate1 .GetName (), k8sNameSpace )
175
- removeDeployment (deploymentClient , deploymentTemplate2 .GetName (), k8sNameSpace )
174
+ removeDeployment (c , depl1 .GetName (), ns )
175
+ removeDeployment (c , depl2 .GetName (), ns )
176
176
177
177
}
178
178
0 commit comments