Skip to content

Commit 4658317

Browse files
xiancaorjeberhard
authored andcommitted
Fix ItWlsMiiSample tests regression failing at initialMain with 404
1 parent 187725e commit 4658317

File tree

7 files changed

+99
-39
lines changed

7 files changed

+99
-39
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2023, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
@@ -239,7 +239,7 @@ public void testUpate3() {
239239
* Test model in image sample update domain use case 4.
240240
*/
241241
@Test
242-
@Order(7)
242+
@Order(8)
243243
public void testUpate4() {
244244
execTestScriptAndAssertSuccess("-update4", "Failed to run -update4");
245245
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2023, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
@@ -239,7 +239,7 @@ public void testUpate3() {
239239
* Test model in image sample update domain use case 4.
240240
*/
241241
@Test
242-
@Order(7)
242+
@Order(8)
243243
public void testUpate4() {
244244
execTestScriptAndAssertSuccess("-update4", "Failed to run -update4");
245245
}

kubernetes/samples/scripts/create-weblogic-domain/wdt-artifacts/archives/archive-v1/wlsdeploy/applications/myapp-v1/myapp_war/index.jsp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
<%-- Copyright (c) 2019, 2023, Oracle and/or its affiliates. --%>
1+
<%-- Copyright (c) 2019, 2024, Oracle and/or its affiliates. --%>
22
<%-- Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. --%>
33
<%@ page import="java.io.PrintStream" %>
4+
<%@ page import="java.util.Set" %>
45
<%@ page import="javax.management.MBeanServer" %>
56
<%@ page import="javax.management.ObjectInstance" %>
67
<%@ page import="javax.management.ObjectName" %>

kubernetes/samples/scripts/create-weblogic-domain/wdt-artifacts/archives/archive-v2/wlsdeploy/applications/myapp-v1/myapp_war/index.jsp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
<%-- Copyright (c) 2019, 2023, Oracle and/or its affiliates. --%>
1+
<%-- Copyright (c) 2019, 2024, Oracle and/or its affiliates. --%>
22
<%-- Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. --%>
33
<%@ page import="java.io.PrintStream" %>
4+
<%@ page import="java.util.Set" %>
45
<%@ page import="javax.management.MBeanServer" %>
56
<%@ page import="javax.management.ObjectInstance" %>
67
<%@ page import="javax.management.ObjectName" %>

kubernetes/samples/scripts/create-weblogic-domain/wdt-artifacts/archives/archive-v2/wlsdeploy/applications/myapp-v2/myapp_war/index.jsp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
<%-- Copyright (c) 2019, 2023, Oracle and/or its affiliates. --%>
1+
<%-- Copyright (c) 2019, 2024, Oracle and/or its affiliates. --%>
22
<%-- Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. --%>
33
<%@ page import="java.io.PrintStream" %>
4+
<%@ page import="java.util.Set" %>
45
<%@ page import="javax.management.MBeanServer" %>
56
<%@ page import="javax.management.ObjectInstance" %>
67
<%@ page import="javax.management.ObjectName" %>

operator/integration-tests/model-in-image/run-test.sh

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44

55
#
@@ -420,10 +420,13 @@ if [ "$DO_INITIAL_MAIN" = "true" ]; then
420420

421421
if [ ! "$DRY_RUN" = "true" ]; then
422422
diefast # (cheat to speedup a subsequent roll/shutdown)
423-
testapp internal cluster-1 "Hello World!"
424423
if [ "$OKD" = "true" ]; then
425-
testapp OKD cluster-1 "Hello World!"
424+
testapp OKD cluster-1 "Hello World!"
425+
elif [ "$KIND_CLUSTER" = "true" ]; then
426+
testapp internal cluster-1 v1 "Hello World!"
427+
testapp traefik cluster-1 v1 "Hello World!"
426428
else
429+
testapp internal cluster-1 "Hello World!"
427430
testapp traefik cluster-1 "Hello World!"
428431
fi
429432
fi
@@ -461,13 +464,16 @@ if [ "$DO_UPDATE1" = "true" ]; then
461464

462465
if [ ! "$DRY_RUN" = "true" ]; then
463466
diefast # (cheat to speedup a subsequent roll/shutdown)
464-
testapp internal cluster-1 "mynewdatasource"
465467
if [ "$OKD" = "true" ]; then
466468
routeHost=$(getRouteHost "${DOMAIN_UID}-cluster-cluster-1")
467469
echo $routeHost
468470
doCommand -c export ROUTE_HOST=${routeHost}
469-
testapp OKD cluster-1 "mynewdatasource"
471+
testapp OKD cluster-1 "mynewdatasource"
472+
elif [ "$KIND_CLUSTER" = "true" ]; then
473+
testapp internal cluster-1 v1 "mynewdatasource"
474+
testapp traefik cluster-1 v1 "mynewdatasource"
470475
else
476+
testapp internal cluster-1 "mynewdatasource"
471477
testapp traefik cluster-1 "mynewdatasource"
472478
fi
473479
fi
@@ -521,17 +527,23 @@ if [ "$DO_UPDATE2" = "true" ]; then
521527

522528
if [ ! "$DRY_RUN" = "true" ]; then
523529
diefast # (cheat to speedup a subsequent roll/shutdown)
524-
testapp internal cluster-1 "name....domain2"
525530
if [ "$OKD" = "true" ]; then
526-
testapp OKD cluster-1 "name....domain2"
531+
testapp OKD cluster-1 "name....domain2"
532+
elif [ "$KIND_CLUSTER" = "true" ]; then
533+
testapp internal cluster-1 v1 "name....domain2"
534+
testapp traefik cluster-1 v1 "name....domain2"
527535
else
536+
testapp internal cluster-1 "name....domain2"
528537
testapp traefik cluster-1 "name....domain2"
529538
fi
530539
doCommand -c export DOMAIN_UID=$DOMAIN_UID1
531-
testapp internal cluster-1 "name....domain1"
532540
if [ "$OKD" = "true" ]; then
533-
testapp OKD cluster-1 "name....domain2"
541+
testapp OKD cluster-1 "name....domain2"
542+
elif [ "$KIND_CLUSTER" = "true" ]; then
543+
testapp internal cluster-1 v1 "name....domain1"
544+
testapp traefik cluster-1 v1 "name....domain1"
534545
else
546+
testapp internal cluster-1 "name....domain1"
535547
testapp traefik cluster-1 "name....domain1"
536548
fi
537549
fi
@@ -583,13 +595,16 @@ if [ "$DO_UPDATE3_MAIN" = "true" ]; then
583595

584596
if [ ! "$DRY_RUN" = "true" ]; then
585597
diefast # (cheat to speedup a subsequent roll/shutdown)
586-
testapp internal cluster-1 "v2"
587598
if [ "$OKD" = "true" ]; then
588599
routeHost=$(getRouteHost "${DOMAIN_UID}-cluster-cluster-1")
589600
echo $routeHost
590601
doCommand -c export ROUTE_HOST=${routeHost}
591-
testapp OKD cluster-1 "v2"
602+
testapp OKD cluster-1 "v2"
603+
elif [ "$KIND_CLUSTER" = "true" ]; then
604+
testapp internal cluster-1 v2 "v2"
605+
testapp traefik cluster-1 v2 "v2"
592606
else
607+
testapp internal cluster-1 "v2"
593608
testapp traefik cluster-1 "v2"
594609
fi
595610
fi
@@ -634,10 +649,19 @@ if [ "$DO_UPDATE4" = "true" ]; then
634649
waitForDomain Completed
635650

636651
if [ ! "$DRY_RUN" = "true" ]; then
637-
testapp internal cluster-1 "'SampleMinThreads' with configured count: 2" 60 quiet
638-
testapp internal cluster-1 "'SampleMaxThreads' with configured count: 20"
652+
if [ "$KIND_CLUSTER" = "true" ]; then
653+
testapp internal cluster-1 v2 "'SampleMinThreads' with configured count: 2" 60 quiet
654+
testapp internal cluster-1 v2 "'SampleMaxThreads' with configured count: 20"
655+
else
656+
testapp internal cluster-1 "'SampleMinThreads' with configured count: 2" 60 quiet
657+
testapp internal cluster-1 "'SampleMaxThreads' with configured count: 20"
658+
fi
639659
if [ "$DO_ASSUME_DB" = "true" ]; then
640-
testapp internal cluster-1 "Datasource 'mynewdatasource': State='Running', testPool='Passed'"
660+
if [ "$KIND_CLUSTER" = "true" ]; then
661+
testapp internal cluster-1 v2 "Datasource 'mynewdatasource': State='Running', testPool='Passed'"
662+
else
663+
testapp internal cluster-1 "Datasource 'mynewdatasource': State='Running', testPool='Passed'"
664+
fi
641665
fi
642666

643667
podInfoAfter="$(getPodInfo | grep -v introspectVersion)"

operator/integration-tests/model-in-image/util-misc.sh

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
timestamp() {
@@ -37,7 +37,11 @@ get_service_yaml() {
3737
get_kube_address() {
3838
# ${KUBERNETES_CLI:-kubectl} cluster-info | grep KubeDNS | sed 's;^.*//;;' | sed 's;:.*$;;'
3939
# This is the heuristic used by the integration test framework:
40-
echo ${K8S_NODEPORT_HOST:-$(hostname)}
40+
if [ "$KIND_CLUSTER" = "true" ]; then
41+
echo $(${KUBERNETES_CLI:-kubectl} get node kind-worker -o jsonpath='{.status.addresses[?(@.type == "InternalIP")].address}')
42+
else
43+
echo ${K8S_NODEPORT_HOST:-$(hostname)}
44+
fi
4145
}
4246

4347
get_sample_host() {
@@ -60,6 +64,8 @@ get_curl_command() {
6064
# $1 is service name
6165
if [ "$OKD" = "true" ]; then
6266
echo "curl -s -S $(curl_timeout_parms) "
67+
elif [ "$KIND_CLUSTER" = "true" ]; then
68+
echo "curl --noproxy '*' -s -S $(curl_timeout_parms) -H 'host: $(get_sample_host $1)'"
6369
else
6470
echo "curl -s -S $(curl_timeout_parms) -H 'host: $(get_sample_host $1)'"
6571
fi
@@ -74,11 +80,17 @@ get_curl_command() {
7480
# with an URL that has the cluster service name
7581
# "traefik" invokes curl locally using the traefik node port
7682
# $2 cluster-1 or cluster-2
77-
# $3 search string expected in curl output
78-
# $4 quiet mode: 'true' or 'false' (anything not 'false' is treated as true)
79-
# $5 max retries (default 15)
80-
#
81-
# For example, 'testapp internal "Hello World!"'.
83+
# if k8s cluster is KIND cluster:
84+
# $3 appversion
85+
# $4 search string expected in curl output
86+
# $5 quiet mode: 'true' or 'false' (anything not 'false' is treated as true)
87+
# $6 max retries (default 15)
88+
# For example, 'testapp internal cluster-1 v1 "Hello World!"'.
89+
# else
90+
# $3 search string expected in curl output
91+
# $4 quiet mode: 'true' or 'false' (anything not 'false' is treated as true)
92+
# $5 max retries (default 15)
93+
# For example, 'testapp internal cluster-1 "Hello World!"'.
8294

8395
testapp() {
8496

@@ -87,8 +99,13 @@ testapp() {
8799

88100
local num_tries=0
89101
local traefik_nodeport=''
90-
local max_tries="${4:-15}"
91-
local quiet="${5:-false}"
102+
if [ "$KIND_CLUSTER" = "true" ]; then
103+
local max_tries="${5:-15}"
104+
local quiet="${6:-false}"
105+
else
106+
local max_tries="${4:-15}"
107+
local quiet="${5:-false}"
108+
fi
92109
local target_file_prefix="$WORKDIR/test-out/$PPID.$(printf "%3.3u" ${COMMAND_OUTFILE_COUNT:-0})"
93110
local target_file=${target_file_prefix}.$(timestamp).testapp.curl.$1.$((num_tries + 1)).out
94111
local start_secs=$SECONDS
@@ -102,8 +119,11 @@ testapp() {
102119
local cluster_service_name=$(get_service_name $domain_uid-cluster-$2)
103120
local admin_service_name=$(get_service_name $domain_uid-admin-server)
104121
local ns=${DOMAIN_NAMESPACE:-sample-domain1-ns}
105-
local command="${KUBERNETES_CLI:-kubectl} exec -n $ns $admin_service_name -- bash -c \"curl -s -S $(curl_timeout_parms) http://$cluster_service_name:8001/myapp_war/index.jsp\""
106-
122+
if [ "$KIND_CLUSTER" = "true" ]; then
123+
local command="${KUBERNETES_CLI:-kubectl} exec -n $ns $admin_service_name -- bash -c \"curl -s -S $(curl_timeout_parms) http://$cluster_service_name:8001/myapp-$3/myapp_war/index.jsp\""
124+
else
125+
local command="${KUBERNETES_CLI:-kubectl} exec -n $ns $admin_service_name -- bash -c \"curl -s -S $(curl_timeout_parms) http://$cluster_service_name:8001/myapp_war/index.jsp\""
126+
fi
107127
elif [ "$1" = "traefik" ]; then
108128
if [ -z "$traefik_nodeport" ]; then
109129
echo "@@ Info: Obtaining traefik nodeport by calling:"
@@ -116,8 +136,11 @@ EOF
116136
return 1
117137
fi
118138
fi
119-
local command="$(get_curl_command ${DOMAIN_UID:-sample-domain1}-cluster-$2) http://$(get_kube_address):${traefik_nodeport}/myapp_war/index.jsp"
120-
139+
if [ "$KIND_CLUSTER" = "true" ]; then
140+
local command="$(get_curl_command ${DOMAIN_UID:-sample-domain1}-cluster-$2) http://$(get_kube_address):${traefik_nodeport}/myapp-$3/myapp_war/index.jsp"
141+
else
142+
local command="$(get_curl_command ${DOMAIN_UID:-sample-domain1}-cluster-$2) http://$(get_kube_address):${traefik_nodeport}/myapp_war/index.jsp"
143+
fi
121144
elif [ "$1" = "OKD" ]; then
122145
echo "In testapp OKD case"
123146
local command="$(get_curl_command ${DOMAIN_UID:-sample-domain1}-cluster-$2) http://${ROUTE_HOST}/myapp_war/index.jsp"
@@ -129,8 +152,11 @@ EOF
129152

130153
fi
131154

132-
133-
local outstr="@@ Info: Searching for '$3' in '$1' mode curl app invoke of cluster '$2' using '$command', "
155+
if [ "$KIND_CLUSTER" = "true" ]; then
156+
local outstr="@@ Info: Searching for '$4' in '$1' mode curl app invoke of cluster '$2' using '$command', "
157+
else
158+
local outstr="@@ Info: Searching for '$3' in '$1' mode curl app invoke of cluster '$2' using '$command', "
159+
fi
134160
if [ $quiet = 'false' ]; then
135161
echo -n "${outstr} output file '$target_file'."
136162
else
@@ -146,14 +172,21 @@ EOF
146172
# use "cat & sed" instead of "grep" as grep exits with an error when it doesn't find anything
147173

148174
local before=$(cat $target_file)
149-
local after=$(cat $target_file | sed "s/$3/ADIFFERENTVALUE/g")
150-
175+
if [ "$KIND_CLUSTER" = "true" ]; then
176+
local after=$(cat $target_file | sed "s/$4/ADIFFERENTVALUE/g")
177+
else
178+
local after=$(cat $target_file | sed "s/$3/ADIFFERENTVALUE/g")
179+
fi
151180
if [ "$before" = "$after" ]; then
152181

153182
num_tries=$((num_tries + 1))
154183
if [ $num_tries -gt $max_tries ]; then
155184
echo
156-
echo "@@ Error: '$3' not found in app response for command '$command' after try number '$num_tries'. Total seconds=$((SECONDS-start_secs)). Contents of response file '$target_file':"
185+
if [ "$KIND_CLUSTER" = "true" ]; then
186+
echo "@@ Error: '$4' not found in app response for command '$command' after try number '$num_tries'. Total seconds=$((SECONDS-start_secs)). Contents of response file '$target_file':"
187+
else
188+
echo "@@ Error: '$3' not found in app response for command '$command' after try number '$num_tries'. Total seconds=$((SECONDS-start_secs)). Contents of response file '$target_file':"
189+
fi
157190
cat $target_file
158191
return 1
159192
fi

0 commit comments

Comments
 (0)