1
- // Copyright (c) 2022, Oracle and/or its affiliates.
1
+ // Copyright (c) 2022, 2023, Oracle and/or its affiliates.
2
2
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3
3
4
4
package oracle .weblogic .kubernetes ;
51
51
import static oracle .weblogic .kubernetes .actions .TestActions .buildAppArchive ;
52
52
import static oracle .weblogic .kubernetes .actions .TestActions .createDomainCustomResource ;
53
53
import static oracle .weblogic .kubernetes .actions .TestActions .defaultAppParams ;
54
+ import static oracle .weblogic .kubernetes .actions .TestActions .deleteConfigMap ;
54
55
import static oracle .weblogic .kubernetes .actions .TestActions .deleteImage ;
55
56
import static oracle .weblogic .kubernetes .actions .TestActions .getDomainCustomResource ;
56
57
import static oracle .weblogic .kubernetes .actions .TestActions .getOperatorPodName ;
57
58
import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
58
59
import static oracle .weblogic .kubernetes .actions .TestActions .imageTag ;
59
60
import static oracle .weblogic .kubernetes .actions .TestActions .now ;
61
+ import static oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes .listConfigMaps ;
60
62
import static oracle .weblogic .kubernetes .assertions .TestAssertions .doesDomainExist ;
61
63
import static oracle .weblogic .kubernetes .assertions .TestAssertions .verifyRollingRestartOccurred ;
62
64
import static oracle .weblogic .kubernetes .utils .AuxiliaryImageUtils .checkWDTVersion ;
72
74
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
73
75
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .verifyConfiguredSystemResouceByPath ;
74
76
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .verifyConfiguredSystemResource ;
77
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withLongRetryPolicy ;
75
78
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapForDomainCreation ;
76
79
import static oracle .weblogic .kubernetes .utils .DomainUtils .checkDomainStatusConditionTypeExists ;
77
80
import static oracle .weblogic .kubernetes .utils .DomainUtils .checkDomainStatusConditionTypeHasExpectedStatus ;
@@ -152,6 +155,9 @@ class ItMiiAuxiliaryImage {
152
155
private static final String miiAuxiliaryImage15Tag = "image15" + MII_BASIC_IMAGE_TAG ;
153
156
private static final String miiAuxiliaryImage15 = MII_AUXILIARY_IMAGE_NAME + ":" + miiAuxiliaryImage15Tag ;
154
157
158
+ private static final String miiAuxiliaryImage16Tag = "image16" + MII_BASIC_IMAGE_TAG ;
159
+ private static final String miiAuxiliaryImage16 = MII_AUXILIARY_IMAGE_NAME + ":" + miiAuxiliaryImage16Tag ;
160
+
155
161
private static final String errorPathAuxiliaryImage1Tag = "errorimage1" + MII_BASIC_IMAGE_TAG ;
156
162
private static final String errorPathAuxiliaryImage1 = MII_AUXILIARY_IMAGE_NAME + ":" + errorPathAuxiliaryImage1Tag ;
157
163
private static final String errorPathAuxiliaryImage2Tag = "errorimage2" + MII_BASIC_IMAGE_TAG ;
@@ -708,15 +714,13 @@ WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, createSecretsForImageRepos(domai
708
714
}
709
715
710
716
/**
711
- * Create a domain using auxiliary image with configMap and no model files.
712
- * Verify domain events and operator log contains the expected error message.
713
- * Add to the configMap model files.
717
+ * Create a domain using auxiliary image with configMap with model files.
714
718
* Verify domain is created and running.
715
719
*/
716
720
@ Test
717
- @ DisplayName ("Test to create domain using auxiliary image with configMap and empty model"
718
- + " files dir in the auxiliary image" )
719
- void testCreateDomainWithConfigMapAndEmptryModelFileDir () {
721
+ @ DisplayName ("Test to create domain using auxiliary image with configMap containing model files "
722
+ + " with empty model files dir in the auxiliary image" )
723
+ void testCreateDomainWithConfigMapAndEmptyModelFileDir () {
720
724
721
725
final String auxiliaryImagePathCustom = "/customauxiliary" ;
722
726
String domainUid = "testdomain8" ;
@@ -733,40 +737,92 @@ void testCreateDomainWithConfigMapAndEmptryModelFileDir() {
733
737
.wdtModelHome (auxiliaryImagePathCustom + "/models" );
734
738
createAndPushAuxiliaryImage (MII_AUXILIARY_IMAGE_NAME ,miiAuxiliaryImage12Tag , witParams );
735
739
736
- String configMapName = "modelfiles-cm" ;
737
- logger .info ("Create ConfigMap {0} in namespace {1} with WDT models {3} and {4}" ,
738
- configMapName , domainNamespace , MII_BASIC_WDT_MODEL_FILE , "/multi-model-one-ds.20.yaml" );
739
-
740
740
//create empty configMap with no models files and verify that domain creation failed.
741
741
List <Path > cmFiles = new ArrayList <>();
742
742
743
+ String configMapName1 = "modelfiles1-cm" ;
744
+
745
+ //add model files to configmap and verify domain is running
746
+ cmFiles .add (
747
+ Paths .get (MODEL_DIR + "/" + MII_BASIC_WDT_MODEL_FILE ));
748
+ cmFiles .add (Paths .get (MODEL_DIR + "/multi-model-one-ds.20.yaml" ));
743
749
assertDoesNotThrow (
744
750
() -> createConfigMapForDomainCreation (
745
- configMapName , cmFiles , domainNamespace , this .getClass ().getSimpleName ()),
751
+ configMapName1 , cmFiles , domainNamespace , this .getClass ().getSimpleName ()),
746
752
"Create configmap for domain creation failed" );
747
- OffsetDateTime timestamp = now ();
748
753
749
754
// create domain custom resource using auxiliary image
750
755
logger .info ("Creating domain custom resource with domainUid {0} and auxiliary image {1}" ,
751
756
domainUid , miiAuxiliaryImage12 );
752
- final DomainResource domainCR = createDomainResourceWithAuxiliaryImage (domainUid , domainNamespace ,
757
+ DomainResource domainCR1 = createDomainResourceWithAuxiliaryImage (domainUid , domainNamespace ,
753
758
WEBLOGIC_IMAGE_TO_USE_IN_SPEC , adminSecretName , createSecretsForImageRepos (domainNamespace ),
754
759
encryptionSecretName , replicaCount , auxiliaryImagePathCustom ,
755
760
miiAuxiliaryImage12 );
761
+ assertNotNull (domainCR1 , "failed to create domain resource" );
762
+ domainCR1 .spec ().configuration ().model ().configMap (configMapName1 );
763
+ createDomainAndVerify (domainUid , domainCR1 , domainNamespace ,
764
+ adminServerPodName , managedServerPrefix , replicaCount );
765
+ }
766
+
767
+ /**
768
+ * Create a domain using auxiliary image with empty configMap and no model files.
769
+ * Verify domain events and operator log contains the expected error message from WDT tool.
770
+ * WDT Create Primordial Domain Failed.
771
+ */
772
+ @ Test
773
+ @ DisplayName ("Test to create domain using auxiliary image with "
774
+ + "empty configMap with no models files and verify that domain creation failed" )
775
+ void testCreateDomainWithEmptyConfigMapWithNoModelFiles () {
776
+
777
+ final String auxiliaryImagePathCustom = "/customauxiliary" ;
778
+ String domainUid = "testdomain9" ;
779
+ String adminServerPodName = domainUid + "-admin-server" ;
780
+ String managedServerPrefix = domainUid + "-managed-server" ;
781
+ List <String > archiveList = Collections .singletonList (ARCHIVE_DIR + "/" + MII_BASIC_APP_NAME + ".zip" );
782
+
783
+ WitParams witParams =
784
+ new WitParams ()
785
+ .modelImageName (MII_AUXILIARY_IMAGE_NAME )
786
+ .modelImageTag (miiAuxiliaryImage16Tag )
787
+ .wdtHome (auxiliaryImagePathCustom )
788
+ .modelArchiveFiles (archiveList )
789
+ .wdtModelHome (auxiliaryImagePathCustom + "/models" );
790
+ createAndPushAuxiliaryImage (MII_AUXILIARY_IMAGE_NAME ,miiAuxiliaryImage16Tag , witParams );
791
+
792
+ String configMapName = "modelfiles-cm" ;
793
+ logger .info ("Create ConfigMap {0} in namespace {1} with WDT models {3} and {4}" ,
794
+ configMapName , domainNamespace , MII_BASIC_WDT_MODEL_FILE , "/multi-model-one-ds.20.yaml" );
795
+
796
+ //create empty configMap with no models files and verify that domain creation failed.
797
+ List <Path > cmFiles = new ArrayList <>();
798
+
799
+ assertDoesNotThrow (
800
+ () -> createConfigMapForDomainCreation (
801
+ configMapName , cmFiles , domainNamespace , this .getClass ().getSimpleName ()),
802
+ "Create configmap for domain creation failed" );
803
+ OffsetDateTime timestamp = now ();
804
+
805
+ // create domain custom resource using auxiliary image
806
+ logger .info ("Creating domain custom resource with domainUid {0} and auxiliary image {1}" ,
807
+ domainUid , miiAuxiliaryImage16 );
808
+ final DomainResource domainCR = createDomainResourceWithAuxiliaryImage (domainUid , domainNamespace ,
809
+ WEBLOGIC_IMAGE_TO_USE_IN_SPEC , adminSecretName , createSecretsForImageRepos (domainNamespace ),
810
+ encryptionSecretName , replicaCount , auxiliaryImagePathCustom ,
811
+ miiAuxiliaryImage16 );
756
812
assertNotNull (domainCR , "failed to create domain resource" );
757
813
domainCR .spec ().configuration ().model ().configMap (configMapName );
758
814
// create domain and verify it is failed
759
815
logger .info ("Creating domain custom resource for domainUid {0} in namespace {1}" ,
760
- domainUid , domainNamespace );
816
+ domainUid , domainNamespace );
761
817
assertDoesNotThrow (() -> createDomainCustomResource (domainCR ),
762
- String .format ("Create domain custom resource failed with ApiException for %s in namespace %s" ,
763
- domainUid , domainNamespace ));
818
+ String .format ("Create domain custom resource failed with ApiException for %s in namespace %s" ,
819
+ domainUid , domainNamespace ));
764
820
// check the introspector pod log contains the expected error message
765
- String expectedErrorMsg = "createDomain failed to find a model file in archive " ;
821
+ String expectedErrorMsg = "Model in Image: WDT Create Primordial Domain Failed " ;
766
822
767
823
// check the domain event contains the expected error message
768
824
checkDomainEventContainsExpectedMsg (opNamespace , domainNamespace , domainUid , DOMAIN_FAILED ,
769
- "Warning" , timestamp , expectedErrorMsg );
825
+ "Warning" , timestamp , expectedErrorMsg );
770
826
771
827
// check the operator pod log contains the expected error message
772
828
checkPodLogContainsString (opNamespace , operatorPodName , expectedErrorMsg );
@@ -779,30 +835,15 @@ WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, createSecretsForImageRepos(domai
779
835
checkServiceDoesNotExist (managedServerPrefix + i , domainNamespace );
780
836
}
781
837
782
- // delete domain3
838
+ // delete domain9
783
839
deleteDomainResource (domainNamespace , domainUid );
784
- String configMapName1 = "modelfiles1-cm" ;
785
-
786
- //add model files to configmap and verify domain is running
787
- cmFiles .add (
788
- Paths .get (MODEL_DIR + "/" + MII_BASIC_WDT_MODEL_FILE ));
789
- cmFiles .add (Paths .get (MODEL_DIR + "/multi-model-one-ds.20.yaml" ));
790
- assertDoesNotThrow (
791
- () -> createConfigMapForDomainCreation (
792
- configMapName1 , cmFiles , domainNamespace , this .getClass ().getSimpleName ()),
793
- "Create configmap for domain creation failed" );
794
-
795
- // create domain custom resource using auxiliary image
796
- logger .info ("Creating domain custom resource with domainUid {0} and auxiliary image {1}" ,
797
- domainUid , miiAuxiliaryImage12 );
798
- DomainResource domainCR1 = createDomainResourceWithAuxiliaryImage (domainUid , domainNamespace ,
799
- WEBLOGIC_IMAGE_TO_USE_IN_SPEC , adminSecretName , createSecretsForImageRepos (domainNamespace ),
800
- encryptionSecretName , replicaCount , auxiliaryImagePathCustom ,
801
- miiAuxiliaryImage12 );
802
- assertNotNull (domainCR1 , "failed to create domain resource" );
803
- domainCR1 .spec ().configuration ().model ().configMap (configMapName1 );
804
- createDomainAndVerify (domainUid , domainCR1 , domainNamespace ,
805
- adminServerPodName , managedServerPrefix , replicaCount );
840
+ deleteConfigMap (configMapName , domainNamespace );
841
+ testUntil (
842
+ withLongRetryPolicy ,
843
+ () -> listConfigMaps (domainNamespace ).getItems ().stream ().noneMatch ((cm )
844
+ -> (cm .getMetadata ().getName ().equals (configMapName ))),
845
+ logger ,
846
+ "configmap {0} to be deleted." , configMapName );
806
847
}
807
848
808
849
/**
@@ -1346,6 +1387,7 @@ public void tearDownAll() {
1346
1387
deleteImage (miiAuxiliaryImage13 );
1347
1388
deleteImage (miiAuxiliaryImage14 );
1348
1389
deleteImage (miiAuxiliaryImage15 );
1390
+ deleteImage (miiAuxiliaryImage16 );
1349
1391
deleteImage (errorPathAuxiliaryImage1 );
1350
1392
deleteImage (errorPathAuxiliaryImage2 );
1351
1393
deleteImage (errorPathAuxiliaryImage3 );
0 commit comments