Skip to content

Commit b5b4bc9

Browse files
marinakogrjeberhard
authored andcommitted
Converted DBOperator tests from external to internal run in OKE
1 parent 8bb0421 commit b5b4bc9

10 files changed

+142
-93
lines changed

Jenkinsfile.oke

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pipeline {
140140
)
141141
string(name: 'NODE_SHAPE',
142142
description: '',
143-
defaultValue: "VM.Standard.E3.Flex"
143+
defaultValue: "VM.Standard.E4.Flex"
144144
)
145145
string(name: 'MOUNT_TARGET_OCID',
146146
description: 'only for debug runs on wko-oke-dev',

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItDBOperator.java

Lines changed: 75 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import io.kubernetes.client.openapi.models.V1LocalObjectReference;
1616
import oracle.weblogic.domain.ClusterResource;
1717
import oracle.weblogic.domain.DomainResource;
18+
import oracle.weblogic.kubernetes.actions.impl.TraefikParams;
1819
import oracle.weblogic.kubernetes.actions.impl.primitive.Command;
1920
import oracle.weblogic.kubernetes.actions.impl.primitive.CommandParams;
21+
import oracle.weblogic.kubernetes.actions.impl.primitive.HelmParams;
2022
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
2123
import oracle.weblogic.kubernetes.annotations.Namespaces;
2224
import oracle.weblogic.kubernetes.logging.LoggingFacade;
@@ -41,18 +43,18 @@
4143
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME;
4244
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
4345
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
46+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER_PRIVATEIP;
4447
import static oracle.weblogic.kubernetes.TestConstants.SKIP_CLEANUP;
4548
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
46-
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
4749
import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR;
4850
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
4951
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
5052
import static oracle.weblogic.kubernetes.actions.ActionConstants.WORK_DIR;
5153
import static oracle.weblogic.kubernetes.actions.TestActions.createDomainCustomResource;
5254
import static oracle.weblogic.kubernetes.actions.TestActions.execCommand;
53-
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
5455
import static oracle.weblogic.kubernetes.actions.TestActions.patchDomainCustomResource;
5556
import static oracle.weblogic.kubernetes.actions.TestActions.scaleCluster;
57+
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallTraefik;
5658
import static oracle.weblogic.kubernetes.actions.impl.primitive.Command.defaultCommandParams;
5759
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
5860
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterAndVerify;
@@ -61,9 +63,9 @@
6163
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createDomainResourceWithLogHome;
6264
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createDomainSecret;
6365
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createJobToChangePermissionsOnPvHostPath;
66+
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.readRuntimeResource;
6467
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
6568
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting;
66-
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
6769
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
6870
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.runClientInsidePod;
6971
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.runJavacInsidePod;
@@ -74,14 +76,14 @@
7476
import static oracle.weblogic.kubernetes.utils.DbUtils.createRcuSchema;
7577
import static oracle.weblogic.kubernetes.utils.DbUtils.deleteOracleDB;
7678
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
77-
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
7879
import static oracle.weblogic.kubernetes.utils.FileUtils.copyFileToPod;
7980
import static oracle.weblogic.kubernetes.utils.FmwUtils.verifyDomainReady;
8081
import static oracle.weblogic.kubernetes.utils.FmwUtils.verifyEMconsoleAccess;
8182
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
8283
import static oracle.weblogic.kubernetes.utils.ImageUtils.createMiiImageAndVerify;
8384
import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret;
8485
import static oracle.weblogic.kubernetes.utils.ImageUtils.imageRepoLoginAndPushImageToRegistry;
86+
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyTraefik;
8587
import static oracle.weblogic.kubernetes.utils.OKDUtils.createRouteForOKD;
8688
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
8789
import static oracle.weblogic.kubernetes.utils.PatchDomainUtils.patchDomainResourceServerStartPolicy;
@@ -93,6 +95,7 @@
9395
import static oracle.weblogic.kubernetes.utils.SecretUtils.createOpsswalletpasswordSecret;
9496
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
9597
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
98+
import static org.assertj.core.api.Assertions.assertThat;
9699
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
97100
import static org.junit.jupiter.api.Assertions.assertEquals;
98101
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -106,16 +109,19 @@
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")
111114
class 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

123+
private static String hostAndPort = null;
124+
119125
private static final String RCUSCHEMAPREFIX = "FMWDOMAINMII";
120126
private static final String RCUSYSPASSWORD = "Oradoc_db1";
121127
private static final String RCUSCHEMAPASSWORD = "Oradoc_db1";
@@ -124,6 +130,7 @@ class ItDBOperator {
124130
private static String dbUrl = null;
125131
private static String dbName = "my-oracle-sidb";
126132
private static LoggingFacade logger = null;
133+
private static HelmParams traefikHelmParams;
127134

128135
private String fmwDomainUid = "fmwdomain-mii-db";
129136
private String adminServerName = "admin-server";
@@ -153,6 +160,9 @@ class ItDBOperator {
153160
private final String wlsClusterResName = wlsDomainUid + "-" + clusterName;
154161

155162
private static String hostHeader;
163+
private String ingressIP;
164+
private static TraefikParams traefikParams;
165+
private String ingressClassName;
156166

157167
/**
158168
* Start DB service and create RCU schema.
@@ -162,7 +172,7 @@ class ItDBOperator {
162172
* @param namespaces injected by JUnit
163173
*/
164174
@BeforeAll
165-
public static void initAll(@Namespaces(4) List<String> namespaces) {
175+
public static void initAll(@Namespaces(5) List<String> namespaces) {
166176

167177
logger = getLogger();
168178
logger.info("Assign a unique namespace for DB and RCU");
@@ -181,6 +191,19 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
181191
assertNotNull(namespaces.get(3), "Namespace is null");
182192
wlsDomainNamespace = namespaces.get(3);
183193

194+
// get a unique Traefik namespace
195+
logger.info("Get a unique namespace for Traefik");
196+
assertNotNull(namespaces.get(4), "Namespace list is null");
197+
traefikNamespace = namespaces.get(4);
198+
199+
// install and verify Traefik
200+
if (OKE_CLUSTER_PRIVATEIP) {
201+
traefikParams =
202+
installAndVerifyTraefik(traefikNamespace, 0, 0);
203+
traefikHelmParams = traefikParams.getHelmParams();
204+
}
205+
206+
184207
// Create the repo secret to pull the image
185208
// this secret is used only for non-kind cluster
186209
createBaseRepoSecret(fmwDomainNamespace);
@@ -199,6 +222,17 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
199222
installAndVerifyOperator(opNamespace, fmwDomainNamespace, wlsDomainNamespace);
200223
}
201224

225+
@AfterAll
226+
void tearDown() {
227+
// uninstall Traefik
228+
if (traefikHelmParams != null) {
229+
assertThat(uninstallTraefik(traefikHelmParams))
230+
.as("Test uninstallTraefik returns true")
231+
.withFailMessage("uninstallTraefik() did not return true")
232+
.isTrue();
233+
}
234+
}
235+
202236
/**
203237
* Create a basic FMW model in image domain using the database created by DB Operator. Verify Pod is ready and service
204238
* exists for both admin server and managed servers. Verify EM console is accessible.
@@ -553,34 +587,28 @@ private void runJmsClientOnAdminPod(String action, String queue) {
553587
* @returns true if MBean is found otherwise false
554588
**/
555589
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));
577590
testUntil(
578-
assertDoesNotThrow(() -> () -> exec(curlString.toString(), true).stdout().contains("200")),
591+
assertDoesNotThrow(() -> () -> getJMSRunTimeOutput(jmsServer,
592+
managedServer).contains("destinationsCurrentCount")),
579593
logger,
580594
"JMS Server Service to migrate");
581595
return true;
582596
}
583597

598+
private String getJMSRunTimeOutput(String jmsServer, String managedServer) {
599+
String output = readRuntimeResource(
600+
adminSvcExtHost,
601+
wlsDomainNamespace,
602+
wlsAdminServerPodName,
603+
"/management/weblogic/latest/domainRuntime/serverRuntimes/"
604+
+ managedServer
605+
+ "/JMSRuntime/JMSServers/"
606+
+ jmsServer,
607+
"checkJmsServerRuntime");
608+
logger.info("Got output " + output);
609+
return output;
610+
}
611+
584612
/*
585613
* Verify the Persistent Store Runtimes through REST API.
586614
* Get the specific Persistent Store Runtime on specified managed server.
@@ -589,31 +617,19 @@ private boolean checkJmsServerRuntime(String jmsServer, String managedServer) {
589617
* @returns true if MBean is found otherwise false
590618
**/
591619
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));
613620
testUntil(
614-
assertDoesNotThrow(() -> () -> exec(curlString.toString(), true).stdout().contains("200")),
621+
assertDoesNotThrow(() -> () -> readRuntimeResource(
622+
adminSvcExtHost,
623+
wlsDomainNamespace,
624+
wlsAdminServerPodName,
625+
"/management/weblogic/latest/domainRuntime/serverRuntimes/"
626+
+ managedServer
627+
+ "/persistentStoreRuntimes/"
628+
+ storeName,
629+
"checkPersistentStoreRuntime").contains("PersistentStoreRuntime")),
615630
logger,
616631
"PersistentStoreRuntimes Service to migrate");
632+
617633
return true;
618634
}
619635

