Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1d08f2e
create wls-srg profile
xiancao Jan 26, 2022
eb41716
add wls-srg profile
xiancao Jan 26, 2022
92a05d6
create wls-srg profile
xiancao Jan 28, 2022
98c7818
get the latest release/3.3
xiancao Jan 28, 2022
bb61261
cleanup
xiancao Jan 28, 2022
de86c9f
resolve merge conflicts
xiancao Jan 28, 2022
45d7f3c
fix syntax error
xiancao Jan 28, 2022
dea42d3
restore jenkinsScript.sh
xiancao Jan 28, 2022
1e4515b
Merge branch 'release/3.3' of https://github.com/oracle/weblogic-kube…
xiancao Jan 31, 2022
c1520a8
add more tests to wls-srg
xiancao Jan 31, 2022
0a778cd
add more tests to wls-srg
xiancao Jan 31, 2022
a0f206f
get latest release/3.3
xiancao Jan 31, 2022
4d87885
add more tests to wls-srg
xiancao Feb 1, 2022
e9febd2
Merge branch 'release/3.3' of https://github.com/oracle/weblogic-kube…
xiancao Feb 1, 2022
06a19fc
fix class name
xiancao Feb 1, 2022
304fa44
Merge branch 'release/3.3' of https://github.com/oracle/weblogic-kube…
xiancao Feb 3, 2022
5c5830d
address Pani's comments
xiancao Feb 7, 2022
bd91529
update copyright
xiancao Feb 7, 2022
9df7b1a
address Pani's comments
xiancao Feb 8, 2022
2c4e33f
Merge branch 'release/3.3' of https://github.com/oracle/weblogic-kube…
xiancao Feb 8, 2022
b884a2e
address Pani's comments
xiancao Feb 9, 2022
50a41ab
address Vanaja's comments
xiancao Feb 10, 2022
b444e69
Merge branch 'release/3.3' of https://github.com/oracle/weblogic-kube…
xiancao Feb 10, 2022
9b68d68
cleanup
xiancao Feb 10, 2022
0ef3cc9
address Pani's comments
xiancao Feb 10, 2022
e3e07d8
address Pani's comments
xiancao Feb 11, 2022
b90f360
address Vanaja's comments
xiancao Feb 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 16 additions & 25 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
**/ItMiiSampleWlsMain,
**/ItMiiUpdateDomainConfig,
**/ItMonitoringExporter,
**/ItParameterizedDomain,
**/ItMultiDomainModels,
**/ItPodsShutdownOption,
**/ItProductionSecureMode,
**/ItWlsSamples,
Expand Down Expand Up @@ -266,28 +266,6 @@
</includes-failsafe>
</properties>
</profile>
<profile>
<id>crio-pipeline</id>
<properties>
<skipITs>false</skipITs>
<includes-failsafe>
**/ItConfigDistributionStrategy,
**/ItIstioDomainInPV,
**/ItIstioMiiDomain,
**/ItMiiSampleWlsAux,
**/ItMiiServiceMigration,
**/ItMiiDomain,
**/ItMiiDynamicUpdate,
**/ItMiiSampleWlsMain,
**/ItMonitoringExporter,
**/ItPodsShutdownOption,
**/ItProductionSecureMode,
**/ItWlsSamples,
**/ItSessionMigration,
**/ItSystemResOverrides
</includes-failsafe>
</properties>
</profile>
<profile>
<id>fmw-image-cert</id>
<properties>
Expand Down Expand Up @@ -317,7 +295,7 @@
<properties>
<skipITs>false</skipITs>
<includes-failsafe>
**/ItParameterizedDomain,
**/ItMultiDomainModels,
**/ItServerStartPolicy,
**/ItMiiUpdateDomainConfig,
**/ItIntrospectVersion,
Expand Down Expand Up @@ -349,12 +327,25 @@
</includes-failsafe>
</properties>
</profile>
<profile>
<id>wls-srg</id>
<properties>
<skipITs>false</skipITs>
<includes-failsafe>
**/ItKubernetesEvents,
**/ItMiiAuxiliaryImage,
**/ItMultiDomainModels,
**/ItPodsRestart,
**/ItTwoDomainsManagedByTwoOperators
</includes-failsafe>
</properties>
</profile>
<profile>
<id>toolkits-srg</id>
<properties>
<skipITs>false</skipITs>
<includes-failsafe>
**/ItParameterizedDomain,
**/ItMultiDomainModels,
**/ItMiiUpdateDomainConfig,
**/ItMiiAuxiliaryImage,
**/ItMiiNewCreateAuxImage,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
// Copyright (c) 2022, Oracle and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

