Skip to content

Commit ce26a91

Browse files
xiancaorjeberhard
andauthored
Add Operator Upgrade Tests for Mii Domain (#2277)
* add operator upgrade test for model-in-image domain Co-authored-by: Ryan Eberhard <[email protected]>
1 parent ae1c70d commit ce26a91

File tree

2 files changed

+162
-25
lines changed

2 files changed

+162
-25
lines changed

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

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@
2828
import org.junit.jupiter.api.MethodOrderer;
2929
import org.junit.jupiter.api.Test;
3030
import org.junit.jupiter.api.TestMethodOrder;
31+
import org.junit.jupiter.params.ParameterizedTest;
32+
import org.junit.jupiter.params.provider.ValueSource;
3133

3234
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
3335
import static java.util.concurrent.TimeUnit.MINUTES;
3436
import static java.util.concurrent.TimeUnit.SECONDS;
3537
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
3638
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
3739
import static oracle.weblogic.kubernetes.TestConstants.DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX;
40+
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
41+
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
3842
import static oracle.weblogic.kubernetes.TestConstants.OLD_DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX;
3943
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_CHART_DIR;
4044
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_GITHUB_CHART_REPO_URL;
@@ -48,6 +52,7 @@
4852
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
4953
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallOperator;
5054
import static oracle.weblogic.kubernetes.assertions.TestAssertions.adminNodePortAccessible;
55+
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createMiiDomainAndVerify;
5156
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyPodsNotRolled;
5257
import static oracle.weblogic.kubernetes.utils.CommonPatchTestUtils.patchServerStartPolicy;
5358
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodDeleted;
@@ -71,7 +76,7 @@
7176

7277
/**
7378
* Install a released version of Operator from GitHub chart repository.
74-
* Create a domain using Domain-In-Image model with a dynamic cluster.
79+
* Create a domain using Domain-In-Image or Model-In-Image model with a dynamic cluster.
7580
* Deploy an application to the cluster in domain and verify the application
7681
* can be accessed while the operator is upgraded and after the upgrade.
7782
* Upgrade operator with latest Operator image from develop branch.
@@ -124,7 +129,6 @@ public static void init() {
124129
withQuickRetryPolicy = with().pollDelay(0, SECONDS)
125130
.and().with().pollInterval(4, SECONDS)
126131
.atMost(10, SECONDS).await();
127-
128132
}
129133

130134
/**
@@ -133,52 +137,62 @@ public static void init() {
133137
@Test
134138
@DisplayName("Upgrade Operator from 2.6.0 to develop")
135139
public void testOperatorWlsUpgradeFrom260ToDevelop() {
136-
upgradeOperator("2.6.0", OLD_DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, false);
140+
upgradeOperator("domain-in-image", "2.6.0", OLD_DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, false);
137141
}
138142

139143
/**
140144
* Operator upgrade from 3.0.3 to latest.
141145
*/
142-
@Test
146+
@ParameterizedTest
143147
@DisplayName("Upgrade Operator from 3.0.3 to develop")
144-
public void testOperatorWlsUpgradeFrom303ToDevelop() {
145-
upgradeOperator("3.0.3", OLD_DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, true);
148+
@ValueSource(strings = { "domain-in-image", "model-in-image" })
149+
public void testOperatorWlsUpgradeFrom303ToDevelop(String domainType) {
150+
logger.info("Starting test testOperatorWlsUpgradeFrom303ToDevelop with domain type {0}", domainType);
151+
upgradeOperator(domainType, "3.0.3", OLD_DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, true);
146152
}
147153

148154
/**
149155
* Operator upgrade from 3.0.4 to latest.
150156
*/
151-
@Test
157+
@ParameterizedTest
152158
@DisplayName("Upgrade Operator from 3.0.4 to develop")
153-
public void testOperatorWlsUpgradeFrom304ToDevelop() {
154-
upgradeOperator("3.0.4", OLD_DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, true);
159+
@ValueSource(strings = { "domain-in-image", "model-in-image" })
160+
public void testOperatorWlsUpgradeFrom304ToDevelop(String domainType) {
161+
logger.info("Starting test testOperatorWlsUpgradeFrom304ToDevelop with domain type {0}", domainType);
162+
upgradeOperator(domainType, "3.0.4", OLD_DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, true);
155163
}
156164

157165
/**
158166
* Operator upgrade from 3.1.2 to latest.
159167
*/
160-
@Test
168+
@ParameterizedTest
161169
@DisplayName("Upgrade Operator from 3.1.2 to develop")
162-
public void testOperatorWlsUpgradeFrom312ToDevelop() {
163-
upgradeOperator("3.1.2", DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, true);
170+
@ValueSource(strings = { "domain-in-image", "model-in-image" })
171+
public void testOperatorWlsUpgradeFrom312ToDevelop(String domainType) {
172+
logger.info("Starting test testOperatorWlsUpgradeFrom312ToDevelop with domain type {0}", domainType);
173+
upgradeOperator(domainType, "3.1.2", DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, true);
164174
}
165175

166176
/**
167177
* Operator upgrade from 3.1.3 to latest.
168178
*/
169-
@Test
179+
@ParameterizedTest
170180
@DisplayName("Upgrade Operator from 3.1.3 to develop")
171-
public void testOperatorWlsUpgradeFrom313ToDevelop() {
172-
upgradeOperator("3.1.3", DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, true);
181+
@ValueSource(strings = { "domain-in-image", "model-in-image" })
182+
public void testOperatorWlsUpgradeFrom313ToDevelop(String domainType) {
183+
logger.info("Starting test testOperatorWlsUpgradeFrom313ToDevelop with domain type {0}", domainType);
184+
upgradeOperator(domainType, "3.1.3", DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, true);
173185
}
174186

175187
/**
176188
* Operator upgrade from 3.1.4 to latest.
177189
*/
178-
@Test
190+
@ParameterizedTest
179191
@DisplayName("Upgrade Operator from 3.1.4 to develop")
180-
public void testOperatorWlsUpgradeFrom314ToDevelop() {
181-
upgradeOperator("3.1.4", DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, true);
192+
@ValueSource(strings = { "domain-in-image", "model-in-image" })
193+
public void testOperatorWlsUpgradeFrom314ToDevelop(String domainType) {
194+
logger.info("Starting test testOperatorWlsUpgradeFrom314ToDevelop with domain type {0}", domainType);
195+
upgradeOperator(domainType, "3.1.4", DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX, true);
182196
}
183197

184198
/**
@@ -201,7 +215,8 @@ public void tearDown() {
201215
// Since Operator version 3.1.0 the service pod prefix has been changed
202216
// from -external to -ext e.g.
203217
// domain1-adminserver-ext NodePort 10.96.46.242 30001:30001/TCP
204-
private void upgradeOperator(String operatorVersion, String externalServiceNameSuffix, boolean useHelmUpgrade) {
218+
private void upgradeOperator(String domainType, String operatorVersion, String externalServiceNameSuffix,
219+
boolean useHelmUpgrade) {
205220
logger.info("Assign a unique namespace for operator {0}", operatorVersion);
206221
assertNotNull(namespaces.get(0), "Namespace is null");
207222
final String opNamespace1 = namespaces.get(0);
@@ -230,14 +245,17 @@ private void upgradeOperator(String operatorVersion, String externalServiceNameS
230245
// install operator
231246
String opNamespace = opNamespace1;
232247
String opServiceAccount = opNamespace + "-sa";
233-
installAndVerifyOperator(opNamespace, opServiceAccount, true,
234-
0, opHelmParams, domainNamespace);
248+
installAndVerifyOperator(opNamespace, opServiceAccount, true, 0, opHelmParams, domainNamespace);
235249

236250
// create domain
237-
createDomainHomeInImageAndVerify(
238-
domainNamespace, operatorVersion, externalServiceNameSuffix);
251+
if (domainType.equalsIgnoreCase("domain-in-image")) {
252+
createDomainHomeInImageAndVerify(domainNamespace, operatorVersion, externalServiceNameSuffix);
253+
} else {
254+
createMiiDomainAndVerify(domainNamespace, domainUid, MII_BASIC_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG,
255+
adminServerPodName, managedServerPodNamePrefix, replicaCount);
256+
}
257+
239258
LinkedHashMap<String, OffsetDateTime> pods = new LinkedHashMap<>();
240-
OffsetDateTime adminPodCreationTime = getPodCreationTime(domainNamespace, adminServerPodName);
241259
pods.put(adminServerPodName, getPodCreationTime(domainNamespace, adminServerPodName));
242260
// get the creation time of the managed server pods before patching
243261
for (int i = 1; i <= replicaCount; i++) {
@@ -258,7 +276,7 @@ private void upgradeOperator(String operatorVersion, String externalServiceNameS
258276

259277
// start a new thread to collect the availability data of the application while the
260278
// main thread performs operator upgrade
261-
List<Integer> appAvailability = new ArrayList<Integer>();
279+
List<Integer> appAvailability = new ArrayList<>();
262280
logger.info("Start a thread to keep track of the application's availability");
263281
Thread accountingThread =
264282
new Thread(
@@ -330,6 +348,7 @@ private void upgradeOperator(String operatorVersion, String externalServiceNameS
330348
// install latest operator
331349
installAndVerifyOperator(opNamespace, opServiceAccount, true, 0, domainNamespace);
332350
}
351+
333352
// check CRD version is updated
334353
logger.info("Checking CRD version ");
335354
withStandardRetryPolicy
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Copyright (c) 2021, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
#
4+
# This is an example of how to define a Domain resource.
5+
#
6+
apiVersion: "weblogic.oracle/v8"
7+
kind: Domain
8+
metadata:
9+
name: domain1
10+
namespace: miidomain300-ns
11+
labels:
12+
weblogic.domainUID: domain1
13+
14+
spec:
15+
# Set to 'FromModel' to indicate 'Model in Image'.
16+
domainHomeSourceType: FromModel
17+
18+
# The WebLogic Domain Home, this must be a location within
19+
# the image for 'Model in Image' domains.
20+
domainHome: /u01/domains/domain1
21+
22+
# The WebLogic Server image that the Operator uses to start the domain
23+
image: "model-in-image:12.2.1.4"
24+
25+
# Defaults to "Always" if image tag (version) is ':latest'
26+
imagePullPolicy: "IfNotPresent"
27+
28+
# Identify which Secret contains the credentials for pulling an image
29+
imagePullSecrets:
30+
- name: ocir-secret
31+
32+
# Identify which Secret contains the WebLogic Admin credentials,
33+
# the secret must contain 'username' and 'password' fields.
34+
webLogicCredentialsSecret:
35+
name: weblogic-credentials
36+
37+
# Whether to include the WebLogic Server stdout in the pod's stdout, default is true
38+
includeServerOutInPodLog: true
39+
40+
# Set which WebLogic Servers the Operator will start
41+
# - "NEVER" will not start any server in the domain
42+
# - "ADMIN_ONLY" will start up only the administration server (no managed servers will be started)
43+
# - "IF_NEEDED" will start all non-clustered servers, including the administration server, and clustered servers up to their replica count.
44+
serverStartPolicy: "IF_NEEDED"
45+
46+
# Settings for all server pods in the domain including the introspector job pod
47+
serverPod:
48+
# Optional new or overridden environment variables for the domain's pods
49+
# - This sample uses CUSTOM_DOMAIN_NAME in its image model file
50+
# to set the Weblogic domain name
51+
env:
52+
- name: CUSTOM_DOMAIN_NAME
53+
value: "domain1"
54+
- name: JAVA_OPTIONS
55+
value: "-Dweblogic.StdoutDebugEnabled=false"
56+
- name: USER_MEM_ARGS
57+
value: "-Djava.security.egd=file:/dev/./urandom -Xms256m -Xmx512m "
58+
resources:
59+
requests:
60+
cpu: "250m"
61+
memory: "768Mi"
62+
63+
# The desired behavior for starting the domain's administration server.
64+
adminServer:
65+
# The serverStartState legal values are "RUNNING" or "ADMIN"
66+
# "RUNNING" means the listed server will be started up to "RUNNING" mode
67+
# "ADMIN" means the listed server will be start up to "ADMIN" mode
68+
serverStartState: "RUNNING"
69+
# Setup a Kubernetes node port for the administration server default channel
70+
adminService:
71+
channels:
72+
- channelName: default
73+
nodePort: 0
74+
- channelName: T3Channel
75+
76+
# The number of managed servers to start for unlisted clusters
77+
replicas: 1
78+
79+
# The desired behavior for starting a specific cluster's member servers
80+
clusters:
81+
- clusterName: cluster-1
82+
serverStartState: "RUNNING"
83+
serverPod:
84+
# Instructs Kubernetes scheduler to prefer nodes for new cluster members where there are not
85+
# already members of the same cluster.
86+
affinity:
87+
podAntiAffinity:
88+
preferredDuringSchedulingIgnoredDuringExecution:
89+
- weight: 100
90+
podAffinityTerm:
91+
labelSelector:
92+
matchExpressions:
93+
- key: "weblogic.clusterName"
94+
operator: In
95+
values:
96+
- $(CLUSTER_NAME)
97+
topologyKey: "kubernetes.io/hostname"
98+
# The number of managed servers to start for this cluster
99+
replicas: 2
100+
101+
# Change the restartVersion to force the introspector job to rerun
102+
# and apply any new model configuration, to also force a subsequent
103+
# roll of your domain's WebLogic Server pods.
104+
restartVersion: '1'
105+
106+
# Changes to this field cause the operator to repeat its introspection of the
107+
# WebLogic domain configuration.
108+
introspectVersion: '1'
109+
110+
configuration:
111+
112+
# Settings for domainHomeSourceType 'FromModel'
113+
model:
114+
# Valid model domain types are 'WLS', 'JRF', and 'RestrictedJRF', default is 'WLS'
115+
domainType: "WLS"
116+
117+
# All 'FromModel' domains require a runtimeEncryptionSecret with a 'password' field
118+
runtimeEncryptionSecret: domain1-runtime-encryption-secret

0 commit comments

Comments
 (0)