Skip to content

Commit a82afee

Browse files
committed
Merge branch 'OWLS-115401' into 'release/4.2'
Add test cross domain transaction between k8s domain and external domain using WLS 14.1.2.0.0 See merge request weblogic-cloud/weblogic-kubernetes-operator!4870
2 parents 359748e + 614cde1 commit a82afee

15 files changed

+1000
-6
lines changed

Jenkinsfile.podman

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ nodes:
467467
hostPort: 2224
468468
- containerPort: 31128
469469
hostPort: 2228
470+
- containerPort: 31132
471+
hostPort: 8001
470472
extraMounts:
471473
- hostPath: ${pv_root}
472474
containerPath: ${pv_root}
@@ -567,6 +569,7 @@ EOF
567569
echo "-DWLSIMG_BUILDER=\"podman\"" >> ${WORKSPACE}/.mvn/maven.config
568570
echo "-Dwko.it.remoteconsole.version=\"${REMOTECONSOLE_VERSION}\"" >> ${WORKSPACE}/.mvn/maven.config
569571
echo "-Djdk.httpclient.allowRestrictedHeaders=\"host\"" >> ${WORKSPACE}/.mvn/maven.config
572+
echo "-Dinstall.weblogic=\"true\"" >> ${WORKSPACE}/.mvn/maven.config
570573

571574
echo "${WORKSPACE}/.mvn/maven.config contents:"
572575
cat "${WORKSPACE}/.mvn/maven.config"
@@ -586,6 +589,7 @@ EOF
586589
export TEST_IMAGES_REPO_USERNAME="${OCIR_USER}"
587590
export TEST_IMAGES_REPO_PASSWORD="${OCIR_PASS}"
588591
export TEST_IMAGES_REPO_EMAIL="[email protected]"
592+
export SHIPHOME_DOWNLOAD_SERVER="home.us.oracle.com"
589593
if ! time mvn -pl integration-tests -P ${MAVEN_PROFILE_NAME} verify 2>&1 | tee "${result_root}/kindtest.log"; then
590594
echo "integration-tests failed"
591595
exit 1

integration-tests/pom.xml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<wko.it.image.tag.operator>${env.IMAGE_TAG_OPERATOR}</wko.it.image.tag.operator>
8181
<wko.it.release.image.name.operator>${env.RELEASE_IMAGE_OPERATOR}</wko.it.release.image.name.operator>
8282
<wko.it.crio.pipeline.image>${env.DOCKER_IMAGE}</wko.it.crio.pipeline.image>
83+
<wko.it.shiphome.download.server>${env.SHIPHOME_DOWNLOAD_SERVER}</wko.it.shiphome.download.server>
8384
<includes-failsafe>**/It*</includes-failsafe>
8485
</properties>
8586

@@ -770,6 +771,42 @@
770771
<skipITs>false</skipITs>
771772
<groups>v8o</groups>
772773
</properties>
773-
</profile>
774+
</profile>
775+
<!-- Profile for integration test environment -->
776+
<profile>
777+
<id>integration-test-env</id>
778+
<!-- This profile is activated only if 'install.weblogic' property is set to 'true' -->
779+
<activation>
780+
<property>
781+
<name>install.weblogic</name>
782+
<value>true</value>
783+
</property>
784+
</activation>
785+
<build>
786+
<plugins>
787+
<plugin>
788+
<groupId>org.codehaus.mojo</groupId>
789+
<artifactId>exec-maven-plugin</artifactId>
790+
<executions>
791+
<execution>
792+
<id>run-silent-install-script</id>
793+
<phase>pre-integration-test</phase>
794+
<goals>
795+
<goal>exec</goal>
796+
</goals>
797+
<configuration>
798+
<executable>bash</executable>
799+
<arguments>
800+
<argument>${project.basedir}/src/test/resources/bash-scripts/install-wls.sh</argument>
801+
<argument>${wko.it.result.root}</argument>
802+
<argument>${wko.it.shiphome.download.server}</argument>
803+
</arguments>
804+
</configuration>
805+
</execution>
806+
</executions>
807+
</plugin>
808+
</plugins>
809+
</build>
810+
</profile>
774811
</profiles>
775812
</project>

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

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,4 +564,7 @@ public interface TestConstants {
564564
public static final int IT_REMOTECONSOLENGINX_INGRESS_HTTPS_NODEPORT = 31128;
565565
public static final int IT_REMOTECONSOLENGINX_INGRESS_HTTPS_HOSTPORT = 2228;
566566

567+
public static final int IT_ONPREMCRDOMAINTX_INGRESS_HTTP_NODEPORT = 31132;
568+
public static final int IT_ONPREMCRDOMAINTX_INGRESS_HTTP_HOSTPORT = 8001;
569+
567570
}

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 id
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;
@@ -126,6 +131,64 @@ public static HttpResponse<String> get(String url, Map<String, String> headers)
126131
return get(url, headers, false);
127132
}
128133