package oracle.weblogic.kubernetes;

import java.util.ArrayList;
import java.util.List;

import oracle.weblogic.domain.Domain;
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
import oracle.weblogic.kubernetes.annotations.Namespaces;
import oracle.weblogic.kubernetes.logging.LoggingFacade;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_SERVER_NAME_BASE;
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
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.WEBLOGIC_SLIM;
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.adminNodePortAccessible;
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createMiiDomainAndVerify;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.scaleAndVerifyCluster;
import static oracle.weblogic.kubernetes.utils.DomainUtils.createAndVerifyDomainInImageUsingWdt;
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainOnPvUsingWdt;
import static oracle.weblogic.kubernetes.utils.DomainUtils.shutdownDomainAndVerify;
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
import static oracle.weblogic.kubernetes.utils.PodUtils.getExternalServicePodName;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeFalse;

/**
* The test class creates WebLogic domains with three models.
* domain-on-pv ( using WDT )
* domain-in-image ( using WDT )
* model-in-image
* Verify the basic lifecycle operations of the WebLogic server pods by scaling the domain.
* Also verify admin console login using admin node port.
*/
@DisplayName("Verify the basic lifecycle operations of the WebLogic server pods by scaling the clusters in the domain"
+ " with different domain types and verify admin console login using admin node port.")
@IntegrationTest
class ItMultiDomainModels {

// domain constants
private static final String clusterName = "cluster-1";
private static final int replicaCount = 2;
private static final String wlSecretName = "weblogic-credentials";
private static final String miiDomainUid = "miidomain";
private static final String dimDomainUid = "domaininimage";
private static final String dpvDomainUid = "domainonpv";
private static final String wdtModelFileForDomainInImage = "wdt-singlecluster-sampleapp-usingprop-wls.yaml";

private static LoggingFacade logger = null;
private static String miiDomainNamespace = null;
private static String domainOnPVNamespace = null;
private static String domainInImageNamespace = null;

/**
* Install operator.
* Create three different type of domains: model in image, domain on PV and domain in image.
*
* @param namespaces list of namespaces created by the IntegrationTestWatcher by the
* JUnit engine parameter resolution mechanism
*/
@BeforeAll
public static void initAll(@Namespaces(4) List<String> namespaces) {
logger = getLogger();

// get a unique operator namespace
logger.info("Getting a unique namespace for operator");
assertNotNull(namespaces.get(0), "Namespace list is null");
String opNamespace = namespaces.get(0);

// get unique namespaces for three different type of domains
logger.info("Getting unique namespaces for three different type of domains");
assertNotNull(namespaces.get(1));
miiDomainNamespace = namespaces.get(1);
assertNotNull(namespaces.get(2));
domainOnPVNamespace = namespaces.get(2);
assertNotNull(namespaces.get(3));
domainInImageNamespace = namespaces.get(3);

// set the service account name for the operator
String opServiceAccount = opNamespace + "-sa";

// install and verify operator
installAndVerifyOperator(opNamespace, opServiceAccount, false, 0,
miiDomainNamespace, domainOnPVNamespace, domainInImageNamespace);
}

/**
* Scale the cluster by patching domain resource for three different
* type of domains i.e. domain-on-pv, domain-in-image and model-in-image
* Also verify admin console login using admin node port.
* @param domainType domain type, possible value: modelInImage, domainInImage, domainOnPV
*/
@ParameterizedTest
@DisplayName("scale cluster by patching domain resource with three different type of domains and "
+ "verify admin console login using admin node port.")
@ValueSource(strings = {"modelInImage", "domainInImage", "domainOnPV"})
void testScaleClustersAndAdminConsoleLogin(String domainType) {

assumeFalse(WEBLOGIC_SLIM, "Skipping the Console Test for slim image");
Domain domain = createDomainBasedOnDomainType(domainType);

// get the domain properties
String domainUid = domain.getSpec().getDomainUid();
String domainNamespace = domain.getMetadata().getNamespace();

String managedServerPodNamePrefix = domainUid + "-" + MANAGED_SERVER_NAME_BASE;

int numberOfServers = 3;
logger.info("Scaling cluster {0} of domain {1} in namespace {2} to {3} servers.",
clusterName, domainUid, domainNamespace, numberOfServers);
List<String> managedServersBeforeScale = listManagedServersBeforeScale(replicaCount);
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
replicaCount, numberOfServers, null, managedServersBeforeScale);

// then scale cluster back to 2 servers
logger.info("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers.",
clusterName, domainUid, domainNamespace, numberOfServers, replicaCount);
managedServersBeforeScale = listManagedServersBeforeScale(numberOfServers);
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
numberOfServers, replicaCount, null, managedServersBeforeScale);

