43
43
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_SERVER_NAME_BASE ;
44
44
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
45
45
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
46
+ import static oracle .weblogic .kubernetes .TestConstants .KIND_REPO ;
46
47
import static oracle .weblogic .kubernetes .TestConstants .MANAGED_SERVER_NAME_BASE ;
47
48
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
48
49
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
83
84
/**
84
85
* Test pods are restarted after the following properties in server pods are changed.
85
86
* 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) .
87
88
* Change: podSecurityContext: runAsUser:0 --> runAsUser: 1000
88
89
* Add resources: limits: cpu: "1", resources: requests: cpu: "0.5".
89
90
*
@@ -541,11 +542,13 @@ void testServerPodsRestartByChaningPodSecurityContext() {
541
542
* Modify the domain scope property on the domain resource.
542
543
* Verify all pods are restarted and back to ready state.
543
544
* 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) .
545
546
*/
546
547
@ Test
547
548
@ DisplayName ("Verify server pods are restarted by changing imagePullPolicy" )
548
549
void testServerPodsRestartByChangingImagePullPolicy () {
550
+ String pullPolicy = KIND_REPO != null ? "Never" : "Always" ;
551
+
549
552
// get the original domain resource before update
550
553
Domain domain1 = assertDoesNotThrow (() -> getDomainCustomResource (domainUid , domainNamespace ),
551
554
String .format ("getDomainCustomResource failed with ApiException when tried to get domain %s in namespace %s" ,
@@ -560,13 +563,13 @@ void testServerPodsRestartByChangingImagePullPolicy() {
560
563
String imagePullPolicy = domain1 .getSpec ().getImagePullPolicy ();
561
564
logger .info ("Original domain imagePullPolicy is: {0}" , imagePullPolicy );
562
565
563
- //change imagePullPolicy: IfNotPresent --> imagePullPolicy: Never
566
+ //change imagePullPolicy: IfNotPresent --> imagePullPolicy: Always(If non kind, otherwise Never)
564
567
StringBuffer patchStr = null ;
565
568
patchStr = new StringBuffer ("[{" );
566
569
patchStr .append ("\" op\" : \" replace\" ," )
567
570
.append (" \" path\" : \" /spec/imagePullPolicy\" ," )
568
571
.append ("\" value\" : \" " )
569
- .append ("Never" )
572
+ .append (pullPolicy )
570
573
.append ("\" }]" );
571
574
logger .info ("PatchStr for imagePullPolicy: {0}" , patchStr .toString ());
572
575
@@ -582,8 +585,8 @@ void testServerPodsRestartByChangingImagePullPolicy() {
582
585
//print out imagePullPolicy in the new patched domain
583
586
imagePullPolicy = domain1 .getSpec ().getImagePullPolicy ();
584
587
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" );
587
590
588
591
//get current timestamp before domain rolling restart to verify domain roll events
589
592
OffsetDateTime timestamp = now ();
@@ -603,15 +606,15 @@ void testServerPodsRestartByChangingImagePullPolicy() {
603
606
CoreV1Event event = getEvent (opNamespace , domainNamespace ,
604
607
domainUid , DOMAIN_ROLL_STARTING , "Normal" , timestamp );
605
608
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 ));
608
611
609
612
event = getEvent (opNamespace , domainNamespace ,
610
613
domainUid , POD_CYCLE_STARTING , "Normal" , timestamp );
611
614
logger .info (Yaml .dump (event ));
612
615
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 ));
615
618
616
619
logger .info ("verify domain roll completed event is logged" );
617
620
checkEvent (opNamespace , domainNamespace , domainUid , DOMAIN_ROLL_COMPLETED ,
@@ -824,6 +827,7 @@ private static void createAndVerifyMiiDomain() {
824
827
.domainUid (domainUid )
825
828
.domainHomeSourceType ("FromModel" )
826
829
.image (miiImage )
830
+ .imagePullPolicy ("IfNotPresent" )
827
831
.addImagePullSecretsItem (new V1LocalObjectReference ()
828
832
.name (OCIR_SECRET_NAME ))
829
833
.webLogicCredentialsSecret (new V1SecretReference ()
@@ -844,6 +848,7 @@ private static void createAndVerifyMiiDomain() {
844
848
.domainType (WLS_DOMAIN_TYPE )
845
849
.runtimeEncryptionSecret (encryptionSecretName ))));
846
850
setPodAntiAffinity (domain );
851
+ logger .info (Yaml .dump (domain ));
847
852
// create model in image domain
848
853
logger .info ("Creating model in image domain {0} in namespace {1} using docker image {2}" ,
849
854
domainUid , domainNamespace , miiImage );
0 commit comments