1
- // Copyright (c) 2020, 2024 , Oracle and/or its affiliates.
1
+ // Copyright (c) 2020, 2025 , Oracle and/or its affiliates.
2
2
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3
3
4
4
package oracle .weblogic .kubernetes ;
19
19
import java .util .Properties ;
20
20
21
21
import io .kubernetes .client .custom .Quantity ;
22
- import io .kubernetes .client .openapi .models .V1EnvVar ;
23
- import io .kubernetes .client .openapi .models .V1LocalObjectReference ;
24
- import io .kubernetes .client .openapi .models .V1ObjectMeta ;
25
- import oracle .weblogic .domain .AdminServer ;
26
- import oracle .weblogic .domain .AdminService ;
27
- import oracle .weblogic .domain .Channel ;
28
22
import oracle .weblogic .domain .Configuration ;
29
23
import oracle .weblogic .domain .CreateIfNotExists ;
30
24
import oracle .weblogic .domain .DomainCreationImage ;
31
25
import oracle .weblogic .domain .DomainOnPV ;
32
26
import oracle .weblogic .domain .DomainOnPVType ;
33
27
import oracle .weblogic .domain .DomainResource ;
34
- import oracle .weblogic .domain .DomainSpec ;
35
- import oracle .weblogic .domain .Model ;
36
- import oracle .weblogic .domain .ServerPod ;
37
28
import oracle .weblogic .kubernetes .actions .impl .primitive .Command ;
38
29
import oracle .weblogic .kubernetes .actions .impl .primitive .CommandParams ;
39
30
import oracle .weblogic .kubernetes .actions .impl .primitive .WitParams ;
66
57
import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
67
58
import static oracle .weblogic .kubernetes .TestConstants .KIND_CLUSTER ;
68
59
import static oracle .weblogic .kubernetes .TestConstants .KUBERNETES_CLI ;
69
- import static oracle .weblogic .kubernetes .TestConstants .MII_AUXILIARY_IMAGE_NAME ;
70
- import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_APP_NAME ;
71
60
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
72
61
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
73
- import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_WDT_MODEL_FILE ;
74
62
import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
75
63
import static oracle .weblogic .kubernetes .TestConstants .OLD_DOMAIN_VERSION ;
76
64
import static oracle .weblogic .kubernetes .TestConstants .RESULTS_ROOT ;
77
65
import static oracle .weblogic .kubernetes .TestConstants .RESULTS_TEMPFILE ;
78
66
import static oracle .weblogic .kubernetes .TestConstants .SKIP_CLEANUP ;
79
- import static oracle .weblogic .kubernetes .TestConstants .SSL_PROPERTIES ;
80
- import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
81
67
import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
82
68
import static oracle .weblogic .kubernetes .TestConstants .WDT_BASIC_IMAGE_NAME ;
83
69
import static oracle .weblogic .kubernetes .TestConstants .WDT_BASIC_IMAGE_TAG ;
84
- import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
85
70
import static oracle .weblogic .kubernetes .TestConstants .WLSIMG_BUILDER ;
86
71
import static oracle .weblogic .kubernetes .TestConstants .WLSIMG_BUILDER_DEFAULT ;
87
- import static oracle .weblogic .kubernetes .actions .ActionConstants .ARCHIVE_DIR ;
88
72
import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
89
73
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
90
- import static oracle .weblogic .kubernetes .actions .ActionConstants .WORK_DIR ;
91
- import static oracle .weblogic .kubernetes .actions .TestActions .createDomainCustomResource ;
92
74
import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
93
75
import static oracle .weblogic .kubernetes .actions .TestActions .scaleCluster ;
94
- import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainExists ;
95
76
import static oracle .weblogic .kubernetes .utils .ApplicationUtils .collectAppAvailability ;
96
77
import static oracle .weblogic .kubernetes .utils .ApplicationUtils .deployAndAccessApplication ;
97
78
import static oracle .weblogic .kubernetes .utils .ApplicationUtils .verifyAdminConsoleAccessible ;
98
79
import static oracle .weblogic .kubernetes .utils .ApplicationUtils .verifyAdminServerRESTAccess ;
99
80
import static oracle .weblogic .kubernetes .utils .AuxiliaryImageUtils .createAndPushAuxiliaryImage ;
100
- import static oracle .weblogic .kubernetes .utils .AuxiliaryImageUtils .createPushAuxiliaryImageWithDomainConfig ;
101
81
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyPodsNotRolled ;
102
82
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
103
83
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressHostRouting ;
104
84
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .formatIPv6Host ;
105
- import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
106
85
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
107
86
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
108
87
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
109
88
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainResourceOnPv ;
110
89
import static oracle .weblogic .kubernetes .utils .DomainUtils .verifyDomainStatusConditionTypeDoesNotExist ;
111
- import static oracle .weblogic .kubernetes .utils .FileUtils .generateFileFromTemplate ;
112
90
import static oracle .weblogic .kubernetes .utils .FileUtils .replaceStringInFile ;
113
91
import static oracle .weblogic .kubernetes .utils .FmwUtils .getConfiguration ;
114
92
import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyDomainReady ;
@@ -161,8 +139,6 @@ class ItOperatorWlsUpgrade {
161
139
private String domainNamespace ;
162
140
private Path srcDomainYaml = null ;
163
141
private Path destDomainYaml = null ;
164
- private static String miiAuxiliaryImageTag = "aux-explict-upgrade" ;
165
- private static final String miiAuxiliaryImage = MII_AUXILIARY_IMAGE_NAME + ":" + miiAuxiliaryImageTag ;
166
142
private static String hostHeader ;
167
143
168
144
/**
@@ -181,7 +157,7 @@ void beforeEach(@Namespaces(2) List<String> namespaces) {
181
157
}
182
158
183
159
/**
184
- * Does some initialization of logger, conditionfactory, etc common
160
+ * Does some initialization of logger, conditionfactory, etc. common
185
161
* to all test methods.
186
162
*/
187
163
@ BeforeAll
@@ -320,73 +296,6 @@ void tearDown() {
320
296
}
321
297
}
322
298
323
- void upgradeWlsAuxDomain (String oldVersion ) {
324
- logger .info ("Upgrade version/{0} Auxiliary Domain(v8) to current" , oldVersion );
325
- installOldOperator (oldVersion ,opNamespace ,domainNamespace );
326
- createSecrets ();
327
-
328
- // Create the repo secret to pull base WebLogic image
329
- createBaseRepoSecret (domainNamespace );
330
-
331
- // Creating an aux image domain with v8 version
332
- List <String > archiveList = Collections .singletonList (ARCHIVE_DIR + "/" + MII_BASIC_APP_NAME + ".zip" );
333
- List <String > modelList = new ArrayList <>();
334
- modelList .add (MODEL_DIR + "/" + MII_BASIC_WDT_MODEL_FILE );
335
- modelList .add (MODEL_DIR + "/model.jms2.yaml" );
336
- logger .info ("creating auxiliary image {0}:{1} using imagetool.sh " , miiAuxiliaryImage , MII_BASIC_IMAGE_TAG );
337
- createPushAuxiliaryImageWithDomainConfig (MII_AUXILIARY_IMAGE_NAME , miiAuxiliaryImageTag , archiveList , modelList );
338
-
339
- // Generate a v8 version of domain.yaml file from a template file
340
- // by replacing domain namespace, domain uid, base image and aux image
341
- String auxImage = MII_AUXILIARY_IMAGE_NAME + ":" + miiAuxiliaryImageTag ;
342
- Map <String , String > templateMap = new HashMap <>();
343
- templateMap .put ("DOMAIN_NS" , domainNamespace );
344
- templateMap .put ("DOMAIN_UID" , domainUid );
345
- templateMap .put ("AUX_IMAGE" , auxImage );
346
- templateMap .put ("BASE_IMAGE" , WEBLOGIC_IMAGE_TO_USE_IN_SPEC );
347
- templateMap .put ("API_VERSION" , "v8" );
348
- Path srcDomainFile = Paths .get (RESOURCE_DIR ,
349
- "upgrade" , "auxilary.single.image.template.yaml" );
350
- Path targetDomainFile = assertDoesNotThrow (
351
- () -> generateFileFromTemplate (srcDomainFile .toString (),
352
- "domain.yaml" , templateMap ));
353
- logger .info ("Generated Domain Resource file {0}" , targetDomainFile );
354
-
355
- // run KUBERNETES_CLI to create the domain
356
- logger .info ("Run " + KUBERNETES_CLI + " to create the domain" );
357
- CommandParams params = new CommandParams ().defaults ();
358
- params .command (KUBERNETES_CLI + " apply -f "
359
- + Paths .get (WORK_DIR + "/domain.yaml" ));
360
- boolean result = Command .withParams (params ).execute ();
361
- assertTrue (result , "Failed to create domain custom resource" );
362
-
363
- // wait for the domain to exist
364
- logger .info ("Checking for domain custom resource in namespace {0}" , domainNamespace );
365
- testUntil (
366
- domainExists (domainUid , "v8" , domainNamespace ),
367
- logger ,
368
- "domain {0} to be created in namespace {1}" ,
369
- domainUid ,
370
- domainNamespace );
371
- checkDomainStarted (domainUid , domainNamespace );
372
- LinkedHashMap <String , OffsetDateTime > pods = new LinkedHashMap <>();
373
- pods .put (adminServerPodName , getPodCreationTime (domainNamespace , adminServerPodName ));
374
- // get the creation time of the managed server pods before upgrading the operator
375
- for (int i = 1 ; i <= replicaCount ; i ++) {
376
- pods .put (managedServerPodNamePrefix + i , getPodCreationTime (domainNamespace , managedServerPodNamePrefix + i ));
377
- }
378
- // verify there is no status condition type Completed
379
- // before upgrading to Latest
380
- verifyDomainStatusConditionTypeDoesNotExist (domainUid , domainNamespace ,
381
- DOMAIN_STATUS_CONDITION_COMPLETED_TYPE , OLD_DOMAIN_VERSION );
382
- upgradeOperatorToCurrent (opNamespace );
383
- checkDomainStatus (domainNamespace ,domainUid );
384
- verifyPodsNotRolled (domainNamespace , pods );
385
- scaleClusterUpAndDown ();
386
- }
387
-
388
-
389
-
390
299
// After upgrade scale up/down the cluster
391
300
private void scaleClusterUpAndDown () {
392
301
String clusterName = domainUid + "-" + "cluster-1" ;
@@ -464,12 +373,10 @@ private void upgradeOperatorAndVerify(String opNamespace, String domainNamespace
464
373
logger .info ("Start a thread to keep track of application availability" );
465
374
Thread accountingThread =
466
375
new Thread (
467
- () -> {
468
- collectAppAvailability (
469
- domainNamespace , opNamespace , appAvailability ,
470
- adminServerPodName , managedServerPodNamePrefix ,
471
- replicaCount , "7001" , "8001" , "testwebapp/index.jsp" );
472
- });
376
+ () -> collectAppAvailability (
377
+ domainNamespace , opNamespace , appAvailability ,
378
+ adminServerPodName , managedServerPodNamePrefix ,
379
+ replicaCount , "7001" , "8001" , "testwebapp/index.jsp" ));
473
380
accountingThread .start ();
474
381
try {
475
382
// upgrade to current operator
@@ -581,94 +488,6 @@ private void restartDomain(String domainUid, String domainNamespace) {
581
488
checkDomainStarted (domainUid , domainNamespace );
582
489
}
583
490
584
- private void createDomainResource (
585
- String domainNamespace ,
586
- String domVersion ,
587
- String domainHomeSourceType ,
588
- String domainImage ) {
589
-
590
- String domApiVersion = "weblogic.oracle/" + domVersion ;
591
- logger .info ("Default Domain API version {0}" , DOMAIN_API_VERSION );
592
- logger .info ("Domain API version selected {0}" , domApiVersion );
593
- logger .info ("Domain Image name selected {0}" , domainImage );
594
- logger .info ("Create domain resource for domainUid {0} in namespace {1}" ,
595
- domainUid , domainNamespace );
596
-
597
- // create encryption secret
598
- logger .info ("Create encryption secret" );
599
- String encryptionSecretName = "encryptionsecret" ;
600
- createSecretWithUsernamePassword (encryptionSecretName , domainNamespace ,
601
- "weblogicenc" , "weblogicenc" );
602
- DomainResource domain = new DomainResource ()
603
- .apiVersion (domApiVersion )
604
- .kind ("Domain" )
605
- .metadata (new V1ObjectMeta ()
606
- .name (domainUid )
607
- .namespace (domainNamespace ))
608
- .spec (new DomainSpec ()
609
- .domainUid (domainUid )
610
- .domainHomeSourceType (domainHomeSourceType )
611
- .image (domainImage )
612
- .addImagePullSecretsItem (new V1LocalObjectReference ()
613
- .name (TEST_IMAGES_REPO_SECRET_NAME ))
614
- .webLogicCredentialsSecret (new V1LocalObjectReference ()
615
- .name (adminSecretName ))
616
- .includeServerOutInPodLog (true )
617
- .serverStartPolicy ("weblogic.oracle/v8" .equals (domApiVersion ) ? "IF_NEEDED" : "IfNeeded" )
618
- .serverPod (new ServerPod ()
619
- .addEnvItem (new V1EnvVar ()
620
- .name ("JAVA_OPTIONS" )
621
- .value (SSL_PROPERTIES ))
622
- .addEnvItem (new V1EnvVar ()
623
- .name ("USER_MEM_ARGS" )
624
- .value ("-Djava.security.egd=file:/dev/./urandom " )))
625
- .adminServer (new AdminServer ()
626
- .adminService (new AdminService ()
627
- .addChannelsItem (new Channel ()
628
- .channelName ("default" )
629
- .nodePort (getNextFreePort ()))))
630
- .configuration (new Configuration ()
631
- .model (new Model ()
632
- .runtimeEncryptionSecret (encryptionSecretName )
633
- .domainType ("WLS" ))
634
- .introspectorJobActiveDeadlineSeconds (300L )));
635
- boolean domCreated = assertDoesNotThrow (() -> createDomainCustomResource (domain , domVersion ),
636
- String .format ("Create domain custom resource failed with ApiException for %s in namespace %s" ,
637
- domainUid , domainNamespace ));
638
- assertTrue (domCreated ,
639
- String .format ("Create domain custom resource failed with ApiException "
640
- + "for %s in namespace %s" , domainUid , domainNamespace ));
641
- setPodAntiAffinity (domain );
642
- removePortForwardingAttribute (domainNamespace ,domainUid );
643
- }
644
-
645
- // Remove the artifact adminChannelPortForwardingEnabled from domain resource
646
- // if exist, so that the Operator release default will be effective.
647
- // e.g. in Release 3.3.x the default is false, but 4.x.x onward it is true
648
- // However in release(s) lower to 3.3.x, the CRD does not contain this attribute
649
- // so the patch command to remove this attribute fails. So we do not assert
650
- // the result of patch command
651
- private void removePortForwardingAttribute (
652
- String domainNamespace , String domainUid ) {
653
-
654
- StringBuffer patchStr = new StringBuffer ("[{" );
655
- patchStr .append ("\" op\" : \" remove\" ," )
656
- .append (" \" path\" : \" /spec/adminServer/adminChannelPortForwardingEnabled\" " )
657
- .append ("}]" );
658
- logger .info ("The patch String {0}" , patchStr );
659
- StringBuffer commandStr = new StringBuffer (KUBERNETES_CLI + " patch domain " );
660
- commandStr .append (domainUid )
661
- .append (" -n " + domainNamespace )
662
- .append (" --type 'json' -p='" )
663
- .append (patchStr )
664
- .append ("'" );
665
- logger .info ("The Command String: {0}" , commandStr );
666
- CommandParams params = new CommandParams ().defaults ();
667
-
668
- params .command (new String (commandStr ));
669
- Command .withParams (params ).execute ();
670
- }
671
-
672
491
/**
673
492
* Replace the fields in domain yaml file with testing attributes.
674
493
* For example, namespace, domainUid, and image. Then create domain using
@@ -844,7 +663,7 @@ void installOperatorCreatesPvPvcWlsDomainAndUpgrade(String operatorVersion) {
844
663
upgradeOperatorToCurrent (opNamespace );
845
664
checkDomainStatus (domainNamespace , domainUid );
846
665
verifyPodsNotRolled (domainNamespace , pods );
847
- scaleClusterUpAndDown (clusterName );
666
+ scaleClusterUpAndDown (domainUid + "-" + clusterName );
848
667
}
849
668
850
669
0 commit comments