Skip to content

Commit 5c5063b

Browse files
sankarpnrjeberhard
authored andcommitted
Port on prem integration tests
1 parent a98c6f1 commit 5c5063b

21 files changed

+1284
-12
lines changed

Jenkinsfile.podman

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ nodes:
475475
hostPort: 2224
476476
- containerPort: 31128
477477
hostPort: 2228
478+
- containerPort: 31132
479+
hostPort: 8001
480+
- containerPort: 31136
481+
hostPort: 2232
478482
extraMounts:
479483
- hostPath: ${pv_root}
480484
containerPath: ${pv_root}
@@ -576,6 +580,7 @@ EOF
576580
echo "-Dwko.it.remoteconsole.version=\"${REMOTECONSOLE_VERSION}\"" >> ${WORKSPACE}/.mvn/maven.config
577581
echo "-Djdk.httpclient.allowRestrictedHeaders=\"host\"" >> ${WORKSPACE}/.mvn/maven.config
578582
echo "-DOPERATOR_LOG_LEVEL=\"${OPERATOR_LOG_LEVEL}\"" >> ${WORKSPACE}/.mvn/maven.config
583+
echo "-Dwko.it.install.weblogic=\"true\"" >> ${WORKSPACE}/.mvn/maven.config
579584

580585
echo "${WORKSPACE}/.mvn/maven.config contents:"
581586
cat "${WORKSPACE}/.mvn/maven.config"

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

