7171import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
7272import static oracle .weblogic .kubernetes .utils .DomainUtils .deleteDomainResource ;
7373import static oracle .weblogic .kubernetes .utils .FmwUtils .createDomainResourceSimplifyJrfPv ;
74- import static oracle .weblogic .kubernetes .utils .FmwUtils .createSimplifyJrfPvDomainAndRCU ;
7574import static oracle .weblogic .kubernetes .utils .FmwUtils .saveAndRestoreOpssWalletfileSecret ;
7675import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyDomainReady ;
7776import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
7877import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
7978import static oracle .weblogic .kubernetes .utils .JobUtils .getIntrospectJobName ;
8079import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
8180import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
81+ import static oracle .weblogic .kubernetes .utils .PatchDomainUtils .patchDomainResourceServerStartPolicy ;
82+ import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDeleted ;
8283import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
8384import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodExists ;
8485import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodLogContains ;
@@ -595,34 +596,18 @@ void testFmwDomainOnPvUserCreatesRCUMultiImages() {
595596 /**
596597 * Export the OPSS wallet file secret of Fmw domain from the previous run
597598 * CrateIfNotExists set to DomainAndRCU
598- * Use this OPSS wallet file secret to create Fmw domain on PV to connect to the same database
599+ * Use this OPSS wallet file secret to restart Fmw domain on PV to connect to the same database
599600 * Verify Pod is ready and service exists for both admin server and managed servers.
600601 */
601602 @ Test
602603 @ Order (6 )
603- @ DisplayName ("Create a FMW domain on PV with provided OPSS wallet file secret" )
604- void testFmwDomainOnPVwithProvidedOpss () {
605-
606- final String pvName = getUniqueName (domainUid3 + "-pv-" );
607- final String pvcName = getUniqueName (domainUid3 + "-pvc-" );
604+ @ DisplayName ("Restart a FMW domain on PV with provided OPSS wallet file secret" )
605+ void testReuseRCUschemaToRestartFmwDomain () {
608606
609607 saveAndRestoreOpssWalletfileSecret (domainNamespace , domainUid3 , opsswalletfileSecretName3 );
610- logger .info ("Deleting domain custom resource with namespace: {0}, domainUid {1}" , domainNamespace , domainUid3 );
611- deleteDomainResource (domainNamespace , domainUid3 );
612- try {
613- deleteDirectory (Paths .get ("/shared" ).toFile ());
614- } catch (IOException ioe ) {
615- logger .severe ("Failed to cleanup directory /shared" , ioe );
616- }
617- logger .info ("Creating domain custom resource with pvName: {0}" , pvName );
618- DomainResource domain = createSimplifyJrfPvDomainAndRCU (
619- domainUid3 , domainNamespace , adminSecretName3 ,
620- TEST_IMAGES_REPO_SECRET_NAME ,
621- rcuaccessSecretName3 ,
622- opsswalletpassSecretName3 , opsswalletfileSecretName3 ,
623- pvName , pvcName , domainCreationImages3 , null );
624-
625- createDomainAndVerify (domain , domainNamespace );
608+ shutdownDomain (domainUid3 );
609+ patchDomainWithWalletFileSecret (opsswalletfileSecretName3 , domainUid3 );
610+ startupDomain (domainUid3 );
626611
627612 // verify that all servers are ready
628613 verifyDomainReady (domainNamespace , domainUid3 , replicaCount , "nosuffix" );
@@ -892,5 +877,56 @@ private static void createModelConfigMap(String domainid, String cfgMapName) {
892877 assertTrue (cmCreated , String .format ("createConfigMap failed %s" , cfgMapName ));
893878 }
894879
880+ /**
881+ * Shutdown the domain by setting serverStartPolicy as "Never".
882+ */
883+ private void shutdownDomain (String domainUid ) {
884+ patchDomainResourceServerStartPolicy ("/spec/serverStartPolicy" , "Never" , domainNamespace , domainUid );
885+ logger .info ("Domain is patched to stop entire WebLogic domain" );
886+
887+ String adminServerPodName = domainUid + "-admin-server" ;
888+ String managedServerPrefix = domainUid + "-managed-server" ;
889+
890+ // make sure all the server pods are removed after patch
891+ checkPodDeleted (adminServerPodName , domainUid , domainNamespace );
892+ for (int i = 1 ; i <= replicaCount ; i ++) {
893+ checkPodDeleted (managedServerPrefix + i , domainUid , domainNamespace );
894+ }
895+
896+ logger .info ("Domain shutdown success" );
897+
898+ }
899+
900+ /**
901+ * Startup the domain by setting serverStartPolicy as "IfNeeded".
902+ */
903+ private void startupDomain (String domainUid ) {
904+ patchDomainResourceServerStartPolicy ("/spec/serverStartPolicy" , "IfNeeded" , domainNamespace ,
905+ domainUid );
906+ logger .info ("Domain is patched to start all servers in the domain" );
907+ }
908+
909+ /**
910+ * Patch the domain with opss wallet file secret.
911+ * @param opssWalletFileSecretName the name of opps wallet file secret
912+ * @return true if patching succeeds, false otherwise
913+ */
914+ private boolean patchDomainWithWalletFileSecret (String opssWalletFileSecretName , String domainUid ) {
915+ // construct the patch string for adding server pod resources
916+ StringBuffer patchStr = new StringBuffer ("[{" )
917+ .append ("\" op\" : \" add\" , " )
918+ .append ("\" path\" : \" /spec/configuration/opss/walletFileSecret\" , " )
919+ .append ("\" value\" : \" " )
920+ .append (opssWalletFileSecretName )
921+ .append ("\" }]" );
922+
923+ logger .info ("Adding opssWalletPasswordSecretName for domain {0} in namespace {1} using patch string: {2}" ,
924+ domainUid , domainNamespace , patchStr .toString ());
925+
926+ V1Patch patch = new V1Patch (new String (patchStr ));
927+
928+ return patchDomainCustomResource (domainUid , domainNamespace , patch , V1Patch .PATCH_FORMAT_JSON_PATCH );
929+ }
930+
895931
896932}
0 commit comments