3
3
4
4
package oracle .weblogic .kubernetes ;
5
5
6
+ import java .io .File ;
7
+ import java .io .FileOutputStream ;
6
8
import java .net .InetAddress ;
7
9
import java .nio .file .Files ;
8
10
import java .nio .file .Path ;
14
16
import java .util .LinkedHashMap ;
15
17
import java .util .List ;
16
18
import java .util .Map ;
17
-
19
+ import java .util .Properties ;
20
+
21
+ import io .kubernetes .client .custom .Quantity ;
22
+ import oracle .weblogic .domain .Configuration ;
23
+ import oracle .weblogic .domain .CreateIfNotExists ;
24
+ import oracle .weblogic .domain .DomainCreationImage ;
25
+ import oracle .weblogic .domain .DomainOnPV ;
26
+ import oracle .weblogic .domain .DomainOnPVType ;
27
+ import oracle .weblogic .domain .DomainResource ;
18
28
import oracle .weblogic .kubernetes .actions .impl .primitive .Command ;
19
29
import oracle .weblogic .kubernetes .actions .impl .primitive .CommandParams ;
30
+ import oracle .weblogic .kubernetes .actions .impl .primitive .WitParams ;
20
31
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
21
32
import oracle .weblogic .kubernetes .annotations .Namespaces ;
22
33
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
33
44
import static java .nio .file .StandardCopyOption .REPLACE_EXISTING ;
34
45
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
35
46
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
47
+ import static oracle .weblogic .kubernetes .TestConstants .BASE_IMAGES_REPO_SECRET_NAME ;
36
48
import static oracle .weblogic .kubernetes .TestConstants .CLUSTER_VERSION ;
37
49
import static oracle .weblogic .kubernetes .TestConstants .DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX ;
38
50
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
51
+ import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_IMAGES_PREFIX ;
39
52
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_STATUS_CONDITION_COMPLETED_TYPE ;
40
53
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_VERSION ;
41
54
import static oracle .weblogic .kubernetes .TestConstants .ENCRYPION_PASSWORD_DEFAULT ;
48
61
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
49
62
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
50
63
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_WDT_MODEL_FILE ;
64
+ import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
51
65
import static oracle .weblogic .kubernetes .TestConstants .OLD_DOMAIN_VERSION ;
52
66
import static oracle .weblogic .kubernetes .TestConstants .RESULTS_ROOT ;
67
+ import static oracle .weblogic .kubernetes .TestConstants .RESULTS_TEMPFILE ;
53
68
import static oracle .weblogic .kubernetes .TestConstants .SKIP_CLEANUP ;
54
69
import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
55
70
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
66
81
import static oracle .weblogic .kubernetes .utils .ApplicationUtils .deployAndAccessApplication ;
67
82
import static oracle .weblogic .kubernetes .utils .ApplicationUtils .verifyAdminConsoleAccessible ;
68
83
import static oracle .weblogic .kubernetes .utils .ApplicationUtils .verifyAdminServerRESTAccess ;
84
+ import static oracle .weblogic .kubernetes .utils .AuxiliaryImageUtils .createAndPushAuxiliaryImage ;
69
85
import static oracle .weblogic .kubernetes .utils .AuxiliaryImageUtils .createPushAuxiliaryImageWithDomainConfig ;
70
86
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyPodsNotRolled ;
71
87
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
72
88
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressHostRouting ;
73
89
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .formatIPv6Host ;
90
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
91
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
74
92
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
93
+ import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
94
+ import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainResourceOnPv ;
75
95
import static oracle .weblogic .kubernetes .utils .DomainUtils .verifyDomainStatusConditionTypeDoesNotExist ;
76
96
import static oracle .weblogic .kubernetes .utils .FileUtils .generateFileFromTemplate ;
77
97
import static oracle .weblogic .kubernetes .utils .FileUtils .replaceStringInFile ;
98
+ import static oracle .weblogic .kubernetes .utils .FmwUtils .getConfiguration ;
99
+ import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyDomainReady ;
78
100
import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
79
101
import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
80
102
import static oracle .weblogic .kubernetes .utils .PatchDomainUtils .patchServerStartPolicy ;
81
103
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDeleted ;
82
104
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodReady ;
83
105
import static oracle .weblogic .kubernetes .utils .PodUtils .getExternalServicePodName ;
84
106
import static oracle .weblogic .kubernetes .utils .PodUtils .getPodCreationTime ;
107
+ import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
85
108
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
86
109
import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
87
110
import static oracle .weblogic .kubernetes .utils .UpgradeUtils .checkCrdVersion ;
@@ -162,6 +185,46 @@ void testOperatorUpgradeMiiDomainV8From409ToCurrent() {
162
185
installOperatorCreateMiiDomainAndUpgrade ("4.0.9" , OLD_DOMAIN_VERSION , DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX );
163
186
}
164
187
188
+ /**
189
+ * Operator upgrade from 4.2.9 to current with DPV domain in V9 schema.
190
+ */
191
+ @ Test
192
+ @ DisplayName ("Upgrade Operator from 4.2.9 to current" )
193
+ void testOperatorUpgradeDomainOnPVV9From429ToCurrent () {
194
+ logger .info ("Starting test testOperatorUpgradeDomainOnPVV9From429ToCurrent, domain v9 schema" );
195
+ installOperatorCreatesPvPvcWlsDomainAndUpgrade ("4.2.9" );
196
+ }
197
+
198
+ /**
199
+ * Operator upgrade from 4.2.8 to current with DPV domain in V9 schema.
200
+ */
201
+ @ Test
202
+ @ DisplayName ("Upgrade Operator from 4.2.8 to current" )
203
+ void testOperatorUpgradeDomainOnPVV9From428ToCurrent () {
204
+ logger .info ("Starting test testOperatorUpgradeDomainOnPVV9From428ToCurrent, domain v9 schema" );
205
+ installOperatorCreatesPvPvcWlsDomainAndUpgrade ("4.2.8" );
206
+ }
207
+
208
+ /**
209
+ * Operator upgrade from 4.1.8 to current with DPV domain in V9 schema.
210
+ */
211
+ @ Test
212
+ @ DisplayName ("Upgrade Operator from 4.1.8 to current" )
213
+ void testOperatorUpgradeDomainOnPVV9From418ToCurrent () {
214
+ logger .info ("Starting test testOperatorUpgradeDomainOnPVV9From418ToCurrent, domain v9 schema" );
215
+ installOperatorCreatesPvPvcWlsDomainAndUpgrade ("4.1.8" );
216
+ }
217
+
218
+ /**
219
+ * Operator upgrade from 4.1.7 to current with DPV domain in V9 schema.
220
+ */
221
+ @ Test
222
+ @ DisplayName ("Upgrade Operator from 4.1.7 to current" )
223
+ void testOperatorUpgradeDomainOnPVV9From417ToCurrent () {
224
+ logger .info ("Starting test testOperatorUpgradeDomainOnPVV9From417ToCurrent, domain v9 schema" );
225
+ installOperatorCreatesPvPvcWlsDomainAndUpgrade ("4.1.7" );
226
+ }
227
+
165
228
/**
166
229
* Upgrade Operator from 4.0.10 to current with Auxiliary image domain, V9 schema.
167
230
*/
@@ -172,7 +235,6 @@ void testOperatorUpgradeAuxDomainV9From4010ToCurrent() {
172
235
installOperatorCreateAuxDomainAndUpgrade ("4.0.10" , DOMAIN_VERSION );
173
236
}
174
237
175
-
176
238
/**
177
239
* Upgrade Operator from 4.1.7 to current with Mii domain in V8 schema.
178
240
*/
@@ -216,29 +278,6 @@ void testOperatorUpgradeMiiDomainV8From426ToCurrent() {
216
278
installOperatorCreateMiiDomainAndUpgrade ("4.2.6" , OLD_DOMAIN_VERSION , DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX );
217
279
}
218
280
219
- /**
220
- * Operator upgrade from 3.4.13 to current with Auxiliary Image Domain, V8 schema.
221
- * V9 schema is from Operator 4.0.
222
- */
223
- @ Test
224
- @ DisplayName ("Upgrade 3.4.13 Auxiliary Domain(v8 schema) Image to current" )
225
- void testOperatorUpgradeAuxDomainV8From3413ToCurrent () {
226
- logger .info ("Starting testOperatorUpgradeAuxDomainV8From3413ToCurrent "
227
- + "to upgrade Domain with Auxiliary Image with v8 schema to current" );
228
- installOperatorCreateAuxDomainAndUpgrade ("3.4.13" , OLD_DOMAIN_VERSION );
229
- }
230
-
231
- /**
232
- * Upgrade Operator from 3.4.12 to current with Mii domain in V8 schema.
233
- */
234
- @ Test
235
- @ DisplayName ("Upgrade 3.4.12 Mii Domain(v8 schema) Image to current" )
236
- void testOperatorUpgradeMiiDomainV8From3412ToCurrent () {
237
- logger .info ("Starting testOperatorWlsAuxDomainV8UpgradeFrom3412ToCurrent "
238
- + "to upgrade MII Domain with v8 schema to current" );
239
- installOperatorCreateMiiDomainAndUpgrade ("3.4.12" , OLD_DOMAIN_VERSION , DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX );
240
- }
241
-
242
281
/**
243
282
* Cleanup Kubernetes artifacts in the namespaces used by the test and
244
283
* delete CRD.
@@ -323,6 +362,93 @@ void installOperatorCreateAuxDomainAndUpgrade(String operatorVersion, String dom
323
362
scaleClusterUpAndDown (domainApiVersion );
324
363
}
325
364
365
+ void installOperatorCreatesPvPvcWlsDomainAndUpgrade (String operatorVersion ) {
366
+ final String storageClassName = "weblogic-domain-storage-class" ;
367
+ String domainHomePrefix = "/shared/" + domainNamespace + "/domains/" ;
368
+ final String clusterName = "cluster-1" ;
369
+ final String pvName = getUniqueName (domainUid + "-pv-" );
370
+ final String pvcName = getUniqueName (domainUid + "-pvc-" );
371
+ final int t3ChannelPort = getNextFreePort ();
372
+ final String wlsModelFile = "model-wlsdomain-onpv-simplified.yaml" ;
373
+
374
+ logger .info ("Upgrade version/{0} Auxiliary Domain(v9) to current" , operatorVersion );
375
+ installOldOperator (operatorVersion , opNamespace , domainNamespace );
376
+ createSecrets ();
377
+
378
+ // Create the repo secret to pull base WebLogic image
379
+ createBaseRepoSecret (domainNamespace );
380
+
381
+ // create a model property file
382
+ File wlsModelPropFile = createWdtPropertyFile ("wlsonpv-upgrade" );
383
+
384
+ // create domainCreationImage
385
+ String domainCreationImageName = DOMAIN_IMAGES_PREFIX + "wls-domain-on-pv-upgrade" ;
386
+ // create image with model and wdt installation files
387
+ WitParams witParams
388
+ = new WitParams ()
389
+ .modelImageName (domainCreationImageName )
390
+ .modelImageTag (MII_BASIC_IMAGE_TAG )
391
+ .modelFiles (Collections .singletonList (MODEL_DIR + "/" + wlsModelFile ))
392
+ .modelVariableFiles (Collections .singletonList (wlsModelPropFile .getAbsolutePath ()));
393
+ createAndPushAuxiliaryImage (domainCreationImageName , MII_BASIC_IMAGE_TAG , witParams );
394
+
395
+ DomainCreationImage domainCreationImage
396
+ = new DomainCreationImage ().image (domainCreationImageName + ":" + MII_BASIC_IMAGE_TAG );
397
+
398
+ // create a domain resource
399
+ logger .info ("Creating domain custom resource" );
400
+ Map <String , Quantity > pvCapacity = new HashMap <>();
401
+ pvCapacity .put ("storage" , new Quantity ("2Gi" ));
402
+
403
+ Map <String , Quantity > pvcRequest = new HashMap <>();
404
+ pvcRequest .put ("storage" , new Quantity ("2Gi" ));
405
+ Configuration configuration = null ;
406
+ if (OKE_CLUSTER ) {
407
+ configuration = getConfiguration (pvcName , pvcRequest , "oci-fss" );
408
+ } else {
409
+ configuration = getConfiguration (pvName , pvcName , pvCapacity , pvcRequest , storageClassName ,
410
+ this .getClass ().getSimpleName ());
411
+ }
412
+ configuration .getInitializeDomainOnPV ().domain (new DomainOnPV ()
413
+ .createMode (CreateIfNotExists .DOMAIN )
414
+ .domainCreationImages (Collections .singletonList (domainCreationImage ))
415
+ .domainType (DomainOnPVType .WLS ));
416
+ DomainResource domain = createDomainResourceOnPv (domainUid ,
417
+ domainNamespace ,
418
+ adminSecretName ,
419
+ clusterName ,
420
+ pvName ,
421
+ pvcName ,
422
+ new String []{BASE_IMAGES_REPO_SECRET_NAME },
423
+ domainHomePrefix ,
424
+ replicaCount ,
425
+ 0 ,
426
+ configuration );
427
+
428
+ // Set the inter-pod anti-affinity for the domain custom resource
429
+ setPodAntiAffinity (domain );
430
+
431
+ // create a domain custom resource and verify domain is created
432
+ createDomainAndVerify (domain , domainNamespace );
433
+
434
+ // verify that all servers are ready
435
+ verifyDomainReady (domainNamespace , domainUid , replicaCount , "nosuffix" );
436
+ LinkedHashMap <String , OffsetDateTime > pods = new LinkedHashMap <>();
437
+ pods .put (adminServerPodName , getPodCreationTime (domainNamespace , adminServerPodName ));
438
+ // get the creation time of the managed server pods before upgrading the operator
439
+ for (int i = 1 ; i <= replicaCount ; i ++) {
440
+ pods .put (managedServerPodNamePrefix + i , getPodCreationTime (domainNamespace , managedServerPodNamePrefix + i ));
441
+ }
442
+ // verify there is no status condition type Completed
443
+ // before upgrading to Latest
444
+ verifyDomainStatusConditionTypeDoesNotExist (domainUid , domainNamespace ,
445
+ DOMAIN_STATUS_CONDITION_COMPLETED_TYPE , DOMAIN_VERSION );
446
+ upgradeOperatorToCurrent (opNamespace );
447
+ checkDomainStatus (domainNamespace , domainUid );
448
+ verifyPodsNotRolled (domainNamespace , pods );
449
+ scaleClusterUpAndDown (clusterName );
450
+ }
451
+
326
452
// After upgrade scale up/down the cluster
327
453
private void scaleClusterUpAndDown (String domainApiVersion ) {
328
454
@@ -603,5 +729,25 @@ private void verifyDomain(String domainUidString, String domainNamespace, String
603
729
String .valueOf (serviceNodePort ), false );
604
730
}
605
731
}
732
+
733
+ private File createWdtPropertyFile (String wlsModelFilePrefix ) {
734
+
735
+ // create property file used with domain model file
736
+ Properties p = new Properties ();
737
+ p .setProperty ("adminUsername" , ADMIN_USERNAME_DEFAULT );
738
+ p .setProperty ("adminPassword" , ADMIN_PASSWORD_DEFAULT );
739
+
740
+ // create a model property file
741
+ File domainPropertiesFile = assertDoesNotThrow (() ->
742
+ File .createTempFile (wlsModelFilePrefix , ".properties" , new File (RESULTS_TEMPFILE )),
743
+ "Failed to create WLS model properties file" );
606
744
745
+ // create the property file
746
+ assertDoesNotThrow (() ->
747
+ p .store (new FileOutputStream (domainPropertiesFile ), "WLS properties file" ),
748
+ "Failed to write WLS properties file" );
749
+
750
+ return domainPropertiesFile ;
751
+ }
752
+
607
753
}
0 commit comments