@@ -627,28 +643,16 @@ private boolean checkStoreRuntime(String storeName, String managedServer) {
627643
* @returns true if MBean is found otherwise false
628644
**/
629645
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));
649646
testUntil(
650-
assertDoesNotThrow(() -> () -> exec(curlString.toString(), true)
651-
.stdout().contains("\"active\": " + active)),
647+
assertDoesNotThrow(() -> () -> readRuntimeResource(
648+
adminSvcExtHost,
649+
wlsDomainNamespace,
650+
wlsAdminServerPodName,
651+
"/management/weblogic/latest/domainRuntime/serverRuntimes/"
652+
+ managedServer
653+
+ "/JTARuntime/recoveryRuntimeMBeans/"
654+
+ recoveryService,
655+
"checkRecoveryServiceRuntime").contains("\"active\": " + active)),
652656
logger,
653657
"JTA Recovery Service to migrate");
654658
return true;

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDomainInPVUsingWDT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
*/
6060
@DisplayName("Test to creat a FMW domain in persistent volume using WDT")
6161
@IntegrationTest
62-
@Tag("oke-sequential")
62+
@Tag("oke-gate")
6363
@Tag("kind-sequential")
6464
@Tag("okd-fmw-cert")
6565
class ItFmwDomainInPVUsingWDT {

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDomainInPVUsingWLST.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
@Tag("okd-fmw-cert")
7373
@IntegrationTest
7474
@Tag("olcne-sequential")
75-
@Tag("oke-sequential")
75+
@Tag("oke-gate")
7676
class ItFmwDomainInPVUsingWLST {
7777

7878
private static String dbNamespace = null;

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDomainInPvUserCreateRcu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
@DisplayName("Test for initializeDomainOnPV when user per-creates RCU")
9999
@IntegrationTest
100100
@Tag("kind-sequential")
101-
@Tag("oke-sequential")
101+
@Tag("oke-gate")
102102
public class ItFmwDomainInPvUserCreateRcu {
103103

104104
private static String opNamespace = null;

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDomainOnPV.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
@DisplayName("Test to create a FMW domain in persistent volume with new simplified feature")
9494
@IntegrationTest
9595
@Tag("kind-parallel")
96-
@Tag("oke-sequential")
96+
@Tag("oke-gate")
9797
@Tag("okd-fmw-cert")
9898
@Tag("olcne-sequential")
9999
class ItFmwDomainOnPV {

0 commit comments

Comments
 (0)