23
23
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
24
24
import oracle .weblogic .kubernetes .annotations .Namespaces ;
25
25
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
26
- import org .junit .jupiter .api .AfterAll ;
27
26
import org .junit .jupiter .api .BeforeAll ;
28
- import org .junit .jupiter .api .Disabled ;
29
27
import org .junit .jupiter .api .DisplayName ;
30
- import org .junit .jupiter .api .MethodOrderer ;
31
- import org .junit .jupiter .api .Order ;
32
28
import org .junit .jupiter .api .Test ;
33
- import org .junit .jupiter .api .TestMethodOrder ;
34
29
35
30
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
36
31
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_SERVER_NAME_BASE ;
50
45
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
51
46
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .scaleAndVerifyCluster ;
52
47
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
48
+ import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
49
+ import static oracle .weblogic .kubernetes .utils .OKDUtils .setTlsTerminationForRoute ;
53
50
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
54
51
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
55
52
import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
58
55
import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
59
56
import static org .junit .jupiter .api .Assertions .assertNotNull ;
60
57
import static org .junit .jupiter .api .Assertions .assertTrue ;
61
- import static org .junit .jupiter .api .Assertions .fail ;
62
58
63
59
/**
64
- * The current class verifies various use cases related to domainNamespaceSelectionStrategy.
60
+ * The current class verifies various use cases related to Dedicated
61
+ * domainNamespaceSelectionStrategy applicable to Operator Helm Chart.
65
62
* For more detail regarding the feature, please refer to
66
- * https://github.com/oracle/weblogic-kubernetes-operator/blob/develop/docs-source/content/
67
- * userguide/managing-operators/using-the-operator/using-helm.md#overall-operator-information.
63
+ * https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-operators/using-helm/#weblogic-domain-management
68
64
*/
69
- @ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
70
65
@ DisplayName ("Test Operator and WebLogic domain with Dedicated set to true" )
71
66
@ IntegrationTest
72
67
class ItDedicatedMode {
@@ -78,11 +73,13 @@ class ItDedicatedMode {
78
73
private static final String CRD_V16 = "domain-crd.yaml" ;
79
74
80
75
// domain constants
81
- private final String domainUid = "dedicated-domain-1 " ;
76
+ private final String domainUid = "dedicated-domain1 " ;
82
77
private final String clusterName = "cluster-1" ;
83
78
private final int replicaCount = 2 ;
84
- private final String adminServerPodName = domainUid + "-" + ADMIN_SERVER_NAME_BASE ;
85
- private final String managedServerPodPrefix = domainUid + "-" + MANAGED_SERVER_NAME_BASE ;
79
+ private final String adminServerPodName =
80
+ domainUid + "-" + ADMIN_SERVER_NAME_BASE ;
81
+ private final String managedServerPodPrefix =
82
+ domainUid + "-" + MANAGED_SERVER_NAME_BASE ;
86
83
87
84
// operator constants
88
85
private static HelmParams opHelmParams ;
@@ -92,20 +89,22 @@ class ItDedicatedMode {
92
89
private static LoggingFacade logger = null ;
93
90
94
91
/**
95
- * Get namespaces for operator and domain2. Create CRD based on the k8s version.
96
- *
92
+ * Get namespaces for operator and domain.
93
+ * Create CRD based on the k8s version.
97
94
* @param namespaces list of namespaces created by the IntegrationTestWatcher by the
98
95
* JUnit engine parameter resolution mechanism.
99
96
*/
100
97
@ BeforeAll
101
98
public static void initAll (@ Namespaces (2 ) List <String > namespaces ) {
102
99
logger = getLogger ();
100
+
103
101
// get a unique operator namespace
104
102
logger .info ("Getting a unique namespace for operator" );
105
103
assertNotNull (namespaces .get (0 ), "Namespace list is null" );
106
104
opNamespace = namespaces .get (0 );
107
105
108
- // in the dedicated mode, the operator only manages domains in the operator's own namespace
106
+ // in the dedicated mode, the operator only manages domains in the
107
+ // operator's own namespace
109
108
domain1Namespace = opNamespace ;
110
109
111
110
// get a new unique domainNamespace
@@ -121,80 +120,66 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
121
120
.chartDir (OPERATOR_CHART_DIR );
122
121
123
122
// delete existing CRD
124
- new Command ()
123
+ Command
125
124
.withParams (new CommandParams ()
126
125
.command ("kubectl delete crd domains.weblogic.oracle --ignore-not-found" ))
127
126
.execute ();
128
127
129
128
// install CRD
130
129
String createCrdCommand = "kubectl create -f " + ITTESTS_DIR + "/../kubernetes/crd/" + CRD_V16 ;
131
130
logger .info ("Creating CRD with command {0}" , createCrdCommand );
132
- new Command ()
131
+ Command
133
132
.withParams (new CommandParams ().command (createCrdCommand ))
134
133
.execute ();
135
- }
136
134
137
- @ AfterAll
138
- public void tearDownAll () {
135
+ // Install the Operator in a ns (say op) with helm parameter
136
+ // domainNamespaceSelectionStrategy set to Dedicated and set
137
+ // domainNamespaces parameter to something other than Operator ns (say wls)
138
+ logger .info ("Installing and verifying operator" );
139
+ installAndVerifyOperator (opNamespace , opNamespace + "-sa" ,
140
+ true , 0 , opHelmParams , domainNamespaceSelectionStrategy ,
141
+ false , domain2Namespace );
142
+ logger .info ("Operator installed on namespace {0} and domainNamespaces set to {1} " , opNamespace , domain2Namespace );
143
+
139
144
}
140
145
141
146
/**
142
- * When installing the Operator via helm install,
143
- * set the Operator Helm Chart parameter domainNamespaceSelectionStrategy to Dedicated and
144
- * set domainNamespaces to something that is different from the operator's namespace.
145
- * Make sure that the domain which is not in the operator's target namespaces do not come up.
146
- * Install an Operator with a namespace and set domainNamespaces in a different namespace
147
- * from the Operator's namespace, also set domainNamespaceSelectionStrategy to Dedicated
148
- * for the Operator Helm Chart.
149
- * Verify the Operator is up and running.
150
- * Create WebLogic Domain in a namespace that is different from the Operator's namespace.
151
- * Verify that the domain does not come up.
147
+ * Create WebLogic Domain in a namespace (say wls) that is different
148
+ * from the Operator's namespace. Verify that the domain does not come up.
152
149
*/
153
150
@ Test
154
- @ Order (1 )
155
- @ DisplayName ("Set domainNamespaceSelectionStrategy to Dedicated for the Operator Helm Chart and "
156
- + "verify that a domain not deployed in operator's namespace doesn't come up" )
151
+ @ DisplayName ("Verify in Dedicated NamespaceSelectionStrategy domain on non-operator namespace does not started" )
157
152
void testDedicatedModeDiffNamespace () {
158
- // install and verify operator
159
- logger .info ("Installing and verifying operator" );
160
- installAndVerifyOperator (opNamespace , opNamespace + "-sa" ,
161
- true , 0 , opHelmParams , domainNamespaceSelectionStrategy ,
162
- false , domain2Namespace );
163
-
164
153
// create and verify the domain
165
- logger .info ("Creating and verifying model in image domain" );
154
+ logger .info ("Creating a domain in non-operator namespace {1}" , domain2Namespace );
166
155
createDomain (domain2Namespace );
167
156
verifyDomainNotRunning (domain2Namespace );
157
+ logger .info ("WebLogic domain is not managed in non-operator namespace" );
168
158
}
169
159
170
160
/**
171
- * When installing the Operator via helm install,
172
- * set domainNamespaceSelectionStrategy to Dedicated for the Operator Helm Chart.
173
- * Make sure that the domains in the operator's target namespaces comes up.
174
- * Operator is installed in the test case testDedicatedModeDiffNamespace.
175
- * Create a WebLogic Domain with the same namespace as Operator's namespace.
176
- * Verify that the WebLogic domain whose namespace is same as Operator's namespace comes up.
161
+ * Create WebLogic Domain in a namespace (say op) that is same as
162
+ * Operator's namespace. Verify that the domain does come up and can be
163
+ * scaled up using Operator
177
164
*/
178
165
@ Test
179
- @ Order (2 )
180
- @ DisplayName ("Set domainNamespaceSelectionStrategy to Dedicated for the Operator Helm Chart and "
181
- + "verify that the domain deployed in the operator's namespace comes up" )
166
+ @ DisplayName ("Verify in Dedicated NamespaceSelectionStrategy domain on operator namespace gets started" )
182
167
void testDedicatedModeSameNamespace () {
183
- // create and verify the domain
184
- logger .info ("Creating and verifying model in image domain" );
168
+
169
+ // This test uses the operator restAPI to scale the doamin.
170
+ // To do this in OKD cluster, we need to expose the external service as
171
+ // route and set tls termination to passthrough
172
+ String opExternalSvc =
173
+ createRouteForOKD ("external-weblogic-operator-svc" , opNamespace );
174
+ // Patch the route just created to set tls termination to passthrough
175
+ setTlsTerminationForRoute ("external-weblogic-operator-svc" , opNamespace );
176
+
177
+ logger .info ("Creating a domain in perator namespace {1}" , domain1Namespace );
185
178
createDomain (domain1Namespace );
186
179
verifyDomainRunning (domain1Namespace );
187
- }
180
+ logger . info ( "WebLogic domain is managed in operator namespace Only" );
188
181
189
- /**
190
- * Test that when domainNamespaceSelectionStrategy is set to Dedicated for the Operator Helm Chart,
191
- * scaling up cluster-1 in domain1Namespace succeeds.
192
- */
193
- @ Test
194
- @ Order (3 )
195
- @ DisplayName ("Scale up cluster-1 in domain1Namespace and verify it succeeds" )
196
- void testDedicatedModeSameNamespaceScale () {
197
- // scale the cluster and check domain can be managed from the operator
182
+ // Scale up cluster-1 in domain1Namespace and verify it succeeds
198
183
int externalRestHttpsPort = getServiceNodePort (opNamespace , "external-weblogic-operator-svc" );
199
184
logger .info ("externalRestHttpsPort {0}" , externalRestHttpsPort );
200
185
@@ -206,84 +191,12 @@ void testDedicatedModeSameNamespaceScale() {
206
191
"" , null , null );
207
192
}
208
193
209
- /**
210
- * Test when domainNamespaceSelectionStrategy is set to Dedicated for the Operator Helm Chart and
211
- * the CRD with a lower than expected version is present, Operator fails with error
212
- * if it has no permission to overwrite the CRD.
213
- */
214
- @ Test
215
- @ Order (4 )
216
- @ Disabled ("Disable the test because the Operator has permission to overwrite the CRD" )
217
- @ DisplayName ("Create a CRD with a lower than expected version and verify that Operator fails with error" )
218
- void testDedicatedModeNlowerVersionCrd () {
219
- // delete existing CRD
220
- new Command ()
221
- .withParams (new CommandParams ()
222
- .command ("kubectl delete crd domains.weblogic.oracle --ignore-not-found" ))
223
- .execute ();
224
-
225
- // install a lower version of CRD, v2.6.0
226
- new Command ()
227
- .withParams (new CommandParams ()
228
- .command ("kubectl create -f " + ITTESTS_DIR + "/../kubernetes/crd/domain-v1beta1-crdv7-260.yaml" ))
229
- .execute ();
230
-
231
- try {
232
- // install latest version of operator and verify
233
- logger .info ("Installing and verifying operator" );
234
- installAndVerifyOperator (opNamespace , opNamespace + "-sa" ,
235
- false , 0 , opHelmParams , domainNamespaceSelectionStrategy ,
236
- false , domain2Namespace );
237
-
238
- // we expect installAndVerifyOperator fails with a lower than expected version of CRD
239
- fail ("Installing the Operator should fail with a lower than expected version of CRD" );
240
- } catch (Exception ex ) {
241
- logger .info ("Installing the Operator with a lower than expected version of CRD failed as expected" );
242
- } finally {
243
- // restore the test env
244
- uninstallOperatorAndVerify ();
245
- }
246
- }
247
-
248
- /**
249
- * Test when domainNamespaceSelectionStrategy is set to Dedicated for the Operator Helm Chart and
250
- * the CRD is not present or is deleted, Operator fails with error if it has no permission to create the CRD.
251
- */
252
- @ Test
253
- @ Order (5 )
254
- @ Disabled ("Disable the test because the Operator has permission to create the CRD" )
255
- @ DisplayName ("Delete the CRD and verify that Operator fails with error" )
256
- void testDedicatedModeNoCrd () {
257
- // delete existing CRD
258
- logger .info ("Delete existing CRD" );
259
- new Command ()
260
- .withParams (new CommandParams ()
261
- .command ("kubectl delete crd domains.weblogic.oracle --ignore-not-found" ))
262
- .execute ();
263
-
264
- try {
265
- // install and verify operator
266
- logger .info ("Installing and verifying operator" );
267
- installAndVerifyOperator (opNamespace , opNamespace + "-sa" ,
268
- false , 0 , opHelmParams , domainNamespaceSelectionStrategy ,
269
- false , domain2Namespace );
270
-
271
- // we expect installAndVerifyOperator fails when the CRD misses
272
- fail ("Installing the Operator should fail when the CRD misses" );
273
- } catch (Exception ex ) {
274
- logger .info ("Installing the Operator failed as expected when the CRD misses" );
275
- } finally {
276
- // restore the test env
277
- uninstallOperatorAndVerify ();
278
- }
279
- }
280
-
281
194
private void createDomain (String domainNamespace ) {
282
195
// create secret for admin credentials
283
196
logger .info ("Create secret for admin credentials" );
284
197
String adminSecretName = "weblogic-credentials" ;
285
- assertDoesNotThrow (() -> createSecretWithUsernamePassword (adminSecretName ,
286
- domainNamespace , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ),
198
+ assertDoesNotThrow (() -> createSecretWithUsernamePassword (adminSecretName , domainNamespace ,
199
+ ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ),
287
200
String .format ("create secret for admin credentials failed for %s" , adminSecretName ));
288
201
289
202
// create encryption secret
@@ -347,7 +260,7 @@ private void createDomainCrAndVerify(String domainNamespace,
347
260
.runtimeEncryptionSecret (encryptionSecretName ))));
348
261
setPodAntiAffinity (domain );
349
262
// create model in image domain
350
- logger .info ("Creating model in image domain {0} in namespace {1} using docker image {2}" ,
263
+ logger .info ("Creating mii domain {0} in namespace {1} using image {2}" ,
351
264
domainUid , domainNamespace , miiImage );
352
265
createDomainAndVerify (domain , domainNamespace );
353
266
}
@@ -396,7 +309,7 @@ private void uninstallOperatorAndVerify() {
396
309
String .format ("Delete service acct %s failed in namespace %s" , opServiceAccount , opNamespace ));
397
310
398
311
// delete secret/ocir-secret
399
- new Command ()
312
+ Command
400
313
.withParams (new CommandParams ()
401
314
.command ("kubectl delete secret/ocir-secret -n " + opNamespace + " --ignore-not-found" ))
402
315
.execute ();
0 commit comments