String adminServerPodName = domainUid + "-" + ADMIN_SERVER_NAME_BASE;
logger.info("Getting node port for default channel");
int serviceNodePort = assertDoesNotThrow(() -> getServiceNodePort(
domainNamespace, getExternalServicePodName(adminServerPodName), "default"),
"Getting admin server node port failed");

logger.info("Validating WebLogic admin server access by login to console");
boolean loginSuccessful = assertDoesNotThrow(() ->
adminNodePortAccessible(serviceNodePort, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT),
"Access to admin server node port failed");
assertTrue(loginSuccessful, "Console login validation failed");

// shutdown domain and verify the domain is shutdown
shutdownDomainAndVerify(domainNamespace, domainUid, replicaCount);
}

/**
* Generate a server list which contains all managed servers in the cluster before scale.
*
* @param replicasBeforeScale the replicas of WebLogic cluster before scale
* @return list of managed servers in the cluster before scale
*/
private static List<String> listManagedServersBeforeScale(int replicasBeforeScale) {

List<String> managedServerNames = new ArrayList<>();
for (int i = 1; i <= replicasBeforeScale; i++) {
managedServerNames.add(MANAGED_SERVER_NAME_BASE + i);
}

return managedServerNames;
}

/**
* Assert the specified domain and domain spec, metadata and clusters not null.
* @param domain oracle.weblogic.domain.Domain object
*/
private static void assertDomainNotNull(Domain domain) {
assertNotNull(domain, "domain is null");
assertNotNull(domain.getSpec(), domain + " spec is null");
assertNotNull(domain.getMetadata(), domain + " metadata is null");
assertNotNull(domain.getSpec().getClusters(), domain.getSpec() + " getClusters() is null");
}

private static Domain createDomainBasedOnDomainType(String domainType) {
Domain domain = null;

if (domainType.equalsIgnoreCase("modelInImage")) {
domain = createMiiDomainAndVerify(miiDomainNamespace, miiDomainUid,
MII_BASIC_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG,
miiDomainUid + "-" + ADMIN_SERVER_NAME_BASE,
miiDomainUid + "-" + MANAGED_SERVER_NAME_BASE, replicaCount);
} else if (domainType.equalsIgnoreCase("domainInImage")) {
List<String> appSrcDirList = new ArrayList<>();
appSrcDirList.add(MII_BASIC_APP_NAME);
domain = createAndVerifyDomainInImageUsingWdt(dimDomainUid, domainInImageNamespace,
wdtModelFileForDomainInImage, appSrcDirList, wlSecretName, clusterName, replicaCount);
} else {
domain = createDomainOnPvUsingWdt(dpvDomainUid, domainOnPVNamespace, wlSecretName,
clusterName, replicaCount, ItMultiDomainModels.class.getSimpleName());
}

assertDomainNotNull(domain);
return domain;
}
}
Loading