Skip to content

Commit 19cb01e

Browse files
sankarpnrjeberhard
authored andcommitted
Add DomainOnPV configuration to Operator versions in Upgrade tests for WLS domains
1 parent af194fb commit 19cb01e

File tree

3 files changed

+208
-70
lines changed

3 files changed

+208
-70
lines changed

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

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import oracle.weblogic.kubernetes.logging.LoggingFacade;
2222
import org.junit.jupiter.api.AfterEach;
2323
import org.junit.jupiter.api.BeforeEach;
24-
import org.junit.jupiter.api.Disabled;
2524
import org.junit.jupiter.api.DisplayName;
2625
import org.junit.jupiter.api.Tag;
2726
import org.junit.jupiter.api.Test;
@@ -73,7 +72,7 @@
7372
/**
7473
* Install a released version of Operator from GitHub chart repository.
7574
* Create a domain using Model-In-Image model with a dynamic cluster.
76-
* Configure Itsio on the domain resource with v8 schema
75+
* Configure Itsio on the domain resource with v9 schema
7776
* Make sure the console is accessible thru istio ingress port
7877
* Upgrade operator with current Operator image build from current branch.
7978
* Make sure the console is accessible thru istio ingress port
@@ -119,35 +118,35 @@ public void beforeEach(@Namespaces(2) List<String> namespaces) {
119118
}
120119

121120
/**
122-
* Upgrade from Operator 3.4.3 to current with Istio enabled domain.
121+
* Upgrade from Operator 4.0.9 to current with Istio enabled domain.
123122
*/
124123
@Test
125-
@DisplayName("Upgrade 3.4.3 Istio Domain(v8) with Istio to current")
126-
void testOperatorWlsIstioDomainUpgradeFrom343ToCurrent() {
127-
logger.info("Starting testOperatorWlsIstioDomainUpgradeFrom343ToCurrent"
128-
+ " to upgrade Istio Image Domain with Istio with v8 schema to current");
129-
upgradeWlsIstioDomain("3.4.3");
124+
@DisplayName("Upgrade 4.0.9 Istio Domain with Istio to current")
125+
void testOperatorWlsIstioDomainUpgradeFrom409ToCurrent() {
126+
logger.info("Starting testOperatorWlsIstioDomainUpgradeFrom409ToCurrent"
127+
+ " to upgrade Istio Image Domain with Istio with v9 schema to current");
128+
upgradeWlsIstioDomain("4.0.9");
130129
}
131130

132131
/**
133-
* Upgrade from Operator 3.4.4 to current with Istio enabled domain.
132+
* Upgrade from Operator 4.1.7 to current with Istio enabled domain.
134133
*/
135134
@Test
136-
@DisplayName("Upgrade 3.4.4 Istio Domain(v8) with Istio to current")
137-
void testOperatorWlsIstioDomainUpgradeFrom344ToCurrent() {
138-
logger.info("Starting testOperatorWlsIstioDomainUpgradeFrom344ToCurrent"
139-
+ " to upgrade Istio Image Domain with Istio with v8 schema to current");
140-
upgradeWlsIstioDomain("3.4.4");
135+
@DisplayName("Upgrade 4.1.7 Istio Domain(v9) with Istio to current")
136+
void testOperatorWlsIstioDomainUpgradeFrom417ToCurrent() {
137+
logger.info("Starting testOperatorWlsIstioDomainUpgradeFrom417ToCurrent"
138+
+ " to upgrade Istio Image Domain with Istio with v9 schema to current");
139+
upgradeWlsIstioDomain("4.1.7");
141140
}
142141

143142
/**
144-
* Upgrade from Operator v3.3.8 to current with Istio enabled domain.
143+
* Upgrade from Operator v4.2.6 to current with Istio enabled domain.
145144
*/
146-
@Disabled
147-
@DisplayName("Upgrade 3.3.8 Istio Domain(v8) with Istio to current")
148-
void testOperatorWlsIstioDomainUpgradeFrom338ToCurrent() {
149-
logger.info("Starting test to upgrade Istio Image Domain with Istio with v8 schema to current");
150-
upgradeWlsIstioDomain("3.3.8");
145+
@Test
146+
@DisplayName("Upgrade 4.2.6 Istio Domain with Istio to current")
147+
void testOperatorWlsIstioDomainUpgradeFrom426ToCurrent() {
148+
logger.info("Starting test to upgrade Istio Image Domain with Istio with v9 schema to current");
149+
upgradeWlsIstioDomain("4.2.6");
151150
}
152151

153152
/**
@@ -163,24 +162,24 @@ public void tearDown() {
163162
}
164163

165164
void upgradeWlsIstioDomain(String oldVersion) {
166-
logger.info("Upgrade version/{0} Istio Domain(v8) to current", oldVersion);
167-
installOldOperator(oldVersion,opNamespace,domainNamespace);
165+
logger.info("Upgrade version/{0} Istio Domain to current", oldVersion);
166+
installOldOperator(oldVersion, opNamespace, domainNamespace);
168167
createSecrets();
169168

170169
// Create the repo secret to pull base WebLogic image
171170
createBaseRepoSecret(domainNamespace);
172171
createConfigMapAndVerify("istio-upgrade-configmap",
173172
domainUid, domainNamespace, Collections.emptyList());
174173

175-
// Creating an MII domain with v8 version
176-
// Generate a v8 version of domain.yaml file from a template file
174+
// Creating an MII domain with v9 version
175+
// Generate a v9 version of domain.yaml file from a template file
177176
// by replacing domain namespace, domain uid, image
178177
Map<String, String> templateMap = new HashMap<>();
179178
templateMap.put("DOMAIN_NS", domainNamespace);
180179
templateMap.put("DOMAIN_UID", domainUid);
181180
templateMap.put("MII_IMAGE",
182181
MII_BASIC_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG);
183-
templateMap.put("API_VERSION", "v8");
182+
templateMap.put("API_VERSION", "v9");
184183
Path srcDomainFile = Paths.get(RESOURCE_DIR,
185184
"upgrade", "istio.config.template.yaml");
186185
Path targetDomainFile = assertDoesNotThrow(
@@ -199,7 +198,7 @@ void upgradeWlsIstioDomain(String oldVersion) {
199198
// wait for the domain to exist
200199
logger.info("Checking for domain custom resource in namespace {0}", domainNamespace);
201200
testUntil(
202-
domainExists(domainUid, "v8", domainNamespace),
201+
domainExists(domainUid, "v9", domainNamespace),
203202
logger,
204203
"domain {0} to be created in namespace {1}",
205204
domainUid,

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

Lines changed: 171 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
package oracle.weblogic.kubernetes;
55

6+
import java.io.File;
7+
import java.io.FileOutputStream;
68
import java.net.InetAddress;
79
import java.nio.file.Files;
810
import java.nio.file.Path;
@@ -14,9 +16,18 @@
1416
import java.util.LinkedHashMap;
1517
import java.util.List;
1618
import java.util.Map;
17-
19+
import java.util.Properties;
20+
21+
import io.kubernetes.client.custom.Quantity;
22+
import oracle.weblogic.domain.Configuration;
23+
import oracle.weblogic.domain.CreateIfNotExists;
24+
import oracle.weblogic.domain.DomainCreationImage;
25+
import oracle.weblogic.domain.DomainOnPV;
26+
import oracle.weblogic.domain.DomainOnPVType;
27+
import oracle.weblogic.domain.DomainResource;
1828
import oracle.weblogic.kubernetes.actions.impl.primitive.Command;
1929
import oracle.weblogic.kubernetes.actions.impl.primitive.CommandParams;
30+
import oracle.weblogic.kubernetes.actions.impl.primitive.WitParams;
2031
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
2132
import oracle.weblogic.kubernetes.annotations.Namespaces;
2233
import oracle.weblogic.kubernetes.logging.LoggingFacade;
@@ -33,9 +44,11 @@
3344
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
3445
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
3546
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
47+
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_SECRET_NAME;
3648
import static oracle.weblogic.kubernetes.TestConstants.CLUSTER_VERSION;
3749
import static oracle.weblogic.kubernetes.TestConstants.DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX;
3850
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
51+
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_IMAGES_PREFIX;
3952
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_STATUS_CONDITION_COMPLETED_TYPE;
4053
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION;
4154
import static oracle.weblogic.kubernetes.TestConstants.ENCRYPION_PASSWORD_DEFAULT;
@@ -48,8 +61,10 @@
4861
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
4962
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
5063
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_WDT_MODEL_FILE;
64+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
5165
import static oracle.weblogic.kubernetes.TestConstants.OLD_DOMAIN_VERSION;
5266
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
67+
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_TEMPFILE;
5368
import static oracle.weblogic.kubernetes.TestConstants.SKIP_CLEANUP;
5469
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
5570
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
@@ -66,22 +81,30 @@
6681
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.deployAndAccessApplication;
6782
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.verifyAdminConsoleAccessible;
6883
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.verifyAdminServerRESTAccess;
84+
import static oracle.weblogic.kubernetes.utils.AuxiliaryImageUtils.createAndPushAuxiliaryImage;
6985
import static oracle.weblogic.kubernetes.utils.AuxiliaryImageUtils.createPushAuxiliaryImageWithDomainConfig;
7086
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyPodsNotRolled;
7187
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
7288
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting;
7389
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.formatIPv6Host;
90+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
91+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
7492
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
93+
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
94+
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainResourceOnPv;
7595
import static oracle.weblogic.kubernetes.utils.DomainUtils.verifyDomainStatusConditionTypeDoesNotExist;
7696
import static oracle.weblogic.kubernetes.utils.FileUtils.generateFileFromTemplate;
7797
import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile;
98+
import static oracle.weblogic.kubernetes.utils.FmwUtils.getConfiguration;
99+
import static oracle.weblogic.kubernetes.utils.FmwUtils.verifyDomainReady;
78100
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
79101
import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret;
80102
import static oracle.weblogic.kubernetes.utils.PatchDomainUtils.patchServerStartPolicy;
81103
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodDeleted;
82104
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodReady;
83105
import static oracle.weblogic.kubernetes.utils.PodUtils.getExternalServicePodName;
84106
import static oracle.weblogic.kubernetes.utils.PodUtils.getPodCreationTime;
107+
import static oracle.weblogic.kubernetes.utils.PodUtils.setPodAntiAffinity;
85108
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
86109
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
87110
import static oracle.weblogic.kubernetes.utils.UpgradeUtils.checkCrdVersion;
@@ -162,6 +185,46 @@ void testOperatorUpgradeMiiDomainV8From409ToCurrent() {
162185
installOperatorCreateMiiDomainAndUpgrade("4.0.9", OLD_DOMAIN_VERSION, DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX);
163186
}
164187

188+
/**
189+
* Operator upgrade from 4.2.9 to current with DPV domain in V9 schema.
190+
*/
191+
@Test
192+
@DisplayName("Upgrade Operator from 4.2.9 to current")
193+
void testOperatorUpgradeDomainOnPVV9From429ToCurrent() {
194+
logger.info("Starting test testOperatorUpgradeDomainOnPVV9From429ToCurrent, domain v9 schema");
195+
installOperatorCreatesPvPvcWlsDomainAndUpgrade("4.2.9");
196+
}
197+
198+
/**
199+
* Operator upgrade from 4.2.8 to current with DPV domain in V9 schema.
200+
*/
201+
@Test
202+
@DisplayName("Upgrade Operator from 4.2.8 to current")
203+
void testOperatorUpgradeDomainOnPVV9From428ToCurrent() {
204+
logger.info("Starting test testOperatorUpgradeDomainOnPVV9From428ToCurrent, domain v9 schema");
205+
installOperatorCreatesPvPvcWlsDomainAndUpgrade("4.2.8");
206+
}
207+
208+
/**
209+
* Operator upgrade from 4.1.8 to current with DPV domain in V9 schema.
210+
*/
211+
@Test
212+
@DisplayName("Upgrade Operator from 4.1.8 to current")
213+
void testOperatorUpgradeDomainOnPVV9From418ToCurrent() {
214+
logger.info("Starting test testOperatorUpgradeDomainOnPVV9From418ToCurrent, domain v9 schema");
215+
installOperatorCreatesPvPvcWlsDomainAndUpgrade("4.1.8");
216+
}
217+
218+
/**
219+
* Operator upgrade from 4.1.7 to current with DPV domain in V9 schema.
220+
*/
221+
@Test
222+
@DisplayName("Upgrade Operator from 4.1.7 to current")
223+
void testOperatorUpgradeDomainOnPVV9From417ToCurrent() {
224+
logger.info("Starting test testOperatorUpgradeDomainOnPVV9From417ToCurrent, domain v9 schema");
225+
installOperatorCreatesPvPvcWlsDomainAndUpgrade("4.1.7");
226+
}
227+
165228
/**
166229
* Upgrade Operator from 4.0.10 to current with Auxiliary image domain, V9 schema.
167230
*/
@@ -172,7 +235,6 @@ void testOperatorUpgradeAuxDomainV9From4010ToCurrent() {
172235
installOperatorCreateAuxDomainAndUpgrade("4.0.10", DOMAIN_VERSION);
173236
}
174237

175-
176238
/**
177239
* Upgrade Operator from 4.1.7 to current with Mii domain in V8 schema.
178240
*/
@@ -216,29 +278,6 @@ void testOperatorUpgradeMiiDomainV8From426ToCurrent() {
216278
installOperatorCreateMiiDomainAndUpgrade("4.2.6", OLD_DOMAIN_VERSION, DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX);
217279
}
218280

219-
/**
220-
* Operator upgrade from 3.4.13 to current with Auxiliary Image Domain, V8 schema.
221-
* V9 schema is from Operator 4.0.
222-
*/
223-
@Test
224-
@DisplayName("Upgrade 3.4.13 Auxiliary Domain(v8 schema) Image to current")
225-
void testOperatorUpgradeAuxDomainV8From3413ToCurrent() {
226-
logger.info("Starting testOperatorUpgradeAuxDomainV8From3413ToCurrent "
227-
+ "to upgrade Domain with Auxiliary Image with v8 schema to current");
228-
installOperatorCreateAuxDomainAndUpgrade("3.4.13", OLD_DOMAIN_VERSION);
229-
}
230-
231-
/**
232-
* Upgrade Operator from 3.4.12 to current with Mii domain in V8 schema.
233-
*/
234-
@Test
235-
@DisplayName("Upgrade 3.4.12 Mii Domain(v8 schema) Image to current")
236-
void testOperatorUpgradeMiiDomainV8From3412ToCurrent() {
237-
logger.info("Starting testOperatorWlsAuxDomainV8UpgradeFrom3412ToCurrent "
238-
+ "to upgrade MII Domain with v8 schema to current");
239-
installOperatorCreateMiiDomainAndUpgrade("3.4.12", OLD_DOMAIN_VERSION, DEFAULT_EXTERNAL_SERVICE_NAME_SUFFIX);
240-
}
241-
242281
/**
243282
* Cleanup Kubernetes artifacts in the namespaces used by the test and
244283
* delete CRD.
@@ -323,6 +362,93 @@ void installOperatorCreateAuxDomainAndUpgrade(String operatorVersion, String dom
323362
scaleClusterUpAndDown(domainApiVersion);
324363
}
325364

365+
void installOperatorCreatesPvPvcWlsDomainAndUpgrade(String operatorVersion) {
366+
final String storageClassName = "weblogic-domain-storage-class";
367+
String domainHomePrefix = "/shared/" + domainNamespace + "/domains/";
368+
final String clusterName = "cluster-1";
369+
final String pvName = getUniqueName(domainUid + "-pv-");
370+
final String pvcName = getUniqueName(domainUid + "-pvc-");
371+
final int t3ChannelPort = getNextFreePort();
372+
final String wlsModelFile = "model-wlsdomain-onpv-simplified.yaml";
373+
374+
logger.info("Upgrade version/{0} Auxiliary Domain(v9) to current", operatorVersion);
375+
installOldOperator(operatorVersion, opNamespace, domainNamespace);
376+
createSecrets();
377+
378+
// Create the repo secret to pull base WebLogic image
379+
createBaseRepoSecret(domainNamespace);
380+
381+
// create a model property file
382+
File wlsModelPropFile = createWdtPropertyFile("wlsonpv-upgrade");
383+
384+
// create domainCreationImage
385+
String domainCreationImageName = DOMAIN_IMAGES_PREFIX + "wls-domain-on-pv-upgrade";
386+
// create image with model and wdt installation files
387+
WitParams witParams
388+
= new WitParams()
389+
.modelImageName(domainCreationImageName)
390+
.modelImageTag(MII_BASIC_IMAGE_TAG)
391+
.modelFiles(Collections.singletonList(MODEL_DIR + "/" + wlsModelFile))
392+
.modelVariableFiles(Collections.singletonList(wlsModelPropFile.getAbsolutePath()));
393+
createAndPushAuxiliaryImage(domainCreationImageName, MII_BASIC_IMAGE_TAG, witParams);
394+
395+
DomainCreationImage domainCreationImage
396+
= new DomainCreationImage().image(domainCreationImageName + ":" + MII_BASIC_IMAGE_TAG);
397+
398+
// create a domain resource
399+
logger.info("Creating domain custom resource");
400+
Map<String, Quantity> pvCapacity = new HashMap<>();
401+
pvCapacity.put("storage", new Quantity("2Gi"));
402+
403+
Map<String, Quantity> pvcRequest = new HashMap<>();
404+
pvcRequest.put("storage", new Quantity("2Gi"));
405+
Configuration configuration = null;
406+
if (OKE_CLUSTER) {
407+
configuration = getConfiguration(pvcName, pvcRequest, "oci-fss");
408+
} else {
409+
configuration = getConfiguration(pvName, pvcName, pvCapacity, pvcRequest, storageClassName,
410+
this.getClass().getSimpleName());
411+
}
412+
configuration.getInitializeDomainOnPV().domain(new DomainOnPV()
413+
.createMode(CreateIfNotExists.DOMAIN)
414+
.domainCreationImages(Collections.singletonList(domainCreationImage))
415+
.domainType(DomainOnPVType.WLS));
416+
DomainResource domain = createDomainResourceOnPv(domainUid,
417+
domainNamespace,
418+
adminSecretName,
419+
clusterName,
420+
pvName,
421+
pvcName,
422+
new String[]{BASE_IMAGES_REPO_SECRET_NAME},
423+
domainHomePrefix,
424+
replicaCount,
425+
0,
426+
configuration);
427+
428+
// Set the inter-pod anti-affinity for the domain custom resource
429+
setPodAntiAffinity(domain);
430+
431+
// create a domain custom resource and verify domain is created
432+
createDomainAndVerify(domain, domainNamespace);
433+
434+
// verify that all servers are ready
435+
verifyDomainReady(domainNamespace, domainUid, replicaCount, "nosuffix");
436+
LinkedHashMap<String, OffsetDateTime> pods = new LinkedHashMap<>();
437+
pods.put(adminServerPodName, getPodCreationTime(domainNamespace, adminServerPodName));
438+
// get the creation time of the managed server pods before upgrading the operator
439+
for (int i = 1; i <= replicaCount; i++) {
440+
pods.put(managedServerPodNamePrefix + i, getPodCreationTime(domainNamespace, managedServerPodNamePrefix + i));
441+
}
442+
// verify there is no status condition type Completed
443+
// before upgrading to Latest
444+
verifyDomainStatusConditionTypeDoesNotExist(domainUid, domainNamespace,
445+
DOMAIN_STATUS_CONDITION_COMPLETED_TYPE, DOMAIN_VERSION);
446+
upgradeOperatorToCurrent(opNamespace);
447+
checkDomainStatus(domainNamespace, domainUid);
448+
verifyPodsNotRolled(domainNamespace, pods);
449+
scaleClusterUpAndDown(clusterName);
450+
}
451+
326452
// After upgrade scale up/down the cluster
327453
private void scaleClusterUpAndDown(String domainApiVersion) {
328454

@@ -603,5 +729,25 @@ private void verifyDomain(String domainUidString, String domainNamespace, String
603729
String.valueOf(serviceNodePort), false);
604730
}
605731
}
732+
733+
private File createWdtPropertyFile(String wlsModelFilePrefix) {
734+
735+
// create property file used with domain model file
736+
Properties p = new Properties();
737+
p.setProperty("adminUsername", ADMIN_USERNAME_DEFAULT);
738+
p.setProperty("adminPassword", ADMIN_PASSWORD_DEFAULT);
739+
740+
// create a model property file
741+
File domainPropertiesFile = assertDoesNotThrow(() ->
742+
File.createTempFile(wlsModelFilePrefix, ".properties", new File(RESULTS_TEMPFILE)),
743+
"Failed to create WLS model properties file");
606744

745+
// create the property file
746+
assertDoesNotThrow(() ->
747+
p.store(new FileOutputStream(domainPropertiesFile), "WLS properties file"),
748+
"Failed to write WLS properties file");
749+
750+
return domainPropertiesFile;
751+
}
752+
607753
}

0 commit comments

Comments
 (0)