65
65
import org .junit .jupiter .api .extension .ExecutionCondition ;
66
66
import org .junit .jupiter .api .extension .ExtendWith ;
67
67
import 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 ;
71
68
72
69
import static java .util .concurrent .TimeUnit .MINUTES ;
73
70
import static java .util .concurrent .TimeUnit .SECONDS ;
105
102
import static oracle .weblogic .kubernetes .actions .impl .Pod .getPod ;
106
103
import static oracle .weblogic .kubernetes .assertions .TestAssertions .podStateNotChanged ;
107
104
import static oracle .weblogic .kubernetes .assertions .TestAssertions .verifyRollingRestartOccurred ;
105
+ import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyPodsNotRolled ;
108
106
import static oracle .weblogic .kubernetes .utils .CommonPatchTestUtils .patchDomainResource ;
109
107
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodDoesNotExist ;
110
108
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodExists ;
@@ -1098,21 +1096,19 @@ public void testDedicatedModeSameNamespaceScale() {
1098
1096
}
1099
1097
1100
1098
/**
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 .
1109
1107
*/
1108
+ @ Test
1110
1109
@ Order (7 )
1111
- @ ParameterizedTest
1112
- @ EmptySource
1113
- @ ValueSource (strings = {"v1" , "8v" , "v.1" })
1114
1110
@ DisplayName ("Test to use sample scripts to explicitly initiate introspection" )
1115
- public void testInitiateIntrospection ( String introspectVersion ) {
1111
+ public void tesIntrospectDomainScript ( ) {
1116
1112
final String adminServerName = "admin-server" ;
1117
1113
final String adminServerPodName = domainUid + "-" + adminServerName ;
1118
1114
final String managedServerNameBase = "managed-server" ;
@@ -1128,14 +1124,26 @@ public void testInitiateIntrospection(String introspectVersion) {
1128
1124
checkPodReadyAndServiceExists (managedServerPodNamePrefix + i , domainUid , introDomainNamespace );
1129
1125
}
1130
1126
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
+
1131
1138
// get introspectVersion before running introspectDomain.sh
1132
- String introspectVersionBf =
1139
+ String ivBefore =
1133
1140
assertDoesNotThrow (() -> getCurrentIntrospectVersion (domainUid , introDomainNamespace ));
1141
+ logger .info ("introspectVersion before running the script {0}" ,ivBefore );
1134
1142
1135
1143
// 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 ;
1139
1147
assertDoesNotThrow (() -> executeLifecycleScript (INTROSPECT_DOMAIN_SCRIPT , extraParam ),
1140
1148
String .format ("Failed to run %s" , INTROSPECT_DOMAIN_SCRIPT ));
1141
1149
@@ -1145,16 +1153,95 @@ public void testInitiateIntrospection(String introspectVersion) {
1145
1153
checkPodDoesNotExist (introspectPodNameBase , domainUid , introDomainNamespace );
1146
1154
1147
1155
// 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 );
1150
1162
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 );
1154
1165
1155
1166
// 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.
1157
1169
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 );
1158
1245
}
1159
1246
1160
1247
/**
0 commit comments