Skip to content

Commit

Permalink
Merge branch 'okeconv42' into 'release/4.2'
Browse files Browse the repository at this point in the history
Backport changes for Converted DBOperator tests from external to internal run in OKE

See merge request weblogic-cloud/weblogic-kubernetes-operator!4742
  • Loading branch information
rjeberhard committed Jul 3, 2024
2 parents 934587e + 1df2aa8 commit 46cb68c
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 99 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile.oke
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pipeline {
)
string(name: 'NODE_SHAPE',
description: '',
defaultValue: "VM.Standard.E3.Flex"
defaultValue: "VM.Standard.E4.Flex"
)
string(name: 'MOUNT_TARGET_OCID',
description: 'only for debug runs on wko-oke-dev',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import io.kubernetes.client.openapi.models.V1LocalObjectReference;
import oracle.weblogic.domain.ClusterResource;
import oracle.weblogic.domain.DomainResource;
import oracle.weblogic.kubernetes.actions.impl.TraefikParams;
import oracle.weblogic.kubernetes.actions.impl.primitive.Command;
import oracle.weblogic.kubernetes.actions.impl.primitive.CommandParams;
import oracle.weblogic.kubernetes.actions.impl.primitive.HelmParams;
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
import oracle.weblogic.kubernetes.annotations.Namespaces;
import oracle.weblogic.kubernetes.logging.LoggingFacade;
Expand All @@ -41,18 +43,18 @@
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME;
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER_PRIVATEIP;
import static oracle.weblogic.kubernetes.TestConstants.SKIP_CLEANUP;
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR;
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
import static oracle.weblogic.kubernetes.actions.ActionConstants.WORK_DIR;
import static oracle.weblogic.kubernetes.actions.TestActions.createDomainCustomResource;
import static oracle.weblogic.kubernetes.actions.TestActions.execCommand;
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
import static oracle.weblogic.kubernetes.actions.TestActions.patchDomainCustomResource;
import static oracle.weblogic.kubernetes.actions.TestActions.scaleCluster;
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallTraefik;
import static oracle.weblogic.kubernetes.actions.impl.primitive.Command.defaultCommandParams;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterAndVerify;
Expand All @@ -61,9 +63,9 @@
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createDomainResourceWithLogHome;
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createDomainSecret;
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createJobToChangePermissionsOnPvHostPath;
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.readRuntimeResource;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.runClientInsidePod;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.runJavacInsidePod;
Expand All @@ -74,14 +76,14 @@
import static oracle.weblogic.kubernetes.utils.DbUtils.createRcuSchema;
import static oracle.weblogic.kubernetes.utils.DbUtils.deleteOracleDB;
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
import static oracle.weblogic.kubernetes.utils.FileUtils.copyFileToPod;
import static oracle.weblogic.kubernetes.utils.FmwUtils.verifyDomainReady;
import static oracle.weblogic.kubernetes.utils.FmwUtils.verifyEMconsoleAccess;
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
import static oracle.weblogic.kubernetes.utils.ImageUtils.createMiiImageAndVerify;
import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret;
import static oracle.weblogic.kubernetes.utils.ImageUtils.imageRepoLoginAndPushImageToRegistry;
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyTraefik;
import static oracle.weblogic.kubernetes.utils.OKDUtils.createRouteForOKD;
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
import static oracle.weblogic.kubernetes.utils.PatchDomainUtils.patchDomainResourceServerStartPolicy;
Expand All @@ -93,6 +95,7 @@
import static oracle.weblogic.kubernetes.utils.SecretUtils.createOpsswalletpasswordSecret;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -106,14 +109,15 @@
@DisplayName("Test to create FMW model in image domain and WebLogic domain using Oracle "
+ "database created using Oracle Database Operator")
@IntegrationTest
@Tag("oke-sequential")
@Tag("oke-gate")
@Tag("kind-parallel")
class ItDBOperator {

private static String dbNamespace = null;
private static String opNamespace = null;
private static String fmwDomainNamespace = null;
private static String wlsDomainNamespace = null;
private static String traefikNamespace = null;
private static String fmwMiiImage = null;

private static final String RCUSCHEMAPREFIX = "FMWDOMAINMII";
Expand All @@ -124,6 +128,7 @@ class ItDBOperator {
private static String dbUrl = null;
private static String dbName = "my-oracle-sidb";
private static LoggingFacade logger = null;
private static HelmParams traefikHelmParams;

private String fmwDomainUid = "fmwdomain-mii-db";
private String adminServerName = "admin-server";
Expand Down Expand Up @@ -153,6 +158,7 @@ class ItDBOperator {
private final String wlsClusterResName = wlsDomainUid + "-" + clusterName;

private static String hostHeader;
private static TraefikParams traefikParams;

/**
* Start DB service and create RCU schema.
Expand All @@ -162,7 +168,7 @@ class ItDBOperator {
* @param namespaces injected by JUnit
*/
@BeforeAll
public static void initAll(@Namespaces(4) List<String> namespaces) {
public static void initAll(@Namespaces(5) List<String> namespaces) {

logger = getLogger();
logger.info("Assign a unique namespace for DB and RCU");
Expand All @@ -181,6 +187,18 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
assertNotNull(namespaces.get(3), "Namespace is null");
wlsDomainNamespace = namespaces.get(3);

// get a unique Traefik namespace
logger.info("Get a unique namespace for Traefik");
assertNotNull(namespaces.get(4), "Namespace list is null");
traefikNamespace = namespaces.get(4);

// install and verify Traefik
if (OKE_CLUSTER_PRIVATEIP) {
traefikParams =
installAndVerifyTraefik(traefikNamespace, 0, 0);
traefikHelmParams = traefikParams.getHelmParams();
}

// Create the repo secret to pull the image
// this secret is used only for non-kind cluster
createBaseRepoSecret(fmwDomainNamespace);
Expand All @@ -199,6 +217,17 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
installAndVerifyOperator(opNamespace, fmwDomainNamespace, wlsDomainNamespace);
}

@AfterAll
void tearDown() {
// uninstall Traefik
if (traefikHelmParams != null) {
assertThat(uninstallTraefik(traefikHelmParams))
.as("Test uninstallTraefik returns true")
.withFailMessage("uninstallTraefik() did not return true")
.isTrue();
}
}

/**
* Create a basic FMW model in image domain using the database created by DB Operator. Verify Pod is ready and service
* exists for both admin server and managed servers. Verify EM console is accessible.
Expand Down Expand Up @@ -553,34 +582,28 @@ private void runJmsClientOnAdminPod(String action, String queue) {
* @returns true if MBean is found otherwise false
**/
private boolean checkJmsServerRuntime(String jmsServer, String managedServer) {
ExecResult result = null;
int adminServiceNodePort
= getServiceNodePort(wlsDomainNamespace, getExternalServicePodName(wlsAdminServerPodName), "default");
String hostAndPort = getHostAndPort(adminSvcExtRouteHost, adminServiceNodePort);
StringBuffer curlString = new StringBuffer("status=$(curl --user "
+ ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + " ");
if (TestConstants.KIND_CLUSTER
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
curlString.append(" -H 'host: " + hostHeader + "' ");
}
curlString.append("http://" + hostAndPort)
.append("/management/weblogic/latest/domainRuntime/serverRuntimes/")
.append(managedServer)
.append("/JMSRuntime/JMSServers/")
.append(jmsServer)
.append(" --silent --show-error ")
.append(" -o /dev/null")
.append(" -w %{http_code});")
.append("echo ${status}");
logger.info("checkJmsServerRuntime: curl command {0}", new String(curlString));
testUntil(
assertDoesNotThrow(() -> () -> exec(curlString.toString(), true).stdout().contains("200")),
assertDoesNotThrow(() -> () -> getJMSRunTimeOutput(jmsServer,
managedServer).contains("destinationsCurrentCount")),
logger,
"JMS Server Service to migrate");
return true;
}

private String getJMSRunTimeOutput(String jmsServer, String managedServer) {
String output = readRuntimeResource(
adminSvcExtHost,
wlsDomainNamespace,
wlsAdminServerPodName,
"/management/weblogic/latest/domainRuntime/serverRuntimes/"
+ managedServer
+ "/JMSRuntime/JMSServers/"
+ jmsServer,
"checkJmsServerRuntime");
logger.info("Got output " + output);
return output;
}

/*
* Verify the Persistent Store Runtimes through REST API.
* Get the specific Persistent Store Runtime on specified managed server.
Expand All @@ -589,31 +612,19 @@ private boolean checkJmsServerRuntime(String jmsServer, String managedServer) {
* @returns true if MBean is found otherwise false
**/
private boolean checkStoreRuntime(String storeName, String managedServer) {
ExecResult result = null;
int adminServiceNodePort
= getServiceNodePort(wlsDomainNamespace, getExternalServicePodName(wlsAdminServerPodName), "default");
String hostAndPort = getHostAndPort(adminSvcExtRouteHost, adminServiceNodePort);
StringBuffer curlString = new StringBuffer("status=$(curl --user "
+ ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + " ");
if (TestConstants.KIND_CLUSTER
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
curlString.append(" -H 'host: " + hostHeader + "' ");
}
curlString.append("http://" + hostAndPort)
.append("/management/weblogic/latest/domainRuntime/serverRuntimes/")
.append(managedServer)
.append("/persistentStoreRuntimes/")
.append(storeName)
.append(" --silent --show-error ")
.append(" -o /dev/null")
.append(" -w %{http_code});")
.append("echo ${status}");
logger.info("checkStoreRuntime: curl command {0}", new String(curlString));
testUntil(
assertDoesNotThrow(() -> () -> exec(curlString.toString(), true).stdout().contains("200")),
assertDoesNotThrow(() -> () -> readRuntimeResource(
adminSvcExtHost,
wlsDomainNamespace,
wlsAdminServerPodName,
"/management/weblogic/latest/domainRuntime/serverRuntimes/"
+ managedServer
+ "/persistentStoreRuntimes/"
+ storeName,
"checkPersistentStoreRuntime").contains("PersistentStoreRuntime")),
logger,
"PersistentStoreRuntimes Service to migrate");

return true;
}

Expand All @@ -627,28 +638,16 @@ private boolean checkStoreRuntime(String storeName, String managedServer) {
* @returns true if MBean is found otherwise false
**/
private boolean checkJtaRecoveryServiceRuntime(String managedServer, String recoveryService, String active) {
ExecResult result = null;
int adminServiceNodePort
= getServiceNodePort(wlsDomainNamespace, getExternalServicePodName(wlsAdminServerPodName), "default");
String hostAndPort = getHostAndPort(adminSvcExtRouteHost, adminServiceNodePort);
StringBuffer curlString = new StringBuffer("curl --user "
+ ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + " ");
if (TestConstants.KIND_CLUSTER
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
curlString.append(" -H 'host: " + hostHeader + "' ");
}
curlString.append("\"http://" + hostAndPort)
.append("/management/weblogic/latest/domainRuntime/serverRuntimes/")
.append(managedServer)
.append("/JTARuntime/recoveryRuntimeMBeans/")
.append(recoveryService)
.append("?fields=active&links=none\"")
.append(" --show-error ");
logger.info("checkJtaRecoveryServiceRuntime: curl command {0}", new String(curlString));
testUntil(
assertDoesNotThrow(() -> () -> exec(curlString.toString(), true)
.stdout().contains("\"active\": " + active)),
assertDoesNotThrow(() -> () -> readRuntimeResource(
adminSvcExtHost,
wlsDomainNamespace,
wlsAdminServerPodName,
"/management/weblogic/latest/domainRuntime/serverRuntimes/"
+ managedServer
+ "/JTARuntime/recoveryRuntimeMBeans/"
+ recoveryService,
"checkRecoveryServiceRuntime").contains("\"active\": " + active)),
logger,
"JTA Recovery Service to migrate");
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
*/
@DisplayName("Test to creat a FMW domain in persistent volume using WDT")
@IntegrationTest
@Tag("oke-sequential")
@Tag("oke-gate")
@Tag("kind-sequential")
@Tag("okd-fmw-cert")
class ItFmwDomainInPVUsingWDT {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
@Tag("okd-fmw-cert")
@IntegrationTest
@Tag("olcne-sequential")
@Tag("oke-sequential1")
@Tag("oke-gate")
class ItFmwDomainInPVUsingWLST {

private static String dbNamespace = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
@DisplayName("Test for initializeDomainOnPV when user per-creates RCU")
@IntegrationTest
@Tag("kind-sequential")
@Tag("oke-sequential1")
@Tag("oke-gate")
public class ItFmwDomainInPvUserCreateRcu {

private static String opNamespace = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_PREFIX;
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_SECRET_NAME;
import static oracle.weblogic.kubernetes.TestConstants.DB_IMAGE_TO_USE_IN_SPEC;
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_IMAGES_PREFIX;
import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_HOST;
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TO_USE_IN_SPEC;
Expand All @@ -64,9 +63,9 @@
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
import static oracle.weblogic.kubernetes.utils.DbUtils.createOracleDBUsingOperator;
import static oracle.weblogic.kubernetes.utils.DbUtils.createRcuAccessSecret;
import static oracle.weblogic.kubernetes.utils.DbUtils.createRcuSchema;
import static oracle.weblogic.kubernetes.utils.DbUtils.startOracleDB;
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainResourceOnPv;
import static oracle.weblogic.kubernetes.utils.DomainUtils.deleteDomainResource;
Expand Down Expand Up @@ -94,7 +93,7 @@
@DisplayName("Test to create a FMW domain in persistent volume with new simplified feature")
@IntegrationTest
@Tag("kind-sequential")
@Tag("oke-sequential1")
@Tag("oke-gate")
@Tag("okd-fmw-cert")
class ItFmwDomainOnPV {

Expand Down Expand Up @@ -144,13 +143,18 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {

DOMAINHOMEPREFIX = "/shared/" + domainNamespace + "/domains/";

// start DB
//install Oracle Database Operator
String dbName = "fmwdomainonpv1" + "my-oracle-db";
logger.info("Create Oracle DB in namespace: {0} ", dbNamespace);
createBaseRepoSecret(dbNamespace);
dbUrl = assertDoesNotThrow(() -> createOracleDBUsingOperator(dbName, RCUSYSPASSWORD, dbNamespace));
/*
logger.info("Start DB in namespace: {0}, dbListenerPort: {1}, dbUrl: {2}, dbImage: {3}",
dbNamespace, dbListenerPort, dbUrl, DB_IMAGE_TO_USE_IN_SPEC);
assertDoesNotThrow(() -> startOracleDB(DB_IMAGE_TO_USE_IN_SPEC, getNextFreePort(), dbNamespace, dbListenerPort),
String.format("Failed to start Oracle DB in the namespace %s with dbUrl %s, dbListenerPost %s",
dbNamespace, dbUrl, dbListenerPort));

*/
// install operator and verify its running in ready state
HelmParams opHelmParams =
new HelmParams().releaseName(OPERATOR_RELEASE_NAME)
Expand Down
Loading

0 comments on commit 46cb68c

Please sign in to comment.