33
44package oracle .weblogic .kubernetes ;
55
6+ import java .time .OffsetDateTime ;
67import java .util .ArrayList ;
8+ import java .util .LinkedHashMap ;
79import java .util .List ;
810
911import io .kubernetes .client .openapi .models .V1Container ;
2628import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
2729import oracle .weblogic .kubernetes .annotations .Namespaces ;
2830import oracle .weblogic .kubernetes .logging .LoggingFacade ;
29- import org .junit .jupiter .api .AfterAll ;
3031import org .junit .jupiter .api .BeforeAll ;
3132import org .junit .jupiter .api .DisplayName ;
3233import org .junit .jupiter .api .Tag ;
4041import static oracle .weblogic .kubernetes .TestConstants .OCIR_SECRET_NAME ;
4142import static oracle .weblogic .kubernetes .TestConstants .WLS_DOMAIN_TYPE ;
4243import static oracle .weblogic .kubernetes .actions .TestActions .getPodLog ;
43- import static oracle .weblogic .kubernetes .actions .TestActions .uninstallOperator ;
44+ import static oracle .weblogic .kubernetes .actions .TestActions .patchDomainResourceWithNewIntrospectVersion ;
45+ import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyPodsNotRolled ;
4446import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodInitializing ;
4547import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReady ;
4648import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
4749import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createDomainAndVerify ;
4850import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createOcirRepoSecret ;
4951import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createSecretWithUsernamePassword ;
5052import static oracle .weblogic .kubernetes .utils .CommonTestUtils .dockerLoginAndPushImageToRegistry ;
53+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getPodCreationTime ;
5154import static oracle .weblogic .kubernetes .utils .CommonTestUtils .installAndVerifyOperator ;
5255import static oracle .weblogic .kubernetes .utils .CommonTestUtils .setPodAntiAffinity ;
5356import static oracle .weblogic .kubernetes .utils .CommonTestUtils .upgradeAndVerifyOperator ;
@@ -160,16 +163,16 @@ private static void createSecrets(String domainNamespace) {
160163 }
161164
162165
163- @ AfterAll
164- public void tearDownAll () {
165- //delete operator
166- uninstallOperator (opHelmParams );
167- }
168-
169166 /**
170167 * Add initContainers at domain spec level and verify the admin server pod executes initContainer command.
171168 * Test fails if domain crd can't add the initContainers or
172169 * WebLogic server pods don't go through initialization and ready state.
170+ * The following introspect version usecase was added based on issue
171+ * reported by OFSS team. With initContainer configured, the WebLogic server
172+ * pod should not roll with modified introspect version without any update to
173+ * domain resource.
174+ * Update the introspect version with out any change to domain resource
175+ * Make sure no WebLogic server pod get rolled.
173176 */
174177 @ Test
175178 @ DisplayName ("Add initContainers at domain spec level and verify the server pods execute initContainer command "
@@ -190,6 +193,23 @@ public void testDomainInitContainer() {
190193 domain1Uid ,"Hi from Domain" ),
191194 "failed to init busybox container command for managed server2" );
192195
196+ // get the pod creation time stamps
197+ LinkedHashMap <String , OffsetDateTime > pods = new LinkedHashMap <>();
198+ // get the creation time of the admin server pod before patching
199+ OffsetDateTime adminPodCreationTime = getPodCreationTime (domain1Namespace ,domain1Uid + "-admin-server" );
200+ String adminServerPodName = domain1Uid + adminServerPrefix ;
201+ pods .put (adminServerPodName , adminPodCreationTime );
202+ // get the creation time of the managed server pods before patching
203+ String managedServerNameBase = "managed-server" ;
204+ String managedServerPodNamePrefix = domain1Uid + "-managed-server" ;
205+ for (int i = 1 ; i <= replicaCount ; i ++) {
206+ pods .put (managedServerPodNamePrefix + i ,
207+ getPodCreationTime (domain1Namespace , managedServerPodNamePrefix + i ));
208+ }
209+ patchDomainResourceWithNewIntrospectVersion (domain1Uid ,domain1Namespace );
210+ //verify the pods are not restarted in any introspectVersion update
211+ verifyPodsNotRolled (domain1Namespace , pods );
212+
193213 }
194214
195215 private boolean checkPodLogContainMsg (String podName , String podNamespace , String domainUid , String msg ) {
@@ -341,7 +361,9 @@ private void createAndVerifyMiiDomain(String domainNamespace, String domainUid,
341361 .addCommandItem ("echo" ).addArgsItem ("\" Hi from Domain\" " )
342362 .name ("busybox" )
343363 .imagePullPolicy ("IfNotPresent" )
344- .image ("busybox" ));
364+ .image ("busybox" ).addEnvItem (new V1EnvVar ()
365+ .name ("DOMAIN_NAME" )
366+ .value ("xyz" )));
345367 setPodAntiAffinity (domain );
346368 break ;
347369 case "adminServer" :
0 commit comments