@@ -187,25 +187,46 @@ public static void createDomainAndVerify(DomainResource domain,
187
187
public static void createDomainAndVerify (String domainUid , DomainResource domain ,
188
188
String domainNamespace , String adminServerPodName ,
189
189
String managedServerPodNamePrefix , int replicaCount ) {
190
+ createDomainAndVerify (domainUid , domain , domainNamespace , adminServerPodName , managedServerPodNamePrefix ,
191
+ replicaCount , true );
192
+ }
193
+
194
+ /**
195
+ * Create a domain in the specified namespace, wait up to five minutes until the domain exists and
196
+ * verify the servers are running.
197
+ *
198
+ * @param domainUid domain
199
+ * @param domain the oracle.weblogic.domain.DomainResource object to create domain custom resource
200
+ * @param domainNamespace namespace in which the domain will be created
201
+ * @param adminServerPodName admin server pod name
202
+ * @param managedServerPodNamePrefix managed server pod prefix
203
+ * @param replicaCount replica count
204
+ * @param verifyServerPods whether to verify server pods of the domain
205
+ */
206
+ public static void createDomainAndVerify (String domainUid , DomainResource domain ,
207
+ String domainNamespace , String adminServerPodName ,
208
+ String managedServerPodNamePrefix , int replicaCount ,
209
+ boolean verifyServerPods ) {
190
210
LoggingFacade logger = getLogger ();
191
211
192
212
// create domain and verify
193
213
createDomainAndVerify (domain , domainNamespace );
194
214
195
- // check that admin service/pod exists in the domain namespace
196
- logger .info ("Checking that admin service/pod {0} exists in namespace {1}" ,
197
- adminServerPodName , domainNamespace );
198
- checkPodReadyAndServiceExists (adminServerPodName , domainUid , domainNamespace );
215
+ if (verifyServerPods ) {
216
+ // check that admin service/pod exists in the domain namespace
217
+ logger .info ("Checking that admin service/pod {0} exists in namespace {1}" ,
218
+ adminServerPodName , domainNamespace );
219
+ checkPodReadyAndServiceExists (adminServerPodName , domainUid , domainNamespace );
199
220
200
- for (int i = 1 ; i <= replicaCount ; i ++) {
201
- String managedServerPodName = managedServerPodNamePrefix + i ;
221
+ for (int i = 1 ; i <= replicaCount ; i ++) {
222
+ String managedServerPodName = managedServerPodNamePrefix + i ;
202
223
203
- // check that ms service/pod exists in the domain namespace
204
- logger .info ("Checking that clustered ms service/pod {0} exists in namespace {1}" ,
205
- managedServerPodName , domainNamespace );
206
- checkPodReadyAndServiceExists (managedServerPodName , domainUid , domainNamespace );
224
+ // check that ms service/pod exists in the domain namespace
225
+ logger .info ("Checking that clustered ms service/pod {0} exists in namespace {1}" ,
226
+ managedServerPodName , domainNamespace );
227
+ checkPodReadyAndServiceExists (managedServerPodName , domainUid , domainNamespace );
228
+ }
207
229
}
208
-
209
230
}
210
231
211
232
/**
@@ -643,6 +664,109 @@ public static DomainResource createDomainOnPvUsingWdt(String domainUid,
643
664
return domain ;
644
665
}
645
666
667
+ /**
668
+ * Create a domain in PV using WDT.
669
+ *
670
+ * @param domainUid uid of the domain
671
+ * @param domainNamespace namespace in which the domain will be created
672
+ * @param wlSecretName WLS secret name
673
+ * @param clusterName WLS domain cluster name
674
+ * @param replicaCount domain replica count
675
+ * @param testClassName the test class name calling this method
676
+ * @param wdtModelFile WDT model file to create the domain
677
+ * @param verifyServerPods whether to verify the server pods
678
+ * @return oracle.weblogic.domain.Domain objects
679
+ */
680
+ public static DomainResource createDomainOnPvUsingWdt (String domainUid ,
681
+ String domainNamespace ,
682
+ String wlSecretName ,
683
+ String clusterName ,
684
+ int replicaCount ,
685
+ String testClassName ,
686
+ String wdtModelFile ,
687
+ boolean verifyServerPods ) {
688
+
689
+ int t3ChannelPort = getNextFreePort ();
690
+
691
+ final String pvName = getUniqueName (domainUid + "-pv-" ); // name of the persistent volume
692
+ final String pvcName = getUniqueName (domainUid + "-pvc-" ); // name of the persistent volume claim
693
+
694
+ // create pull secrets for WebLogic image when running in non Kind Kubernetes cluster
695
+ // this secret is used only for non-kind cluster
696
+ createBaseRepoSecret (domainNamespace );
697
+
698
+ // create WebLogic domain credential secret
699
+ createSecretWithUsernamePassword (wlSecretName , domainNamespace , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT );
700
+
701
+ // create persistent volume and persistent volume claim for domain
702
+ // these resources should be labeled with domainUid for cleanup after testing
703
+
704
+ createPV (pvName , domainUid , testClassName );
705
+ createPVC (pvName , pvcName , domainUid , domainNamespace );
706
+
707
+ String labelSelector = String .format ("weblogic.domainUid in (%s)" , domainUid );
708
+ LoggingFacade logger = getLogger ();
709
+ // check the persistent volume and persistent volume claim exist
710
+ testUntil (
711
+ assertDoesNotThrow (() -> pvExists (pvName , labelSelector ),
712
+ String .format ("pvExists failed with ApiException when checking pv %s" , pvName )),
713
+ logger ,
714
+ "persistent volume {0} exists" ,
715
+ pvName );
716
+
717
+ testUntil (
718
+ assertDoesNotThrow (() -> pvcExists (pvcName , domainNamespace ),
719
+ String .format ("pvcExists failed with ApiException when checking pvc %s in namespace %s" ,
720
+ pvcName , domainNamespace )),
721
+ logger ,
722
+ "persistent volume claim {0} exists in namespace {1}" ,
723
+ pvcName ,
724
+ domainNamespace );
725
+
726
+
727
+ // create a temporary WebLogic domain property file as a input for WDT model file
728
+ File domainPropertiesFile = assertDoesNotThrow (() -> createTempFile ("domainonpv" + domainUid , "properties" ),
729
+ "Failed to create domain properties file" );
730
+
731
+ Properties p = new Properties ();
732
+ p .setProperty ("adminUsername" , ADMIN_USERNAME_DEFAULT );
733
+ p .setProperty ("adminPassword" , ADMIN_PASSWORD_DEFAULT );
734
+ p .setProperty ("domainName" , domainUid );
735
+ p .setProperty ("adminServerName" , ADMIN_SERVER_NAME_BASE );
736
+ p .setProperty ("productionModeEnabled" , "true" );
737
+ p .setProperty ("clusterName" , clusterName );
738
+ p .setProperty ("configuredManagedServerCount" , "4" );
739
+ p .setProperty ("managedServerNameBase" , MANAGED_SERVER_NAME_BASE );
740
+ p .setProperty ("t3ChannelPort" , Integer .toString (t3ChannelPort ));
741
+ p .setProperty ("t3PublicAddress" , K8S_NODEPORT_HOST );
742
+ p .setProperty ("managedServerPort" , "8001" );
743
+ p .setProperty ("adminServerSslPort" , "7002" );
744
+ assertDoesNotThrow (() ->
745
+ p .store (new FileOutputStream (domainPropertiesFile ), "WDT properties file" ),
746
+ "Failed to write domain properties file" );
747
+
748
+ // shell script to download WDT and run the WDT createDomain script
749
+ Path wdtScript = get (RESOURCE_DIR , "bash-scripts" , "setup_wdt.sh" );
750
+
751
+ // create configmap and domain in persistent volume using WDT
752
+ runCreateDomainOnPVJobUsingWdt (wdtScript , get (RESOURCE_DIR , "wdt-models" , wdtModelFile ),
753
+ domainPropertiesFile .toPath (),
754
+ domainUid , pvName , pvcName , domainNamespace , testClassName );
755
+
756
+ DomainResource domain = createDomainResourceForDomainOnPV (domainUid , domainNamespace , wlSecretName , pvName , pvcName ,
757
+ clusterName , replicaCount );
758
+
759
+ // Verify the domain custom resource is created.
760
+ // Also verify the admin server pod and managed server pods are up and running.
761
+ if (verifyServerPods ) {
762
+ createDomainAndVerify (domainUid , domain , domainNamespace , domainUid + "-" + ADMIN_SERVER_NAME_BASE ,
763
+ domainUid + "-" + MANAGED_SERVER_NAME_BASE , replicaCount );
764
+ } else {
765
+ createDomainAndVerify (domain , domainNamespace );
766
+ }
767
+ return domain ;
768
+ }
769
+
646
770
/**
647
771
* Create domain with domain-on-pv type and verify the domain is created.
648
772
* Also verify the admin server pod and managed server pods are up and running.
@@ -964,6 +1088,57 @@ public static DomainResource createAndVerifyDomainInImageUsingWdt(String domainU
964
1088
clusterName , replicaCount );
965
1089
}
966
1090
1091
+ /**
1092
+ * Create a WebLogic domain in image using WDT.
1093
+ *
1094
+ * @param domainUid domain uid
1095
+ * @param domainNamespace namespace in which the domain to be created
1096
+ * @param wdtModelFileForDomainInImage WDT model file used to create domain image
1097
+ * @param appSrcDirList list of the app src in WDT model file
1098
+ * @param propertyFiles list of property files
1099
+ * @param wlSecretName wls admin secret name
1100
+ * @param clusterName cluster name
1101
+ * @param replicaCount replica count of the cluster
1102
+ * @return oracle.weblogic.domain.DomainResource object
1103
+ */
1104
+ public static DomainResource createDomainInImageUsingWdt (String domainUid ,
1105
+ String domainNamespace ,
1106
+ String wdtModelFileForDomainInImage ,
1107
+ List <String > appSrcDirList ,
1108
+ List <String > propertyFiles ,
1109
+ String wlSecretName ,
1110
+ String clusterName ,
1111
+ int replicaCount ) {
1112
+
1113
+ // create secret for admin credentials
1114
+ getLogger ().info ("Create secret for admin credentials" );
1115
+ createSecretWithUsernamePassword (wlSecretName , domainNamespace , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT );
1116
+
1117
+ // create image with model files
1118
+ getLogger ().info ("Creating image with model file and verify" );
1119
+ String domainInImageWithWDTImage = createImageAndVerify ("domaininimage-wdtimage" ,
1120
+ Collections .singletonList (MODEL_DIR + "/" + wdtModelFileForDomainInImage ), appSrcDirList ,
1121
+ propertyFiles ,
1122
+ WEBLOGIC_IMAGE_NAME , WEBLOGIC_IMAGE_TAG , WLS_DOMAIN_TYPE , false ,
1123
+ domainUid , false );
1124
+
1125
+ // repo login and push image to registry if necessary
1126
+ imageRepoLoginAndPushImageToRegistry (domainInImageWithWDTImage );
1127
+
1128
+ // Create the repo secret to pull the image
1129
+ // this secret is used only for non-kind cluster
1130
+ createTestRepoSecret (domainNamespace );
1131
+
1132
+ // create the domain custom resource
1133
+ DomainResource domain = createDomainResourceForDomainInImage (domainUid , domainNamespace , domainInImageWithWDTImage ,
1134
+ wlSecretName , clusterName , replicaCount );
1135
+
1136
+ // create domain and verify
1137
+ createDomainAndVerify (domain , domainNamespace );
1138
+
1139
+ return domain ;
1140
+ }
1141
+
967
1142
/**
968
1143
* Create domain resource with domain-in-image type.
969
1144
*
0 commit comments