6565import org .junit .jupiter .api .extension .ExecutionCondition ;
6666import org .junit .jupiter .api .extension .ExtendWith ;
6767import org .junit .jupiter .api .extension .ExtensionContext ;
68- import org .junit .jupiter .params .ParameterizedTest ;
69- import org .junit .jupiter .params .provider .EmptySource ;
70- import org .junit .jupiter .params .provider .ValueSource ;
7168
7269import static java .util .concurrent .TimeUnit .MINUTES ;
7370import static java .util .concurrent .TimeUnit .SECONDS ;
105102import static oracle .weblogic .kubernetes .actions .impl .Pod .getPod ;
106103import static oracle .weblogic .kubernetes .assertions .TestAssertions .podStateNotChanged ;
107104import static oracle .weblogic .kubernetes .assertions .TestAssertions .verifyRollingRestartOccurred ;
105+ import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyPodsNotRolled ;
108106import static oracle .weblogic .kubernetes .utils .CommonPatchTestUtils .patchDomainResource ;
109107import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodDoesNotExist ;
110108import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodExists ;
@@ -1098,21 +1096,19 @@ public void testDedicatedModeSameNamespaceScale() {
10981096 }
10991097
11001098 /**
1101- * Rerun a WebLogic domain's introspect job by explicitly initiating the introspection
1102- * using the sample script introspectDomain.sh script.
1103- * Test that after running introspectDomain.sh w/wo a introspectVersion value specified,
1104- * the introspection is explicitly initiating and introspectVersion in the domain is changed.
1105- * Use ParameterizedTest to test introspectVersion = "", "v1", "8v", "v.1"
1106- * Verify the introspector pod is created and runs
1107- * Verifies introspection is changed.
1108- * Verifies accessing sample application in admin server works .
1099+ * Update the introspectVersion of the domain resource using lifecycle script.
1100+ * Refer to kubernetes/samples/scripts/domain-lifecycle/ introspectDomain.sh
1101+ * The usecase update the introspectVersion by passing differnt value to -i
1102+ * option (non-numeic, non-numeric with space, no value) and make sure that
1103+ * the introspectVersion is updated accrodingly in both domain sepc level
1104+ * and server pod level.
1105+ * It also verifies the intospector job is started/stoped and none of the
1106+ * server pod is rolled since there is no change to resource configuration .
11091107 */
1108+ @ Test
11101109 @ Order (7 )
1111- @ ParameterizedTest
1112- @ EmptySource
1113- @ ValueSource (strings = {"v1" , "8v" , "v.1" })
11141110 @ DisplayName ("Test to use sample scripts to explicitly initiate introspection" )
1115- public void testInitiateIntrospection ( String introspectVersion ) {
1111+ public void tesIntrospectDomainScript ( ) {
11161112 final String adminServerName = "admin-server" ;
11171113 final String adminServerPodName = domainUid + "-" + adminServerName ;
11181114 final String managedServerNameBase = "managed-server" ;
@@ -1128,14 +1124,26 @@ public void testInitiateIntrospection(String introspectVersion) {
11281124 checkPodReadyAndServiceExists (managedServerPodNamePrefix + i , domainUid , introDomainNamespace );
11291125 }
11301126
1127+ // get the pod creation time stamps
1128+ LinkedHashMap <String , OffsetDateTime > pods = new LinkedHashMap <>();
1129+ // get the creation time of the admin server pod before patching
1130+ OffsetDateTime adminPodCreationTime = getPodCreationTime (introDomainNamespace , adminServerPodName );
1131+ pods .put (adminServerPodName , adminPodCreationTime );
1132+ // get the creation time of the managed server pods before patching
1133+ for (int i = 1 ; i <= replicaCount ; i ++) {
1134+ pods .put (managedServerPodNamePrefix + i ,
1135+ getPodCreationTime (introDomainNamespace , managedServerPodNamePrefix + i ));
1136+ }
1137+
11311138 // get introspectVersion before running introspectDomain.sh
1132- String introspectVersionBf =
1139+ String ivBefore =
11331140 assertDoesNotThrow (() -> getCurrentIntrospectVersion (domainUid , introDomainNamespace ));
1141+ logger .info ("introspectVersion before running the script {0}" ,ivBefore );
11341142
11351143 // use introspectDomain.sh to initiate introspection
1136- logger .info ("Initiate introspection with introspectDomain.sh script " );
1137- String extraParam = ( introspectVersion . isEmpty ()) ? "" : " -i " + introspectVersion ;
1138-
1144+ logger .info ("Initiate introspection with non numeric string (vX.Y) " );
1145+ String introspectVersion = "vX.Y" ;
1146+ String extraParam = " -i " + introspectVersion ;
11391147 assertDoesNotThrow (() -> executeLifecycleScript (INTROSPECT_DOMAIN_SCRIPT , extraParam ),
11401148 String .format ("Failed to run %s" , INTROSPECT_DOMAIN_SCRIPT ));
11411149
@@ -1145,16 +1153,95 @@ public void testInitiateIntrospection(String introspectVersion) {
11451153 checkPodDoesNotExist (introspectPodNameBase , domainUid , introDomainNamespace );
11461154
11471155 // get introspectVersion after running introspectDomain.sh
1148- String introspectVersionAf =
1149- assertDoesNotThrow (() -> getCurrentIntrospectVersion (domainUid , introDomainNamespace ));
1156+ String ivAfter = assertDoesNotThrow (() -> getCurrentIntrospectVersion (domainUid , introDomainNamespace ));
1157+ logger .info ("introspectVersion after running the script {0}" ,ivAfter );
1158+
1159+ // verify that introspectVersion is changed
1160+ assertTrue (ivAfter .equals (introspectVersion ),
1161+ "introspectVersion must change to " + introspectVersion );
11501162
1151- // verify that introspectVersion is changed after running introspectDomain.sh
1152- assertFalse (introspectVersionBf .equals (introspectVersionAf ),
1153- "introspectVersion should change from " + introspectVersionBf + " to " + introspectVersionAf );
1163+ assertFalse (ivAfter .equals (ivBefore ),
1164+ "introspectVersion should change from " + ivBefore + " to " + ivAfter );
11541165
11551166 // verify when a domain resource has spec.introspectVersion configured,
1156- // after a cluster is scaled up, new server pods have the label "weblogic.introspectVersion" set as well.
1167+ // after a introspectVersion is modified, new server pods have the label
1168+ // "weblogic.introspectVersion" set as well.
11571169 verifyIntrospectVersionLabelInPod (replicaCount );
1170+
1171+ // use introspectDomain.sh to initiate introspection
1172+ logger .info ("Initiate introspection with non numeric string with space" );
1173+ introspectVersion = "My Version" ;
1174+ String extraParam2 = " -i " + "\" " + introspectVersion + "\" " ;
1175+ assertDoesNotThrow (() -> executeLifecycleScript (INTROSPECT_DOMAIN_SCRIPT , extraParam2 ),
1176+ String .format ("Failed to run %s" , INTROSPECT_DOMAIN_SCRIPT ));
1177+
1178+ //verify the introspector pod is created and runs
1179+ introspectPodNameBase = getIntrospectJobName (domainUid );
1180+ checkPodExists (introspectPodNameBase , domainUid , introDomainNamespace );
1181+
1182+ // get introspectVersion after running introspectDomain.sh
1183+ ivAfter = assertDoesNotThrow (() -> getCurrentIntrospectVersion (domainUid , introDomainNamespace ));
1184+ logger .info ("introspectVersion after running the script {0}" ,ivAfter );
1185+
1186+ // verify that introspectVersion is changed
1187+ assertTrue (ivAfter .equals (introspectVersion ),
1188+ "introspectVersion must change to " + introspectVersion );
1189+
1190+ // use introspectDomain.sh to initiate introspection
1191+ // Since the current version is non-numeric the updated version is
1192+ // updated to 1
1193+ logger .info ("Initiate introspection with no explicit version(1)" );
1194+ assertDoesNotThrow (() -> executeLifecycleScript (INTROSPECT_DOMAIN_SCRIPT , "" ),
1195+ String .format ("Failed to run %s" , INTROSPECT_DOMAIN_SCRIPT ));
1196+
1197+ //verify the introspector pod is created and runs
1198+ introspectPodNameBase = getIntrospectJobName (domainUid );
1199+ checkPodExists (introspectPodNameBase , domainUid , introDomainNamespace );
1200+
1201+ // get introspectVersion after running introspectDomain.sh
1202+ ivAfter = assertDoesNotThrow (() -> getCurrentIntrospectVersion (domainUid , introDomainNamespace ));
1203+ logger .info ("introspectVersion after running the script {0}" ,ivAfter );
1204+
1205+ // verify that introspectVersion is changed
1206+ assertTrue (ivAfter .equals ("1" ), "introspectVersion must change to 1" );
1207+
1208+ // use introspectDomain.sh to initiate introspection
1209+ // Since the current version is 1, the updated version must be set to 2
1210+ logger .info ("Initiate introspection with no explicit version (2)" );
1211+ assertDoesNotThrow (() -> executeLifecycleScript (INTROSPECT_DOMAIN_SCRIPT , "" ),
1212+ String .format ("Failed to run %s" , INTROSPECT_DOMAIN_SCRIPT ));
1213+
1214+ //verify the introspector pod is created and runs
1215+ introspectPodNameBase = getIntrospectJobName (domainUid );
1216+ checkPodExists (introspectPodNameBase , domainUid , introDomainNamespace );
1217+
1218+ // get introspectVersion after running introspectDomain.sh
1219+ ivAfter = assertDoesNotThrow (() -> getCurrentIntrospectVersion (domainUid , introDomainNamespace ));
1220+ logger .info ("introspectVersion after running the script {0}" ,ivAfter );
1221+
1222+ // verify that introspectVersion is changed
1223+ assertTrue (ivAfter .equals ("2" ), "introspectVersion must change to 2" );
1224+
1225+ // use introspectDomain.sh to initiate introspection
1226+ // with an explicit introspection with -i parameter
1227+ logger .info ("Initiate introspection with explicit numeric version" );
1228+ String extraParam3 = " -i 101" ;
1229+ assertDoesNotThrow (() -> executeLifecycleScript (INTROSPECT_DOMAIN_SCRIPT , extraParam3 ),
1230+ String .format ("Failed to run %s" , INTROSPECT_DOMAIN_SCRIPT ));
1231+
1232+ //verify the introspector pod is created and runs
1233+ introspectPodNameBase = getIntrospectJobName (domainUid );
1234+ checkPodExists (introspectPodNameBase , domainUid , introDomainNamespace );
1235+
1236+ // get introspectVersion after running introspectDomain.sh
1237+ ivAfter = assertDoesNotThrow (() -> getCurrentIntrospectVersion (domainUid , introDomainNamespace ));
1238+ logger .info ("introspectVersion after running the script {0}" ,ivAfter );
1239+
1240+ // verify that introspectVersion is changed
1241+ assertTrue (ivAfter .equals ("101" ), "introspectVersion must change to 101" );
1242+
1243+ //verify the pods are not restarted in any introspectVersion update
1244+ verifyPodsNotRolled (introDomainNamespace , pods );
11581245 }
11591246
11601247 /**
0 commit comments