4343import static oracle .weblogic .kubernetes .TestConstants .ADMIN_SERVER_NAME_BASE ;
4444import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
4545import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
46+ import static oracle .weblogic .kubernetes .TestConstants .KIND_REPO ;
4647import static oracle .weblogic .kubernetes .TestConstants .MANAGED_SERVER_NAME_BASE ;
4748import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
4849import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
8384/**
8485 * Test pods are restarted after the following properties in server pods are changed.
8586 * Change: The env property tested: "-Dweblogic.StdoutDebugEnabled=false" --> "-Dweblogic.StdoutDebugEnabled=true
86- * Change: imagePullPolicy: IfNotPresent --> imagePullPolicy: Never.
87+ * Change: imagePullPolicy: IfNotPresent --> imagePullPolicy: Always(If non kind, otherwise Never) .
8788 * Change: podSecurityContext: runAsUser:0 --> runAsUser: 1000
8889 * Add resources: limits: cpu: "1", resources: requests: cpu: "0.5".
8990 *
@@ -541,11 +542,13 @@ void testServerPodsRestartByChaningPodSecurityContext() {
541542 * Modify the domain scope property on the domain resource.
542543 * Verify all pods are restarted and back to ready state.
543544 * Verifies that the domain roll starting/pod cycle starting events are logged.
544- * The resources tested: imagePullPolicy: IfNotPresent --> imagePullPolicy: Never.
545+ * The resources tested: imagePullPolicy: IfNotPresent --> imagePullPolicy: Always(If non kind, otherwise Never) .
545546 */
546547 @ Test
547548 @ DisplayName ("Verify server pods are restarted by changing imagePullPolicy" )
548549 void testServerPodsRestartByChangingImagePullPolicy () {
550+ String pullPolicy = KIND_REPO != null ? "Never" : "Always" ;
551+
549552 // get the original domain resource before update
550553 Domain domain1 = assertDoesNotThrow (() -> getDomainCustomResource (domainUid , domainNamespace ),
551554 String .format ("getDomainCustomResource failed with ApiException when tried to get domain %s in namespace %s" ,
@@ -560,13 +563,13 @@ void testServerPodsRestartByChangingImagePullPolicy() {
560563 String imagePullPolicy = domain1 .getSpec ().getImagePullPolicy ();
561564 logger .info ("Original domain imagePullPolicy is: {0}" , imagePullPolicy );
562565
563- //change imagePullPolicy: IfNotPresent --> imagePullPolicy: Never
566+ //change imagePullPolicy: IfNotPresent --> imagePullPolicy: Always(If non kind, otherwise Never)
564567 StringBuffer patchStr = null ;
565568 patchStr = new StringBuffer ("[{" );
566569 patchStr .append ("\" op\" : \" replace\" ," )
567570 .append (" \" path\" : \" /spec/imagePullPolicy\" ," )
568571 .append ("\" value\" : \" " )
569- .append ("Never" )
572+ .append (pullPolicy )
570573 .append ("\" }]" );
571574 logger .info ("PatchStr for imagePullPolicy: {0}" , patchStr .toString ());
572575
@@ -582,8 +585,8 @@ void testServerPodsRestartByChangingImagePullPolicy() {
582585 //print out imagePullPolicy in the new patched domain
583586 imagePullPolicy = domain1 .getSpec ().getImagePullPolicy ();
584587 logger .info ("In the new patched domain imagePullPolicy is: {0}" , imagePullPolicy );
585- assertTrue (imagePullPolicy .equalsIgnoreCase ("Never" ), "imagePullPolicy was not updated"
586- + " in the new patched domain" );
588+ assertTrue (imagePullPolicy .equalsIgnoreCase (pullPolicy ),
589+ "imagePullPolicy was not updated in the new patched domain" );
587590
588591 //get current timestamp before domain rolling restart to verify domain roll events
589592 OffsetDateTime timestamp = now ();
@@ -603,15 +606,15 @@ void testServerPodsRestartByChangingImagePullPolicy() {
603606 CoreV1Event event = getEvent (opNamespace , domainNamespace ,
604607 domainUid , DOMAIN_ROLL_STARTING , "Normal" , timestamp );
605608 logger .info ("verify the event message contains the 'imagePullPolicy' "
606- + "changed from 'IfNotPresent' to 'Never ' message is logged" );
607- assertTrue (event .getMessage ().contains ("Never" ));
609+ + "changed from 'IfNotPresent' to '" + pullPolicy + " ' message is logged" );
610+ assertTrue (event .getMessage ().contains (pullPolicy ));
608611
609612 event = getEvent (opNamespace , domainNamespace ,
610613 domainUid , POD_CYCLE_STARTING , "Normal" , timestamp );
611614 logger .info (Yaml .dump (event ));
612615 logger .info ("verify the event message contains the 'imagePullPolicy' "
613- + "changed from 'IfNotPresent' to 'Never ' message is logged" );
614- assertTrue (event .getMessage ().contains ("Never" ));
616+ + "changed from 'IfNotPresent' to '" + pullPolicy + " ' message is logged" );
617+ assertTrue (event .getMessage ().contains (pullPolicy ));
615618
616619 logger .info ("verify domain roll completed event is logged" );
617620 checkEvent (opNamespace , domainNamespace , domainUid , DOMAIN_ROLL_COMPLETED ,
@@ -824,6 +827,7 @@ private static void createAndVerifyMiiDomain() {
824827 .domainUid (domainUid )
825828 .domainHomeSourceType ("FromModel" )
826829 .image (miiImage )
830+ .imagePullPolicy ("IfNotPresent" )
827831 .addImagePullSecretsItem (new V1LocalObjectReference ()
828832 .name (OCIR_SECRET_NAME ))
829833 .webLogicCredentialsSecret (new V1SecretReference ()
@@ -844,6 +848,7 @@ private static void createAndVerifyMiiDomain() {
844848 .domainType (WLS_DOMAIN_TYPE )
845849 .runtimeEncryptionSecret (encryptionSecretName ))));
846850 setPodAntiAffinity (domain );
851+ logger .info (Yaml .dump (domain ));
847852 // create model in image domain
848853 logger .info ("Creating model in image domain {0} in namespace {1} using docker image {2}" ,
849854 domainUid , domainNamespace , miiImage );
0 commit comments