1515import io .kubernetes .client .openapi .models .V1LocalObjectReference ;
1616import oracle .weblogic .domain .ClusterResource ;
1717import oracle .weblogic .domain .DomainResource ;
18+ import oracle .weblogic .kubernetes .actions .impl .TraefikParams ;
1819import oracle .weblogic .kubernetes .actions .impl .primitive .Command ;
1920import oracle .weblogic .kubernetes .actions .impl .primitive .CommandParams ;
21+ import oracle .weblogic .kubernetes .actions .impl .primitive .HelmParams ;
2022import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
2123import oracle .weblogic .kubernetes .annotations .Namespaces ;
2224import oracle .weblogic .kubernetes .logging .LoggingFacade ;
4143import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_APP_NAME ;
4244import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
4345import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
46+ import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER_PRIVATEIP ;
4447import static oracle .weblogic .kubernetes .TestConstants .SKIP_CLEANUP ;
4548import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
46- import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
4749import static oracle .weblogic .kubernetes .actions .ActionConstants .ITTESTS_DIR ;
4850import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
4951import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
5052import static oracle .weblogic .kubernetes .actions .ActionConstants .WORK_DIR ;
5153import static oracle .weblogic .kubernetes .actions .TestActions .createDomainCustomResource ;
5254import static oracle .weblogic .kubernetes .actions .TestActions .execCommand ;
53- import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
5455import static oracle .weblogic .kubernetes .actions .TestActions .patchDomainCustomResource ;
5556import static oracle .weblogic .kubernetes .actions .TestActions .scaleCluster ;
57+ import static oracle .weblogic .kubernetes .actions .TestActions .uninstallTraefik ;
5658import static oracle .weblogic .kubernetes .actions .impl .primitive .Command .defaultCommandParams ;
5759import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainExists ;
5860import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterAndVerify ;
6163import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .createDomainResourceWithLogHome ;
6264import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .createDomainSecret ;
6365import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .createJobToChangePermissionsOnPvHostPath ;
66+ import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .readRuntimeResource ;
6467import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
6568import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressHostRouting ;
66- import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
6769import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
6870import static oracle .weblogic .kubernetes .utils .CommonTestUtils .runClientInsidePod ;
6971import static oracle .weblogic .kubernetes .utils .CommonTestUtils .runJavacInsidePod ;
7476import static oracle .weblogic .kubernetes .utils .DbUtils .createRcuSchema ;
7577import static oracle .weblogic .kubernetes .utils .DbUtils .deleteOracleDB ;
7678import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
77- import static oracle .weblogic .kubernetes .utils .ExecCommand .exec ;
7879import static oracle .weblogic .kubernetes .utils .FileUtils .copyFileToPod ;
7980import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyDomainReady ;
8081import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyEMconsoleAccess ;
8182import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
8283import static oracle .weblogic .kubernetes .utils .ImageUtils .createMiiImageAndVerify ;
8384import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
8485import static oracle .weblogic .kubernetes .utils .ImageUtils .imageRepoLoginAndPushImageToRegistry ;
86+ import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .installAndVerifyTraefik ;
8587import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
8688import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
8789import static oracle .weblogic .kubernetes .utils .PatchDomainUtils .patchDomainResourceServerStartPolicy ;
9395import static oracle .weblogic .kubernetes .utils .SecretUtils .createOpsswalletpasswordSecret ;
9496import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
9597import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
98+ import static org .assertj .core .api .Assertions .assertThat ;
9699import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
97100import static org .junit .jupiter .api .Assertions .assertEquals ;
98101import static org .junit .jupiter .api .Assertions .assertNotNull ;
106109@ DisplayName ("Test to create FMW model in image domain and WebLogic domain using Oracle "
107110 + "database created using Oracle Database Operator" )
108111@ IntegrationTest
109- @ Tag ("oke-sequential " )
112+ @ Tag ("oke-gate " )
110113@ Tag ("kind-parallel" )
111114class ItDBOperator {
112115
113116 private static String dbNamespace = null ;
114117 private static String opNamespace = null ;
115118 private static String fmwDomainNamespace = null ;
116119 private static String wlsDomainNamespace = null ;
120+ private static String traefikNamespace = null ;
117121 private static String fmwMiiImage = null ;
118122
119123 private static final String RCUSCHEMAPREFIX = "FMWDOMAINMII" ;
@@ -124,6 +128,7 @@ class ItDBOperator {
124128 private static String dbUrl = null ;
125129 private static String dbName = "my-oracle-sidb" ;
126130 private static LoggingFacade logger = null ;
131+ private static HelmParams traefikHelmParams ;
127132
128133 private String fmwDomainUid = "fmwdomain-mii-db" ;
129134 private String adminServerName = "admin-server" ;
@@ -153,6 +158,7 @@ class ItDBOperator {
153158 private final String wlsClusterResName = wlsDomainUid + "-" + clusterName ;
154159
155160 private static String hostHeader ;
161+ private static TraefikParams traefikParams ;
156162
157163 /**
158164 * Start DB service and create RCU schema.
@@ -162,7 +168,7 @@ class ItDBOperator {
162168 * @param namespaces injected by JUnit
163169 */
164170 @ BeforeAll
165- public static void initAll (@ Namespaces (4 ) List <String > namespaces ) {
171+ public static void initAll (@ Namespaces (5 ) List <String > namespaces ) {
166172
167173 logger = getLogger ();
168174 logger .info ("Assign a unique namespace for DB and RCU" );
@@ -181,6 +187,18 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
181187 assertNotNull (namespaces .get (3 ), "Namespace is null" );
182188 wlsDomainNamespace = namespaces .get (3 );
183189
190+ // get a unique Traefik namespace
191+ logger .info ("Get a unique namespace for Traefik" );
192+ assertNotNull (namespaces .get (4 ), "Namespace list is null" );
193+ traefikNamespace = namespaces .get (4 );
194+
195+ // install and verify Traefik
196+ if (OKE_CLUSTER_PRIVATEIP ) {
197+ traefikParams =
198+ installAndVerifyTraefik (traefikNamespace , 0 , 0 );
199+ traefikHelmParams = traefikParams .getHelmParams ();
200+ }
201+
184202 // Create the repo secret to pull the image
185203 // this secret is used only for non-kind cluster
186204 createBaseRepoSecret (fmwDomainNamespace );
@@ -199,6 +217,17 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
199217 installAndVerifyOperator (opNamespace , fmwDomainNamespace , wlsDomainNamespace );
200218 }
201219
220+ @ AfterAll
221+ void tearDown () {
222+ // uninstall Traefik
223+ if (traefikHelmParams != null ) {
224+ assertThat (uninstallTraefik (traefikHelmParams ))
225+ .as ("Test uninstallTraefik returns true" )
226+ .withFailMessage ("uninstallTraefik() did not return true" )
227+ .isTrue ();
228+ }
229+ }
230+
202231 /**
203232 * Create a basic FMW model in image domain using the database created by DB Operator. Verify Pod is ready and service
204233 * exists for both admin server and managed servers. Verify EM console is accessible.
@@ -553,34 +582,28 @@ private void runJmsClientOnAdminPod(String action, String queue) {
553582 * @returns true if MBean is found otherwise false
554583 **/
555584 private boolean checkJmsServerRuntime (String jmsServer , String managedServer ) {
556- ExecResult result = null ;
557- int adminServiceNodePort
558- = getServiceNodePort (wlsDomainNamespace , getExternalServicePodName (wlsAdminServerPodName ), "default" );
559- String hostAndPort = getHostAndPort (adminSvcExtRouteHost , adminServiceNodePort );
560- StringBuffer curlString = new StringBuffer ("status=$(curl --user "
561- + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + " " );
562- if (TestConstants .KIND_CLUSTER
563- && !TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
564- hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT ;
565- curlString .append (" -H 'host: " + hostHeader + "' " );
566- }
567- curlString .append ("http://" + hostAndPort )
568- .append ("/management/weblogic/latest/domainRuntime/serverRuntimes/" )
569- .append (managedServer )
570- .append ("/JMSRuntime/JMSServers/" )
571- .append (jmsServer )
572- .append (" --silent --show-error " )
573- .append (" -o /dev/null" )
574- .append (" -w %{http_code});" )
575- .append ("echo ${status}" );
576- logger .info ("checkJmsServerRuntime: curl command {0}" , new String (curlString ));
577585 testUntil (
578- assertDoesNotThrow (() -> () -> exec (curlString .toString (), true ).stdout ().contains ("200" )),
586+ assertDoesNotThrow (() -> () -> getJMSRunTimeOutput (jmsServer ,
587+ managedServer ).contains ("destinationsCurrentCount" )),
579588 logger ,
580589 "JMS Server Service to migrate" );
581590 return true ;
582591 }
583592
593+ private String getJMSRunTimeOutput (String jmsServer , String managedServer ) {
594+ String output = readRuntimeResource (
595+ adminSvcExtHost ,
596+ wlsDomainNamespace ,
597+ wlsAdminServerPodName ,
598+ "/management/weblogic/latest/domainRuntime/serverRuntimes/"
599+ + managedServer
600+ + "/JMSRuntime/JMSServers/"
601+ + jmsServer ,
602+ "checkJmsServerRuntime" );
603+ logger .info ("Got output " + output );
604+ return output ;
605+ }
606+
584607 /*
585608 * Verify the Persistent Store Runtimes through REST API.
586609 * Get the specific Persistent Store Runtime on specified managed server.
@@ -589,31 +612,19 @@ private boolean checkJmsServerRuntime(String jmsServer, String managedServer) {
589612 * @returns true if MBean is found otherwise false
590613 **/
591614 private boolean checkStoreRuntime (String storeName , String managedServer ) {
592- ExecResult result = null ;
593- int adminServiceNodePort
594- = getServiceNodePort (wlsDomainNamespace , getExternalServicePodName (wlsAdminServerPodName ), "default" );
595- String hostAndPort = getHostAndPort (adminSvcExtRouteHost , adminServiceNodePort );
596- StringBuffer curlString = new StringBuffer ("status=$(curl --user "
597- + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + " " );
598- if (TestConstants .KIND_CLUSTER
599- && !TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
600- hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT ;
601- curlString .append (" -H 'host: " + hostHeader + "' " );
602- }
603- curlString .append ("http://" + hostAndPort )
604- .append ("/management/weblogic/latest/domainRuntime/serverRuntimes/" )
605- .append (managedServer )
606- .append ("/persistentStoreRuntimes/" )
607- .append (storeName )
608- .append (" --silent --show-error " )
609- .append (" -o /dev/null" )
610- .append (" -w %{http_code});" )
611- .append ("echo ${status}" );
612- logger .info ("checkStoreRuntime: curl command {0}" , new String (curlString ));
613615 testUntil (
614- assertDoesNotThrow (() -> () -> exec (curlString .toString (), true ).stdout ().contains ("200" )),
616+ assertDoesNotThrow (() -> () -> readRuntimeResource (
617+ adminSvcExtHost ,
618+ wlsDomainNamespace ,
619+ wlsAdminServerPodName ,
620+ "/management/weblogic/latest/domainRuntime/serverRuntimes/"
621+ + managedServer
622+ + "/persistentStoreRuntimes/"
623+ + storeName ,
624+ "checkPersistentStoreRuntime" ).contains ("PersistentStoreRuntime" )),
615625 logger ,
616626 "PersistentStoreRuntimes Service to migrate" );
627+
617628 return true ;
618629 }
619630
@@ -627,28 +638,16 @@ private boolean checkStoreRuntime(String storeName, String managedServer) {
627638 * @returns true if MBean is found otherwise false
628639 **/
629640 private boolean checkJtaRecoveryServiceRuntime (String managedServer , String recoveryService , String active ) {
630- ExecResult result = null ;
631- int adminServiceNodePort
632- = getServiceNodePort (wlsDomainNamespace , getExternalServicePodName (wlsAdminServerPodName ), "default" );
633- String hostAndPort = getHostAndPort (adminSvcExtRouteHost , adminServiceNodePort );
634- StringBuffer curlString = new StringBuffer ("curl --user "
635- + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + " " );
636- if (TestConstants .KIND_CLUSTER
637- && !TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
638- hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT ;
639- curlString .append (" -H 'host: " + hostHeader + "' " );
640- }
641- curlString .append ("\" http://" + hostAndPort )
642- .append ("/management/weblogic/latest/domainRuntime/serverRuntimes/" )
643- .append (managedServer )
644- .append ("/JTARuntime/recoveryRuntimeMBeans/" )
645- .append (recoveryService )
646- .append ("?fields=active&links=none\" " )
647- .append (" --show-error " );
648- logger .info ("checkJtaRecoveryServiceRuntime: curl command {0}" , new String (curlString ));
649641 testUntil (
650- assertDoesNotThrow (() -> () -> exec (curlString .toString (), true )
651- .stdout ().contains ("\" active\" : " + active )),
642+ assertDoesNotThrow (() -> () -> readRuntimeResource (
643+ adminSvcExtHost ,
644+ wlsDomainNamespace ,
645+ wlsAdminServerPodName ,
646+ "/management/weblogic/latest/domainRuntime/serverRuntimes/"
647+ + managedServer
648+ + "/JTARuntime/recoveryRuntimeMBeans/"
649+ + recoveryService ,
650+ "checkRecoveryServiceRuntime" ).contains ("\" active\" : " + active )),
652651 logger ,
653652 "JTA Recovery Service to migrate" );
654653 return true ;
0 commit comments