134+
/**
135+
* Http GET request to download a file and save it in the give destination directory.
136+
*
137+
* @param url URL of the file to download
138+
* @param destLocation detination directory where to save the downloaded file
139+
* @param proxyHost optional proxy host, can be null for no proxy
140+
* @param proxyPort optional proxy port, can be null for no proxy
141+
* @param maxRetries the maximum number of retries before it can return false
142+
* @return true if download succeeds otherwide false
143+
*/
144+
public static boolean downloadFile(String url, String destLocation, String proxyHost,
145+
String proxyPort, int maxRetries) {
146+
LoggingFacade logger = getLogger();
147+
148+
// Build HttpClient with optional proxy and retry policy
149+
HttpClient.Builder clientBuilder = HttpClient.newBuilder()
150+
.version(HttpClient.Version.HTTP_2)
151+
.followRedirects(HttpClient.Redirect.NORMAL)
152+
.connectTimeout(Duration.ofSeconds(10));
153+
154+
// Configure proxy if PROXY_HOST and PROXY_PORT are specified
155+
if (proxyHost != null && proxyPort != null) {
156+
clientBuilder.proxy(ProxySelector.of(new InetSocketAddress(proxyHost, Integer.valueOf(proxyPort))));
157+
logger.info("Proxy configured: {0}:{1}", proxyHost, proxyPort);
158+
} else {
159+
logger.info("No proxy configuration provided.");
160+
}
161+
162+
HttpClient client = clientBuilder.build();
163+
164+
// Prepare the HttpRequest
165+
HttpRequest request = HttpRequest.newBuilder()
166+
.uri(URI.create(url))
167+
.timeout(Duration.ofMinutes(2))
168+
.GET()
169+
.build();
170+
171+
// Attempt to download the file
172+
for (int attempt = 1; attempt <= maxRetries; attempt++) {
173+
try {
174+
logger.info("Starting download...");
175+
if (client.send(request, HttpResponse.BodyHandlers.ofFile(Paths.get(destLocation))).statusCode() != 200) {
176+
logger.info("Failed download retrying...");
177+
TimeUnit.SECONDS.sleep(10);
178+
continue;
179+
} else {
180+
logger.info("Download completed successfully.");
181+
return true;
182+
}
183+
} catch (HttpTimeoutException e) {
184+
logger.severe("Request timed out: {0}", e.getMessage());
185+
} catch (IOException | InterruptedException e) {
186+
logger.severe("Download failed: {0}", e.getMessage());
187+
}
188+
}
189+
return false;
190+
}
191+
129192
private static final TrustManager MOCK_TRUST_MANAGER = new X509ExtendedTrustManager() {
130193
@Override
131194
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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" ] || [ -n "$result_root" ]; then
7+
echo "RESULT_ROOT or result_root is set"
8+
else
9+
echo "no RESULT_ROOT or result_root is set, exiting wls installation."
10+
exit 0
11+
fi
12+
13+
if [ -n "$2" ] || [ -n "$SHIPHOME_DOWNLOAD_SERVER" ]; then
14+
echo "SHIPHOME_DOWNLOAD_SERVER is set"
15+
else
16+
echo "no SHIPHOME_DOWNLOAD_SERVER is set, exiting wls installation."
17+
exit 0
18+
fi
19+
20+
if [ -z "$1" ]; then
21+
echo "running in Jenkins, result_root is set"
22+
else
23+
echo "running in localhost, RESULT_ROOT is set : $1"
24+
result_root=$1
25+
SHIPHOME_DOWNLOAD_SERVER=$2
26+
27+
fi
28+
echo $result_root
29+
echo $SHIPHOME_DOWNLOAD_SERVER
30+
MW_HOME="$result_root/mwhome"
31+
SILENT_RESPONSE_FILE=$result_root/silent.response
32+
ORAINVENTORYPOINTER_LOC=$result_root/oraInv.loc
33+
ORAINVENTORY_LOC=$result_root/oraInventory
34+
WLS_SHIPHOME=$result_root/fmw_wls_generic.jar
35+
DOWNLOAD_URL="http://$SHIPHOME_DOWNLOAD_SERVER/results/release/src141200/fmw_14.1.2.0.0_wls_generic.jar"
36+
SUCCESS="The\ installation\ of\ Oracle\ Fusion\ Middleware.*completed\ successfully"
37+
38+
rm -rf $MW_HOME/*
39+
rm -rf $SILENT_RESPONSE_FILE
40+
rm -rf $ORAINVENTORY_LOC/*
41+
rm -rf $ORAINVENTORYPOINTER_LOC
42+
mkdir -p $MW_HOME
43+
mkdir -p $ORAINVENTORY_LOC
44+
45+
echo "creating $SILENT_RESPONSE_FILE file with contents"
46+
47+
cat <<EOF > $SILENT_RESPONSE_FILE
48+
[ENGINE]
49+
Response File Version=1.0.0.0.0
50+
[GENERIC]
51+
ORACLE_HOME=$MW_HOME
52+
INSTALL_TYPE=WebLogic Server
53+
EOF
54+
55+
cat $SILENT_RESPONSE_FILE
56+
57+
echo "creating $ORAINVENTORYPOINTER_LOC file with contents"
58+
59+
cat <<EOF > $ORAINVENTORYPOINTER_LOC
60+
inventory_loc=$ORAINVENTORY_LOC
61+
inst_group=opc
62+
EOF
63+
64+
cat $ORAINVENTORYPOINTER_LOC
65+
66+
#download WebLogic shiphome installer
67+
curl -Lo $WLS_SHIPHOME $DOWNLOAD_URL
68+
ls -l $WLS_SHIPHOME
69+
md5sum $WLS_SHIPHOME
70+
71+
#install WebLogic
72+
echo "Running java -jar $WLS_SHIPHOME -silent -responseFile $SILENT_RESPONSE_FILE -invPtrLoc $ORAINVENTORYPOINTER_LOC"
73+
install_log=$(java -jar $WLS_SHIPHOME -silent -responseFile $SILENT_RESPONSE_FILE -invPtrLoc $ORAINVENTORYPOINTER_LOC)
74+
if [[ "$install_log" =~ $SUCCESS ]]; then
75+
echo "The installation of WebLogic completed successfully."
76+
. $MW_HOME/wlserver/server/bin/setWLSEnv.sh
77+
java weblogic.version
78+
else
79+
echo "The installation of WebLogic failed."
80+
fi
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
resources:
4+
FileStore:
5+
TestCdtFileStore:
6+
Target: 'cluster-1'
7+
JMSServer:
8+
TestCdtJmsServer:
9+
ProductionPausedAtStartup: false
10+
ConsumptionPausedAtStartup: false
11+
Target: 'cluster-1'
12+
PersistentStore: 'TestCdtFileStore'
13+
InsertionPausedAtStartup: false
14+
MessageCompressionOptions: GZIP_DEFAULT_COMPRESSION
15+
TestAdminJmsServer:
16+
ProductionPausedAtStartup: false
17+
ConsumptionPausedAtStartup: false
18+
Target: 'admin-server'
19+
InsertionPausedAtStartup: false
20+
MessageCompressionOptions: GZIP_DEFAULT_COMPRESSION
21+
22+
JMSSystemResource:
23+
TestAdminJmsModule:
24+
Target: 'admin-server'
25+
SubDeployment:
26+
TestAdminSubDeployment:
27+
Target: TestAdminJmsServer
28+
JmsResource:
29+
Queue:
30+
testAccountingQueue:
31+
SubDeploymentName: TestAdminSubDeployment
32+
JNDIName: jms.testAccountingQueue
33+
TestCdtJmsModule:
34+
Target: 'cluster-1'
35+
SubDeployment:
36+
TestCdtSubDeployment:
37+
Target: TestCdtJmsServer
38+
JmsResource:
39+
UniformDistributedQueue:
40+
testCdtUniformQueue:
41+
SubDeploymentName: TestCdtSubDeployment
42+
JNDIName: jms/testCdtUniformQueue
43+
ConnectionFactory:
44+
ClusterConnectionFactory:
45+
JNDIName: jms.ClusterConnectionFactory
46+
DefaultTargetingEnabled: true
47+
LoadBalancingParams:
48+
ServerAffinityEnabled: false
49+
LoadBalancingEnabled: true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
DOMAIN_NAME=domain1
5+
ADMIN_USERNAME=weblogic
6+
ADMIN_PASSWORD=welcome1
7+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
domainInfo:
5+
AdminUserName: '@@PROP:ADMIN_USERNAME@@'
6+
AdminPassword: '@@PROP:ADMIN_PASSWORD@@'
7+
ServerStartMode: 'prod'
8+
9+
topology:
10+
Name: '@@PROP:DOMAIN_NAME@@'
11+
AdminServerName: "admin-server"
12+
Cluster:
13+
"cluster-1":
14+
DynamicServers:
15+
ServerTemplate: "cluster-1-template"
16+
ServerNamePrefix: "managed-server"
17+
DynamicClusterSize: 2
18+
MaxDynamicClusterSize: 2
19+
CalculatedListenPorts: false
20+
Server:
21+
"admin-server":
22+
ListenPort: 7001
23+
ExternalDNSName: '@@PROP:DOMAIN_NAME@@-admin-server.@@PROP:NAMESPACE@@'
24+
25+
ServerTemplate:
26+
"cluster-1-template":
27+
Cluster: "cluster-1"
28+
ListenPort : 8001
29+
ExternalDNSName: '@@PROP:DOMAIN_NAME@@-managed-server${id}.@@PROP:NAMESPACE@@'
30+
DataSource:
31+
RmiJDBCSecurity: Compatibility
32+
33+
appDeployments:
34+
Application:
35+
jmservlet:
36+
SourcePath: "wlsdeploy/applications/jmsservlet.war"
37+
ModuleType: war
38+
Target: 'admin-server'
39+
mdbtopic:
40+
SourcePath: "wlsdeploy/applications/mdbtopic.jar"
41+
ModuleType: jar
42+
Target: 'cluster-1'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
DOMAIN_NAME=domain2
5+
ADMIN_USERNAME=weblogic
6+
ADMIN_PASSWORD=welcome1

0 commit comments

Comments
 (0)