Lines changed: 809 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,12 @@ public interface TestConstants {
464464

465465
public static final String LARGE_DOMAIN_TESTING_PROPS_FILE =
466466
"largedomaintesting.props";
467+
468+
public static final boolean INSTALL_WEBLOGIC = Boolean.valueOf((getNonEmptySystemProperty("wko.it.install.weblogic",
469+
"false")));
470+
public static final String WEBLOGIC_SHIPHOME = getNonEmptySystemProperty("wko.it.wls.shiphome",
471+
"https://home.us.oracle.com/results/release/src141200/fmw_14.1.2.0.0_wls_generic.jar");
472+
467473
public static final String ORACLE_OPERATOR_NS = "ns-oracle-operator";
468474

469475
//node ports used by the integration tests
@@ -549,6 +555,12 @@ public interface TestConstants {
549555
public static final int IT_REMOTECONSOLENGINX_INGRESS_HTTP_NODEPORT = 31124;
550556
public static final int IT_REMOTECONSOLENGINX_INGRESS_HTTP_HOSTPORT = 2224;
551557
public static final int IT_REMOTECONSOLENGINX_INGRESS_HTTPS_NODEPORT = 31128;
552-
public static final int IT_REMOTECONSOLENGINX_INGRESS_HTTPS_HOSTPORT = 2228;
558+
public static final int IT_REMOTECONSOLENGINX_INGRESS_HTTPS_HOSTPORT = 2228;
559+
560+
public static final int IT_ONPREMCRDOMAINTX_INGRESS_HTTP_NODEPORT = 31132;
561+
public static final int IT_ONPREMCRDOMAINTX_INGRESS_HTTP_HOSTPORT = 8001;
562+
public static final int IT_ONPREMCRDOMAINTX_CLUSTER_NODEPORT = 31136;
563+
public static final int IT_ONPREMCRDOMAINTX_CLUSTER_HOSTPORT = 2232;
564+
553565

554566
}

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/AppBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ public boolean archiveApp() {
244244
List<String> srcFiles = params.srcDirList();
245245
String srcFile = srcFiles.get(0);
246246
String appName = srcFile.substring(srcFile.lastIndexOf("/") + 1, srcFile.lastIndexOf("."));
247+
params.appName(appName);
247248
String archiveSrcDir = params.appArchiveDir() + "/wlsdeploy/applications";
248249

249250
try {

integration-tests/src/test/java/oracle/weblogic/kubernetes/extensions/InitializationTasks.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_NAME;
5757
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TAG;
5858
import static oracle.weblogic.kubernetes.TestConstants.INGRESS_CLASS_FILE_NAME;
59+
import static oracle.weblogic.kubernetes.TestConstants.INSTALL_WEBLOGIC;
5960
import static oracle.weblogic.kubernetes.TestConstants.KIND_REPO;
6061
import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI;
6162
import static oracle.weblogic.kubernetes.TestConstants.LOCALE_IMAGE_NAME;
@@ -86,6 +87,7 @@
8687
import static oracle.weblogic.kubernetes.TestConstants.WDT_BASIC_MODEL_PROPERTIES_FILE;
8788
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_NAME;
8889
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
90+
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SHIPHOME;
8991
import static oracle.weblogic.kubernetes.TestConstants.WLSIMG_BUILDER;
9092
import static oracle.weblogic.kubernetes.actions.ActionConstants.ARCHIVE_DIR;
9193
import static oracle.weblogic.kubernetes.actions.ActionConstants.DOWNLOAD_DIR;
@@ -107,6 +109,7 @@
107109
import static oracle.weblogic.kubernetes.actions.TestActions.imageRepoLogin;
108110
import static oracle.weblogic.kubernetes.actions.TestActions.imageTag;
109111
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallOperator;
112+
import static oracle.weblogic.kubernetes.actions.impl.primitive.Command.defaultCommandParams;
110113
import static oracle.weblogic.kubernetes.assertions.TestAssertions.doesImageExist;
111114
import static oracle.weblogic.kubernetes.assertions.TestAssertions.imageExists;
112115
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
@@ -329,6 +332,9 @@ public void beforeAll(ExtensionContext context) {
329332
logger.info("Installing istio before any test suites are run");
330333
installIstio();
331334
}
335+
if (INSTALL_WEBLOGIC && !OKD && !CRIO && !ARM && !OKE_CLUSTER) {
336+
installOnPremWebLogic();
337+
}
332338
} finally {
333339
// Initialization is done. Release all waiting other threads. The latch is now disabled so
334340
// other threads
@@ -702,5 +708,17 @@ private void installOracleDBOperator() {
702708
}
703709
assertDoesNotThrow(() -> installDBOperator(), "Failed to install database operator");
704710
}
711+
712+
private void installOnPremWebLogic() {
713+
Path installScript = Paths.get(RESOURCE_DIR, "bash-scripts", "install-wls.sh");
714+
String command
715+
= String.format("%s %s %s %s", "/bin/bash", installScript, RESULTS_ROOT, WEBLOGIC_SHIPHOME);
716+
getLogger().info("WebLogic installation command {0}", command);
717+
assertTrue(() -> Command.withParams(
718+
defaultCommandParams()
719+
.command(command)
720+
.redirect(false))
721+
.execute());
722+
}
705723

706724
}

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ public static void replaceStringInFile(String filePath, String regex, String rep
496496
Path src = Paths.get(filePath);
497497
logger.info("Replacing {0} in {1} with {2}", regex, src.toString(), replacement);
498498
String content = new String(Files.readAllBytes(src), StandardCharsets.UTF_8);
499-
if (!content.contains(regex)) {
500-
logger.info("search string {0} not found to replace with {1}", regex, replacement);
499+
if (!content.matches(regex)) {
500+
logger.warning("search string {0} not found to replace with {1}", regex, replacement);
501501
}
502502
long oldModified = src.toFile().lastModified();
503503
Files.write(src, content.replaceAll(regex, replacement).getBytes(StandardCharsets.UTF_8));

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/ImageUtils.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,28 +209,29 @@ public static String createDiiImageAndVerify(String domainUid,
209209
}
210210

211211
/**
212-
* Create an image with modelfile, application archive and property file. If the property file
213-
* is needed to be updated with a property that has been created by the framework, it is copied
214-
* onto RESULT_ROOT and updated. Hence the altModelDir. Call this method to create a domain home in image.
212+
* Create an image with modelfile, application archive and property file.If the property file
213+
is needed to be updated with a property that has been created by the framework, it is copied
214+
onto RESULT_ROOT and updated. Hence the altModelDir. Call this method to create a domain home in image.
215215
* @param imageNameBase - base image name used in local or to construct image name in repository
216216
* @param wdtModelList - model file used to build the image
217217
* @param appSrcDirList - application to be added to the image
218218
* @param modelPropFile - property file to be used with the model file above
219219
* @param altModelDir - directory where the property file is found if not in the default MODEL_DIR
220+
* @param domainUid domain uid
220221
* @return image name with tag
221222
*/
222223
public static String createImageAndVerify(String imageNameBase,
223224
List<String> wdtModelList,
224225
List<String> appSrcDirList,
225226
String modelPropFile,
226227
String altModelDir,
227-
String domainHome) {
228+
String domainUid) {
228229

229230
final List<String> modelPropList = Collections.singletonList(altModelDir + "/" + modelPropFile);
230231

231232
return createImageAndVerify(
232233
imageNameBase, wdtModelList, appSrcDirList, modelPropList, WEBLOGIC_IMAGE_NAME,
233-
WEBLOGIC_IMAGE_TAG, WLS, false, domainHome, false);
234+
WEBLOGIC_IMAGE_TAG, WLS, false, domainUid, false);
234235
}
235236

236237
/**

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/OracleHttpClient.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@
44
package oracle.weblogic.kubernetes.utils;
55

66
import java.io.IOException;
7+
import java.net.InetSocketAddress;
8+
import java.net.ProxySelector;
79
import java.net.Socket;
810
import java.net.URI;
911
import java.net.http.HttpClient;
1012
import java.net.http.HttpRequest;
1113
import java.net.http.HttpResponse;
14+
import java.net.http.HttpTimeoutException;
15+
import java.nio.file.Paths;
1216
import java.security.SecureRandom;
1317
import java.security.cert.CertificateException;
1418
import java.security.cert.X509Certificate;
1519
import java.time.Duration;
1620
import java.util.Base64;
1721
import java.util.Map;
1822
import java.util.Map.Entry;
23+
import java.util.concurrent.TimeUnit;
1924
import javax.net.ssl.SSLContext;
2025
import javax.net.ssl.SSLEngine;
2126
import javax.net.ssl.TrustManager;
@@ -125,6 +130,64 @@ public static HttpResponse<String> get(String url, Map<String, String> headers)
125130
return get(url, headers, false);
126131
}
127132

133+
/**
134+
* Http GET request to download a file and save it in the give destination directory.
135+
*
136+
* @param url URL of the file to download
137+
* @param destLocation detination directory where to save the downloaded file
138+
* @param proxyHost optional proxy host, can be null for no proxy
139+
* @param proxyPort optional proxy port, can be null for no proxy
140+
* @param maxRetries the maximum number of retries before it can return false
141+
* @return true if download succeeds otherwide false
142+
*/
143+
public static boolean downloadFile(String url, String destLocation, String proxyHost,
144+
String proxyPort, int maxRetries) {
145+
LoggingFacade logger = getLogger();
146+
147+
// Build HttpClient with optional proxy and retry policy
148+
HttpClient.Builder clientBuilder = HttpClient.newBuilder()
149+
.version(HttpClient.Version.HTTP_2)
150+
.followRedirects(HttpClient.Redirect.NORMAL)
151+
.connectTimeout(Duration.ofSeconds(10));
152+
153+
// Configure proxy if PROXY_HOST and PROXY_PORT are specified
154+
if (proxyHost != null && proxyPort != null) {
155+
clientBuilder.proxy(ProxySelector.of(new InetSocketAddress(proxyHost, Integer.valueOf(proxyPort))));
156+
logger.info("Proxy configured: {0}:{1}", proxyHost, proxyPort);
157+
} else {
158+
logger.info("No proxy configuration provided.");
159+
}
160+
161+
HttpClient client = clientBuilder.build();
162+
163+
// Prepare the HttpRequest
164+
HttpRequest request = HttpRequest.newBuilder()
165+
.uri(URI.create(url))
166+
.timeout(Duration.ofMinutes(2))
167+
.GET()
168+
.build();
169+
170+
// Attempt to download the file
171+
for (int attempt = 1; attempt <= maxRetries; attempt++) {
172+
try {
173+
logger.info("Starting download...");
174+
if (client.send(request, HttpResponse.BodyHandlers.ofFile(Paths.get(destLocation))).statusCode() != 200) {
175+
logger.info("Failed download retrying...");
176+
TimeUnit.SECONDS.sleep(10);
177+
continue;
178+
} else {
179+
logger.info("Download completed successfully.");
180+
return true;
181+
}
182+
} catch (HttpTimeoutException e) {
183+
logger.severe("Request timed out: {0}", e.getMessage());
184+
} catch (IOException | InterruptedException e) {
185+
logger.severe("Download failed: {0}", e.getMessage());
186+
}
187+
}
188+
return false;
189+
}
190+
128191
private static final TrustManager MOCK_TRUST_MANAGER = new X509ExtendedTrustManager() {
129192
@Override
130193
public java.security.cert.X509Certificate[] getAcceptedIssuers() {

integration-tests/src/test/resources/bash-scripts/install-istio.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,22 @@ ${KUBERNETES_CLI} delete namespace istio-system --ignore-not-found
3333
# create the namespace 'istio-system'
3434
${KUBERNETES_CLI} create namespace istio-system
3535

36-
( cd $workdir;
37-
oci os object get --namespace=${wko_tenancy} --bucket-name=wko-system-test-files \
38-
--name=istio/istio-${version}-${arch}.tar.gz --file=istio.tar.gz \
39-
--auth=instance_principal
36+
( cd $workdir
37+
if [ -z "$JENKINS_HOME" ]; then
38+
# Not in Jenkins, download using curl
39+
echo "Detected local environment. Downloading Istio using curl."
40+
curl -Lo istio.tar.gz https://github.com/istio/istio/releases/download/${version}/istio-${version}-${arch}.tar.gz
41+
else
42+
# Running in Jenkins, download using OCI CLI
43+
echo "Detected Jenkins environment. Downloading Istio using OCI CLI."
44+
oci os object get --namespace=${wko_tenancy} --bucket-name=wko-system-test-files \
45+
--name=istio/istio-${version}-${arch}.tar.gz --file=istio.tar.gz \
46+
--auth=instance_principal
47+
fi
4048
tar zxf istio.tar.gz
4149
)
4250

51+
4352
( ${KUBERNETES_CLI} create secret generic docker-istio-secret --type=kubernetes.io/dockerconfigjson --from-file=.dockerconfigjson=$HOME/.docker/config.json -n istio-system )
4453

4554
# set custom docker registry to gcr.io/istio-release to avoid
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
# Copyright (c) 2024, Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
echo $JAVA_HOME
6+
if [ -n "$1" ]; then
7+
echo "RESULT_ROOT is set"
8+
result_root=$1
9+
else
10+
echo "no RESULT_ROOT is set, exiting wls installation."
11+
exit 0
12+
fi
13+
14+
if [ -n "$2" ]; then
15+
echo "WEBLOGIC_SHIPHOME is set"
16+
shiphome_url=$2
17+
else
18+
echo "no WEBLOGIC_SHIPHOME is set, exiting wls installation."
19+
exit 0
20+
fi
21+
22+
echo $result_root
23+
echo $shiphome_url
24+
MW_HOME="$result_root/mwhome"
25+
SILENT_RESPONSE_FILE=$result_root/silent.response
26+
ORAINVENTORYPOINTER_LOC=$result_root/oraInv.loc
27+
ORAINVENTORY_LOC=$result_root/oraInventory
28+
WLS_SHIPHOME=$result_root/fmw_wls_generic.jar
29+
SUCCESS="The\ installation\ of\ Oracle\ Fusion\ Middleware.*completed\ successfully"
30+
31+
rm -rf $MW_HOME/*
32+
rm -rf $SILENT_RESPONSE_FILE
33+
rm -rf $ORAINVENTORY_LOC/*
34+
rm -rf $ORAINVENTORYPOINTER_LOC
35+
mkdir -p $MW_HOME
36+
mkdir -p $ORAINVENTORY_LOC
37+
38+
echo "creating $SILENT_RESPONSE_FILE file with contents"
39+
40+
cat <<EOF > $SILENT_RESPONSE_FILE
41+
[ENGINE]
42+
Response File Version=1.0.0.0.0
43+
[GENERIC]
44+
ORACLE_HOME=$MW_HOME
45+
INSTALL_TYPE=WebLogic Server
46+
EOF
47+
48+
cat $SILENT_RESPONSE_FILE
49+
50+
echo "creating $ORAINVENTORYPOINTER_LOC file with contents"
51+
52+
cat <<EOF > $ORAINVENTORYPOINTER_LOC
53+
inventory_loc=$ORAINVENTORY_LOC
54+
inst_group=opc
55+
EOF
56+
57+
cat $ORAINVENTORYPOINTER_LOC
58+
59+
#download WebLogic shiphome installer
60+
curl -Lo $WLS_SHIPHOME $shiphome_url
61+
ls -l $WLS_SHIPHOME
62+
md5sum $WLS_SHIPHOME
63+
64+
#install WebLogic
65+
echo "Running java -jar $WLS_SHIPHOME -silent -responseFile $SILENT_RESPONSE_FILE -invPtrLoc $ORAINVENTORYPOINTER_LOC"
66+
install_log=$(java -jar $WLS_SHIPHOME -silent -responseFile $SILENT_RESPONSE_FILE -invPtrLoc $ORAINVENTORYPOINTER_LOC)
67+
if [[ "$install_log" =~ $SUCCESS ]]; then
68+
echo "The installation of WebLogic completed successfully."
69+
. $MW_HOME/wlserver/server/bin/setWLSEnv.sh
70+
java weblogic.version
71+
else
72+
echo "The installation of WebLogic failed."
73+
fi

0 commit comments

Comments
 (0)