2222import oracle .weblogic .domain .Istio ;
2323import oracle .weblogic .domain .Model ;
2424import oracle .weblogic .domain .ServerPod ;
25- import oracle .weblogic .kubernetes .actions .impl .primitive .HelmParams ;
2625import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
2726import oracle .weblogic .kubernetes .annotations .Namespaces ;
2827import oracle .weblogic .kubernetes .logging .LoggingFacade ;
2928import oracle .weblogic .kubernetes .utils .BuildApplication ;
3029import oracle .weblogic .kubernetes .utils .ExecCommand ;
3130import oracle .weblogic .kubernetes .utils .ExecResult ;
32- import org .awaitility .core .ConditionFactory ;
3331import org .junit .jupiter .api .BeforeAll ;
3432import org .junit .jupiter .api .DisplayName ;
3533import org .junit .jupiter .api .Tag ;
3634import org .junit .jupiter .api .Test ;
3735
38- import static java .util .concurrent .TimeUnit .MINUTES ;
39- import static java .util .concurrent .TimeUnit .SECONDS ;
36+ import static oracle .weblogic .kubernetes .TestConstants .ADMIN_SERVER_NAME_BASE ;
4037import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
4138import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
4239import static oracle .weblogic .kubernetes .TestConstants .MANAGED_SERVER_NAME_BASE ;
4643import static oracle .weblogic .kubernetes .actions .TestActions .addLabelsToNamespace ;
4744import static oracle .weblogic .kubernetes .actions .TestActions .createDomainCustomResource ;
4845import static oracle .weblogic .kubernetes .utils .ApplicationUtils .callWebAppAndWaitTillReady ;
46+ import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .createAndPushMiiImage ;
47+ import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .createMiiDomainWithIstioMultiClusters ;
4948import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
5049import static oracle .weblogic .kubernetes .utils .FileUtils .generateFileFromTemplate ;
5150import static oracle .weblogic .kubernetes .utils .ImageUtils .createImageAndVerify ;
5857import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
5958import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
6059import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
61- import static org .awaitility .Awaitility .with ;
6260import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
6361import static org .junit .jupiter .api .Assertions .assertEquals ;
6462import static org .junit .jupiter .api .Assertions .assertFalse ;
@@ -76,25 +74,25 @@ class ItIstioManagedCoherence {
7674
7775 // constants for creating domain image using model in image
7876 private static final String COHERENCE_MODEL_FILE = "coherence-managed-wdt-config.yaml" ;
77+ private static final String MII_COHERENCE_MODEL_FILE = "coherence-managed-wdt-config-mii.yaml" ;
7978 private static final String COHERENCE_MODEL_PROP = "coherence-managed-wdt-config.properties" ;
8079 private static final String COHERENCE_IMAGE_NAME = "coherence-managed-image" ;
8180
8281 // constants for WebLogic domain
8382 private static final String domainUid = "coherence-managed-domain" ;
8483 private static final int NUMBER_OF_CLUSTERS = 2 ;
8584 private static final String CLUSTER_NAME_PREFIX = "cluster-" ;
86- private static final int MANAGED_SERVER_PORT = 8001 ;
8785 private static final int replicaCount = 2 ;
8886 private static String adminServerPodName = domainUid + "-admin-server" ;
89- private static String cluster1Hostname = null ;
90- private static String cluster2Hostname = null ;
87+ private static final String miiImageName = "mii-image" ;
88+ private static final String miiDomainUid = "miidomain" ;
9189
9290 private static String opNamespace = null ;
93- private static String domainNamespace = null ;
94- private static ConditionFactory withStandardRetryPolicy = null ;
91+ private static String domainInImageNamespace = null ;
92+ private static String miiDomainNamespace = null ;
93+ private static String miiImage = null ;
94+ private static String encryptionSecretName = "encryptionsecret" ;
9595
96- private static boolean enableValidatingWebhook = false ;
97- private static HelmParams voyagerHelmParams = null ;
9896 private static LoggingFacade logger = null ;
9997
10098 /**
@@ -108,36 +106,37 @@ class ItIstioManagedCoherence {
108106 * JUnit engine parameter resolution mechanism
109107 */
110108 @ BeforeAll
111- public static void init (@ Namespaces (2 ) List <String > namespaces ) {
109+ public static void init (@ Namespaces (3 ) List <String > namespaces ) {
112110 logger = getLogger ();
113- // create standard, reusable retry/backoff policy
114- withStandardRetryPolicy = with ().pollDelay (2 , SECONDS )
115- .and ().with ().pollInterval (10 , SECONDS )
116- .atMost (5 , MINUTES ).await ();
117111
118112 // get a new unique opNamespace
119113 logger .info ("Assigning a unique namespace for Operator" );
120114 assertNotNull (namespaces .get (0 ), "Namespace list is null" );
121115 opNamespace = namespaces .get (0 );
122116
123- // get a new unique domainNamespace
124- logger .info ("Assigning a unique namespace for Domain" );
117+ // get a new unique namespace for domain-in-image domain
118+ logger .info ("Assigning a unique namespace for domain-in-image Domain" );
125119 assertNotNull (namespaces .get (1 ), "Namespace list is null" );
126- domainNamespace = namespaces .get (1 );
120+ domainInImageNamespace = namespaces .get (1 );
121+
122+ // get a new unique namespace for model-in-image domain
123+ logger .info ("Assigning a unique namespace for model-in-image Domain" );
124+ assertNotNull (namespaces .get (2 ), "Namespace list is null" );
125+ miiDomainNamespace = namespaces .get (2 );
127126
128-
129127 // Label the domain/operator namespace with istio-injection=enabled
130128 Map <String , String > labelMap = new HashMap ();
131129 labelMap .put ("istio-injection" , "enabled" );
132- assertDoesNotThrow (() -> addLabelsToNamespace (domainNamespace ,labelMap ));
133- assertDoesNotThrow (() -> addLabelsToNamespace (opNamespace ,labelMap ));
130+ assertDoesNotThrow (() -> addLabelsToNamespace (domainInImageNamespace , labelMap ));
131+ assertDoesNotThrow (() -> addLabelsToNamespace (miiDomainNamespace , labelMap ));
132+ assertDoesNotThrow (() -> addLabelsToNamespace (opNamespace , labelMap ));
134133
135134 // install and verify operator
136- installAndVerifyOperator (opNamespace , domainNamespace );
135+ installAndVerifyOperator (opNamespace , domainInImageNamespace , miiDomainNamespace );
137136
138137 // build Coherence applications
139138 Path distDir = BuildApplication .buildApplication (Paths .get (APP_DIR , COHERENCE_APP_NAME ),
140- null , null , "builddir" , domainNamespace );
139+ null , null , "builddir" , domainInImageNamespace );
141140 Path coherenceAppGarPath = Paths .get (distDir .toString (), COHERENCE_APP_NAME + ".gar" );
142141 Path coherenceAppEarPath = Paths .get (distDir .toString (), COHERENCE_APP_NAME + ".ear" );
143142 assertTrue (coherenceAppGarPath .toFile ().exists (), "Application archive is not available" );
@@ -147,16 +146,17 @@ public static void init(@Namespaces(2) List<String> namespaces) {
147146 }
148147
149148 /**
150- * Create domain with two clusters, cluster-1 and cluster-2.
149+ * Create domain-in-image domain with two clusters, cluster-1 and cluster-2.
151150 * Associate them with a Coherence cluster
152151 * Deploy the EAR file to cluster-1 that has no storage enabled
153152 * Deploy the GAR file to cluster-2 that has storage enabled
154153 * Verify that data can be added and stored in the cache
155154 * and can also be retrieved from cache.
156155 */
157156 @ Test
158- @ DisplayName ("Two cluster domain with a Coherence cluster with ISTIO and test interaction with cache data" )
159- void testIstioMultiClusterCoherenceDomain () {
157+ @ DisplayName ("Two cluster domain-in-image domain with a Coherence cluster with ISTIO and "
158+ + "test interaction with cache data" )
159+ void testIstioMultiClusterCoherenceDomainInImageDomain () {
160160
161161 // create a DomainHomeInImage image using WebLogic Image Tool
162162 String domImage = createAndVerifyDomainImage ();
@@ -166,9 +166,9 @@ void testIstioMultiClusterCoherenceDomain() {
166166
167167 String clusterService = domainUid + "-cluster-cluster-1" ;
168168 Map <String , String > templateMap = new HashMap ();
169- templateMap .put ("NAMESPACE" , domainNamespace );
169+ templateMap .put ("NAMESPACE" , domainInImageNamespace );
170170 templateMap .put ("DUID" , domainUid );
171- templateMap .put ("ADMIN_SERVICE" ,adminServerPodName );
171+ templateMap .put ("ADMIN_SERVICE" , adminServerPodName );
172172 templateMap .put ("CLUSTER_SERVICE" , clusterService );
173173
174174 Path srcHttpFile = Paths .get (RESOURCE_DIR , "istio" , "istio-coh-http-template.yaml" );
@@ -195,52 +195,100 @@ void testIstioMultiClusterCoherenceDomain() {
195195 assertTrue (testCompletedSuccessfully , "Test Coherence cache failed" );
196196 }
197197
198+
199+ /**
200+ * Create model-in-image domain with two clusters, cluster-1 and cluster-2.
201+ * Associate them with a Coherence cluster
202+ * Deploy the EAR file to cluster-1 that has no storage enabled
203+ * Deploy the GAR file to cluster-2 that has storage enabled
204+ * Verify that data can be added and stored in the cache
205+ * and can also be retrieved from cache.
206+ */
207+ @ Test
208+ @ DisplayName ("Two cluster mii domain with a Coherence cluster with ISTIO and test interaction with cache data" )
209+ void testIstioMultiClusterCoherenceMiiDomain () {
210+
211+ // create a model-in-image domain image using WebLogic Image Tool
212+ miiImage = createAndPushMiiImage (miiImageName , MII_COHERENCE_MODEL_FILE , COHERENCE_APP_NAME , COHERENCE_MODEL_PROP );
213+
214+ // create and verify a two-clusters WebLogic domain with a Coherence cluster
215+ createMiiDomainWithIstioMultiClusters (miiDomainUid , miiDomainNamespace , miiImage , NUMBER_OF_CLUSTERS , replicaCount );
216+
217+ Map <String , String > templateMap = new HashMap ();
218+ templateMap .put ("NAMESPACE" , miiDomainNamespace );
219+ templateMap .put ("DUID" , miiDomainUid );
220+ templateMap .put ("ADMIN_SERVICE" , miiDomainUid + "-" + ADMIN_SERVER_NAME_BASE );
221+ templateMap .put ("CLUSTER_SERVICE" , miiDomainUid + "-cluster-cluster-1" );
222+
223+ Path srcHttpFile = Paths .get (RESOURCE_DIR , "istio" , "istio-coh-http-template.yaml" );
224+ Path targetHttpFile = assertDoesNotThrow (
225+ () -> generateFileFromTemplate (srcHttpFile .toString (), "istio-http.yaml" , templateMap ));
226+ logger .info ("Generated Http VS/Gateway file path is {0}" , targetHttpFile );
227+
228+ boolean deployRes = assertDoesNotThrow (
229+ () -> deployHttpIstioGatewayAndVirtualservice (targetHttpFile ));
230+ assertTrue (deployRes , "Failed to deploy Http Istio Gateway/VirtualService" );
231+
232+ int istioIngressPort = getIstioHttpIngressPort ();
233+ logger .info ("Istio Ingress Port is {0}" , istioIngressPort );
234+
235+ // Make sure ready app is accessible thru Istio Ingress Port
236+ String curlCmd = "curl --silent --show-error --noproxy '*' http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort
237+ + "/weblogic/ready --write-out %{http_code} -o /dev/null" ;
238+ logger .info ("Executing curl command {0}" , curlCmd );
239+ assertTrue (callWebAppAndWaitTillReady (curlCmd , 60 ));
240+
241+ // test adding data to the cache and retrieving them from the cache
242+ boolean testCompletedSuccessfully = assertDoesNotThrow (()
243+ -> coherenceCacheTest (istioIngressPort ), "Test Coherence cache failed" );
244+ assertTrue (testCompletedSuccessfully , "Test Coherence cache failed" );
245+ }
246+
198247 private static String createAndVerifyDomainImage () {
199248 // create image with model files
200249 logger .info ("Create image with model file and verify" );
201250 String domImage = createImageAndVerify (
202251 COHERENCE_IMAGE_NAME , COHERENCE_MODEL_FILE ,
203- COHERENCE_APP_NAME , COHERENCE_MODEL_PROP , domainUid );
252+ COHERENCE_APP_NAME , COHERENCE_MODEL_PROP , domainUid );
204253
205254 // docker login and push image to docker registry if necessary
206255 dockerLoginAndPushImageToRegistry (domImage );
207256
208257 // create docker registry secret to pull the image from registry
209258 // this secret is used only for non-kind cluster
210- logger .info ("Create docker registry secret in namespace {0}" , domainNamespace );
211- createOcirRepoSecret (domainNamespace );
259+ logger .info ("Create docker registry secret in namespace {0}" , domainInImageNamespace );
260+ createOcirRepoSecret (domainInImageNamespace );
212261 return domImage ;
213262 }
214263
215264 private static void createAndVerifyDomain (String domImage ) {
216265 // create secret for admin credentials
217266 logger .info ("Create secret for admin credentials" );
218267 String adminSecretName = "weblogic-credentials" ;
219- assertDoesNotThrow (() -> createSecretWithUsernamePassword (adminSecretName , domainNamespace ,
268+ assertDoesNotThrow (() -> createSecretWithUsernamePassword (adminSecretName , domainInImageNamespace ,
220269 "weblogic" , "welcome1" ),
221270 String .format ("create secret for admin credentials failed for %s" , adminSecretName ));
222271
223272 // create encryption secret
224273 logger .info ("Create encryption secret" );
225- String encryptionSecretName = "encryptionsecret" ;
226- assertDoesNotThrow (() -> createSecretWithUsernamePassword (encryptionSecretName , domainNamespace ,
274+ assertDoesNotThrow (() -> createSecretWithUsernamePassword (encryptionSecretName , domainInImageNamespace ,
227275 "weblogicenc" , "weblogicenc" ),
228276 String .format ("create encryption secret failed for %s" , encryptionSecretName ));
229277
230278 // create domain and verify
231279 logger .info ("Create model in image domain {0} in namespace {1} using docker image {2}" ,
232- domainUid , domainNamespace , domImage );
280+ domainUid , domainInImageNamespace , domImage );
233281 createDomainCrAndVerify (adminSecretName , domImage );
234282
235283 // check that admin service exists in the domain namespace
236284 logger .info ("Checking that admin service {0} exists in namespace {1}" ,
237- adminServerPodName , domainNamespace );
238- checkServiceExists (adminServerPodName , domainNamespace );
285+ adminServerPodName , domainInImageNamespace );
286+ checkServiceExists (adminServerPodName , domainInImageNamespace );
239287
240288 // check that admin server pod is ready
241289 logger .info ("Checking that admin server pod {0} is ready in namespace {1}" ,
242- adminServerPodName , domainNamespace );
243- checkPodReady (adminServerPodName , domainUid , domainNamespace );
290+ adminServerPodName , domainInImageNamespace );
291+ checkPodReady (adminServerPodName , domainUid , domainInImageNamespace );
244292
245293 // check the readiness for the managed servers in each cluster
246294 for (int i = 1 ; i <= NUMBER_OF_CLUSTERS ; i ++) {
@@ -250,13 +298,13 @@ private static void createAndVerifyDomain(String domImage) {
250298
251299 // check that the managed server service exists in the domain namespace
252300 logger .info ("Checking that managed server service {0} exists in namespace {1}" ,
253- managedServerPodName , domainNamespace );
254- checkServiceExists (managedServerPodName , domainNamespace );
301+ managedServerPodName , domainInImageNamespace );
302+ checkServiceExists (managedServerPodName , domainInImageNamespace );
255303
256304 // check that the managed server pod is ready
257305 logger .info ("Checking that managed server pod {0} is ready in namespace {1}" ,
258- managedServerPodName , domainNamespace );
259- checkPodReady (managedServerPodName , domainUid , domainNamespace );
306+ managedServerPodName , domainInImageNamespace );
307+ checkPodReady (managedServerPodName , domainUid , domainInImageNamespace );
260308 }
261309 }
262310 }
@@ -277,7 +325,7 @@ private static void createDomainCrAndVerify(String adminSecretName, String domIm
277325 .kind ("Domain" )
278326 .metadata (new V1ObjectMeta ()
279327 .name (domainUid )
280- .namespace (domainNamespace ))
328+ .namespace (domainInImageNamespace ))
281329 .spec (new DomainSpec ()
282330 .domainUid (domainUid )
283331 .domainHomeSourceType ("Image" )
@@ -286,7 +334,7 @@ private static void createDomainCrAndVerify(String adminSecretName, String domIm
286334 .name (OCIR_SECRET_NAME ))
287335 .webLogicCredentialsSecret (new V1SecretReference ()
288336 .name (adminSecretName )
289- .namespace (domainNamespace ))
337+ .namespace (domainInImageNamespace ))
290338 .includeServerOutInPodLog (true )
291339 .serverStartPolicy ("IF_NEEDED" )
292340 .serverPod (new ServerPod ()
@@ -308,12 +356,12 @@ private static void createDomainCrAndVerify(String adminSecretName, String domIm
308356 .introspectorJobActiveDeadlineSeconds (300L )));
309357 setPodAntiAffinity (domain );
310358 logger .info ("Create domain custom resource for domainUid {0} in namespace {1}" ,
311- domainUid , domainNamespace );
359+ domainUid , domainInImageNamespace );
312360 boolean domCreated = assertDoesNotThrow (() -> createDomainCustomResource (domain ),
313361 String .format ("Create domain custom resource failed with ApiException for %s in namespace %s" ,
314- domainUid , domainNamespace ));
362+ domainUid , domainInImageNamespace ));
315363 assertTrue (domCreated , String .format ("Create domain custom resource failed with ApiException "
316- + "for %s in namespace %s" , domainUid , domainNamespace ));
364+ + "for %s in namespace %s" , domainUid , domainInImageNamespace ));
317365 }
318366
319367 private boolean coherenceCacheTest (int ingressServiceNodePort ) {
@@ -442,4 +490,5 @@ private ExecResult clearCache(String hostAndPort) {
442490
443491 return result ;
444492 }
493+
445494}
0 commit comments