Skip to content

Commit addd3c0

Browse files
author
Tom Barnes
authored
fix issue 1457 (and sundry) (#1631)
* fix issue 1457 (update introspector to work around off-line WLST bug for SSL bean), fix 'introspector' test's MII path (depended on missing scripts), add option to old integration tests to bypass its greedy need for a docker login when running locally * update comments in test util scripts
1 parent 5e11184 commit addd3c0

File tree

6 files changed

+265
-24
lines changed

6 files changed

+265
-24
lines changed

integration-tests/src/test/resources/setupenv.sh

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,41 @@ function cleanup {
99
function create_image_pull_secret_wl {
1010

1111
set +x
12+
13+
if [ "$LOCAL_RUN" = "true" ]; then
14+
if [ ! -z "$(docker images -q $IMAGE_NAME_WEBLOGIC:$IMAGE_TAG_WEBLOGIC)" ]; then
15+
return 0
16+
fi
17+
docker pull $IMAGE_NAME_WEBLOGIC:$IMAGE_TAG_WEBLOGIC
18+
if [ $? -eq 0 ]; then
19+
return 0
20+
fi
21+
fi
22+
1223
if [ -z "$OCR_USERNAME" ] || [ -z "$OCR_PASSWORD" ]; then
13-
echo "Provide Docker login details using env variables OCR_USERNAME and OCR_PASSWORD to pull the WebLogic image."
14-
exit 1
15-
fi
24+
echo "Provide Docker login details using env variables OCR_USERNAME and OCR_PASSWORD to pull the WebLogic image."
25+
exit 1
26+
fi
1627

1728
if [ -n "$OCR_USERNAME" ] && [ -n "$OCR_PASSWORD" ]; then
18-
echo "Creating Docker Secret"
19-
kubectl create secret docker-registry $IMAGE_PULL_SECRET_WEBLOGIC \
20-
--docker-server=${OCR_SERVER}/ \
21-
--docker-username=$OCR_USERNAME \
22-
--docker-password=$OCR_PASSWORD \
23-
--docker-email=$OCR_USERNAME@oracle.com \
24-
--dry-run -o yaml | kubectl apply -f -
29+
echo "Creating Docker Secret"
30+
kubectl create secret docker-registry $IMAGE_PULL_SECRET_WEBLOGIC \
31+
--docker-server=${OCR_SERVER}/ \
32+
--docker-username=$OCR_USERNAME \
33+
--docker-password=$OCR_PASSWORD \
34+
--docker-email=$OCR_USERNAME@oracle.com \
35+
--dry-run -o yaml | kubectl apply -f -
2536

26-
echo "Checking Secret"
27-
SECRET="`kubectl get secret $IMAGE_PULL_SECRET_WEBLOGIC | grep $IMAGE_PULL_SECRET_WEBLOGIC | wc | awk ' { print $1; }'`"
28-
if [ "$SECRET" != "1" ]; then
29-
echo "secret $IMAGE_PULL_SECRET_WEBLOGIC was not created successfully"
30-
exit 1
31-
fi
32-
33-
# below docker pull is needed to for domain home in image tests the base image should be in local repo
34-
docker login -u $OCR_USERNAME -p $OCR_PASSWORD ${OCR_SERVER}
35-
docker pull $IMAGE_NAME_WEBLOGIC:$IMAGE_TAG_WEBLOGIC
37+
echo "Checking Secret"
38+
SECRET="`kubectl get secret $IMAGE_PULL_SECRET_WEBLOGIC | grep $IMAGE_PULL_SECRET_WEBLOGIC | wc | awk ' { print $1; }'`"
39+
if [ "$SECRET" != "1" ]; then
40+
echo "secret $IMAGE_PULL_SECRET_WEBLOGIC was not created successfully"
41+
exit 1
42+
fi
3643

44+
# below docker pull is needed to for domain home in image tests the base image should be in local repo
45+
docker login -u $OCR_USERNAME -p $OCR_PASSWORD ${OCR_SERVER}
46+
docker pull $IMAGE_NAME_WEBLOGIC:$IMAGE_TAG_WEBLOGIC
3747
fi
3848
set -x
3949
}

integration-tests/src/test/resources/wdt/config.cluster.topology.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ topology:
1212
Server:
1313
'@@PROP:ADMIN_NAME@@':
1414
ListenPort: '@@PROP:ADMIN_PORT@@'
15+
SSL:
16+
Enabled: false
17+
ListenPort: 7002
18+
HostnameVerificationIgnored: true
19+
JSSEEnabled: true
1520
NetworkAccessPoint:
1621
T3Channel:
1722
ListenPort: '@@PROP:T3_CHANNEL_PORT@@'
@@ -20,9 +25,24 @@ topology:
2025
'managed-server1':
2126
Cluster: '@@PROP:CLUSTER_NAME@@'
2227
ListenPort: '@@PROP:MANAGED_SERVER_PORT@@'
28+
SSL:
29+
Enabled: false
30+
ListenPort: 7123
31+
HostnameVerificationIgnored: true
32+
JSSEEnabled: true
2333
'managed-server2':
2434
Cluster: '@@PROP:CLUSTER_NAME@@'
2535
ListenPort: '@@PROP:MANAGED_SERVER_PORT@@'
36+
SSL:
37+
Enabled: false
38+
ListenPort: 7123
39+
HostnameVerificationIgnored: true
40+
JSSEEnabled: true
2641
'managed-server3':
2742
Cluster: '@@PROP:CLUSTER_NAME@@'
2843
ListenPort: '@@PROP:MANAGED_SERVER_PORT@@'
44+
SSL:
45+
Enabled: false
46+
ListenPort: 7123
47+
HostnameVerificationIgnored: true
48+
JSSEEnabled: true

operator/src/main/resources/scripts/introspectDomain.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,15 @@ def getDynamicServersOrNone(self,cluster):
395395
ret = None
396396
return ret
397397

398+
# Work-around bugs in off-line WLST when accessing an SSL mbean
398399
def getSSLOrNone(self,server):
399400
try:
401+
# this can throw if SSL mbean not there
400402
ret = server.getSSL()
403+
# this can throw if SSL mbean is there but enabled is false
404+
ssl.getListenPort()
405+
# this can throw if SSL mbean is there but enabled is false
406+
ssl.isListenPortEnabled()
401407
except:
402408
trace("Ignoring getSSL() exception, this is expected.")
403409
ret = None

src/integration-tests/introspector/introspectTest.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,7 @@ function createMII_Image() {
451451

452452
tracen "Info: Downloading WDT and WIT"
453453
printdots_start
454-
${SOURCEPATH}/kubernetes/samples/scripts/create-weblogic-domain/model-in-image/build_download.sh \
455-
> ${test_home}/miibuild_download.out 2>&1
454+
${SCRIPTPATH}/util_download_mii_tools.sh > ${test_home}/miibuild_download.out 2>&1
456455
local rc=$?
457456
printdots_end
458457
if [ $rc -ne 0 ] ; then
@@ -464,8 +463,7 @@ function createMII_Image() {
464463
tracen "Info: Launching WIT to build the image"
465464
printdots_start
466465

467-
${SOURCEPATH}/kubernetes/samples/scripts/create-weblogic-domain/model-in-image/build_image_model.sh \
468-
> ${test_home}/miibuild_image.out 2>&1
466+
${SCRIPTPATH}/util_build_mii_image.sh > ${test_home}/miibuild_image.out 2>&1
469467
local rc=$?
470468
printdots_end
471469

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash
2+
# Copyright (c) 2019, 2020, Oracle Corporation 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+
# This script uses the WebLogic Image Tool to build a Docker image with model in image
6+
# artifacts.
7+
#
8+
# Assumptions:
9+
#
10+
# WORKDIR
11+
# Working directory. Defaults to '/tmp/$USER/model-in-image-sample-work-dir'.
12+
#
13+
# MODEL_DIR:
14+
# Location of the model .zip, .properties, and .yaml files
15+
# that will be copied in to the image. Default is 'WORKDIR/models'
16+
# which is populated by the ./build_model.sh script.
17+
#
18+
# MODEL_YAML_FILES, MODEL_ARCHIVE_FILES, MODEL_VARIABLES_FILES:
19+
# Optionally, set one or more of these with comma-separated lists of file
20+
# locations to override the corresponding .yaml, .zip, and .properties
21+
# files normally obtained from MODEL_DIR.
22+
#
23+
# WDT_DOMAIN_TYPE - WLS (default), RestrictedJRF, or JRF
24+
# BASE_IMAGE_NAME - defaults to container-registry.oracle.com/middleware/weblogic for
25+
# the 'WLS' domain type, and otherwise defaults to
26+
# container-registry.oracle.com/middleware/fmw-infrastructure
27+
# BASE_IMAGE_TAG - defaults to 12.2.1.4
28+
# MODEL_IMAGE_NAME - defaults to 'model-in-image'
29+
# MODEL_IMAGE_TAG - defaults to 'v1'
30+
# MODEL_IMAGE_BUILD - 'when-missing' or 'always' (default)
31+
#
32+
33+
set -eu
34+
35+
SCRIPTDIR="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
36+
echo "@@ Info: Running '$(basename "$0")'."
37+
38+
WORKDIR=${WORKDIR:-/tmp/$USER/model-in-image-sample-work-dir}
39+
40+
echo "@@ Info: WORKDIR='$WORKDIR'."
41+
42+
mkdir -p ${WORKDIR}
43+
cd ${WORKDIR}
44+
45+
WDT_DOMAIN_TYPE=${WDT_DOMAIN_TYPE:-WLS}
46+
47+
case "$WDT_DOMAIN_TYPE" in
48+
WLS)
49+
BASE_IMAGE_NAME="${BASE_IMAGE_NAME:-container-registry.oracle.com/middleware/weblogic}" ;;
50+
JRF|RestrictedJRF)
51+
BASE_IMAGE_NAME="${BASE_IMAGE_NAME:-container-registry.oracle.com/middleware/fmw-infrastructure}" ;;
52+
*)
53+
echo "@@ Error: Invalid domain type WDT_DOMAIN_TYPE '$WDT_DOMAIN_TYPE': expected 'WLS', 'JRF', or 'RestrictedJRF'." && exit 1 ;;
54+
esac
55+
56+
BASE_IMAGE_TAG=${BASE_IMAGE_TAG:-12.2.1.4}
57+
58+
MODEL_IMAGE_NAME=${MODEL_IMAGE_NAME:-model-in-image}
59+
MODEL_IMAGE_TAG=${MODEL_IMAGE_TAG:-v1}
60+
MODEL_IMAGE_BUILD=${MODEL_IMAGE_BUILD:-always}
61+
62+
if [ ! "$MODEL_IMAGE_BUILD" = "always" ] && \
63+
[ "`docker images $MODEL_IMAGE_NAME:$MODEL_IMAGE_TAG | awk '{ print $1 ":" $2 }' | grep -c $MODEL_IMAGE_NAME:$MODEL_IMAGE_TAG`" = "1" ]; then
64+
echo @@
65+
echo "@@ Info: --------------------------------------------------------------------------------------------------"
66+
echo "@@ Info: NOTE!!! "
67+
echo "@@ Info: Skipping model image build because image '$MODEL_IMAGE_NAME:$MODEL_IMAGE_TAG' already exists. "
68+
echo "@@ Info: To always build the model image, 'export MODEL_IMAGE_BUILD=always'. "
69+
echo "@@ Info: --------------------------------------------------------------------------------------------------"
70+
echo @@
71+
sleep 3
72+
exit 0
73+
fi
74+
75+
echo @@
76+
echo @@ Info: Obtaining model files
77+
echo @@
78+
79+
MODEL_DIR=${MODEL_DIR:-$WORKDIR/models}
80+
MODEL_YAML_FILES="${MODEL_YAML_FILES:-$(ls $MODEL_DIR/*.yaml | xargs | sed 's/ /,/g')}"
81+
MODEL_ARCHIVE_FILES="${MODEL_ARCHIVE_FILES:-$(ls $MODEL_DIR/*.zip | xargs | sed 's/ /,/g')}"
82+
MODEL_VARIABLE_FILES="${MODEL_VARIABLE_FILES:-$(ls $MODEL_DIR/*.properties | xargs | sed 's/ /,/g')}"
83+
84+
echo @@ MODEL_YAML_FILES=${MODEL_YAML_FILES}
85+
echo @@ MODEL_ARCHIVE_FILES=${MODEL_ARCHIVE_FILES}
86+
echo @@ MODEL_VARIABLE_FILES=${MODEL_VARIABLE_FILES}
87+
88+
echo @@
89+
echo @@ Info: Setting up imagetool and populating its caches
90+
echo @@
91+
92+
mkdir -p cache
93+
unzip -o weblogic-image-tool.zip
94+
95+
IMGTOOL_BIN=${WORKDIR}/imagetool/bin/imagetool.sh
96+
97+
# The image tool uses the WLSIMG_CACHEDIR and WLSIMG_BLDIR env vars:
98+
export WLSIMG_CACHEDIR=${WORKDIR}/cache
99+
export WLSIMG_BLDDIR=${WORKDIR}
100+
101+
${IMGTOOL_BIN} cache deleteEntry --key wdt_myversion
102+
${IMGTOOL_BIN} cache addInstaller \
103+
--type wdt --version myversion --path ${WORKDIR}/weblogic-deploy-tooling.zip
104+
105+
echo "@@"
106+
echo "@@ Info: Starting model image build for '$MODEL_IMAGE_NAME:$MODEL_IMAGE_TAG'"
107+
echo "@@"
108+
109+
#
110+
# Run the image tool to create the image. It will use the WDT binaries
111+
# in the local image tool cache marked with key 'myversion' (see 'cache' commands above).
112+
#
113+
114+
${IMGTOOL_BIN} update \
115+
--tag $MODEL_IMAGE_NAME:$MODEL_IMAGE_TAG \
116+
--fromImage $BASE_IMAGE_NAME:$BASE_IMAGE_TAG \
117+
--wdtModel ${MODEL_YAML_FILES} \
118+
--wdtVariables ${MODEL_VARIABLE_FILES} \
119+
--wdtArchive ${MODEL_ARCHIVE_FILES} \
120+
--wdtModelOnly \
121+
--wdtVersion myversion \
122+
--wdtDomainType ${WDT_DOMAIN_TYPE}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
# Copyright (c) 2019, 2020, Oracle Corporation 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+
#
6+
# This script downloads the latest WebLogic Deploy Tool and WebLogic Image Tool
7+
# to the WORKDIR directory.
8+
#
9+
# Optional environment variables:
10+
#
11+
# WORKDIR
12+
# working directory with at least 10g of space
13+
# defaults to /tmp/$USER/model-in-image-sample-work-dir
14+
#
15+
# http_proxy https_proxy
16+
# If running behind a proxy, then set as needed to allow curl access to github.com.
17+
#
18+
# DOWNLOAD_WDT DOWNLOAD_WIT
19+
# Default to 'when-missing'. Set to 'always' to force download even
20+
# if local installer zip is missing.
21+
#
22+
# WDT_INSTALLER_URL WIT_INSTALLER_URL
23+
# Defaults to 'https://github.com/oracle/weblogic-deploy-tooling/releases/latest'
24+
# and 'https://github.com/oracle/weblogic-image-tool/releases/latest' respectively.
25+
#
26+
# To override an installer URL, export the URL env to point to a specific zip file, for example:
27+
# export WDT_INSTALLER_URL=https://github.com/oracle/weblogic-deploy-tooling/releases/download/weblogic-deploy-tooling-1.7.0/weblogic-deploy.zip
28+
#
29+
30+
set -o pipefail
31+
32+
set -eu
33+
34+
SCRIPTDIR="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
35+
echo "@@ Info: Running '$(basename "$0")'."
36+
37+
DOWNLOAD_WIT=${DOWNLOAD_WIT:-when-missing}
38+
DOWNLOAD_WDT=${DOWNLOAD_WDT:-when-missing}
39+
WDT_INSTALLER_URL=${WDT_INSTALLER_URL:-https://github.com/oracle/weblogic-deploy-tooling/releases/latest}
40+
WIT_INSTALLER_URL=${WIT_INSTALLER_URL:-https://github.com/oracle/weblogic-image-tool/releases/latest}
41+
WORKDIR=${WORKDIR:-/tmp/$USER/model-in-image-sample-work-dir}
42+
43+
echo "@@ Info: WORKDIR='$WORKDIR'."
44+
45+
mkdir -p ${WORKDIR}
46+
cd ${WORKDIR}
47+
48+
download_zip() {
49+
set -eu
50+
local ZIPFILE=$1
51+
local LOCATION=$2
52+
local DOWNLOAD_VAR_NAME=$3
53+
local DOWNLOAD=${!DOWNLOAD_VAR_NAME}
54+
55+
if [ ! "$DOWNLOAD" = "always" ] && [ -f $ZIPFILE ]; then
56+
echo "@@"
57+
echo "@@ -----------------------------------------------------------------------"
58+
echo "@@ Info: NOTE! Skipping '$LOCATION' download since local "
59+
echo "@@ file '$WORKDIR/$ZIPFILE' already exists. "
60+
echo "@@ To force a download, 'export $DOWNLOAD_VAR_NAME=always'. "
61+
echo "@@ -----------------------------------------------------------------------"
62+
echo "@@"
63+
sleep 2
64+
return
65+
fi
66+
67+
echo "@@ Downloading '$LOCATION' to '$WORKDIR/$ZIPFILE'."
68+
69+
local iurl="$LOCATION"
70+
if [ "`echo $iurl | grep -c 'https://github.com.*/latest$'`" = "1" ]; then
71+
echo "@@ The location URL matches regex 'https://github.com.*/latest$'. About to convert to direct location."
72+
local tempfile="$(mktemp -u).$(basename $0).$SECONDS.$PPID.$RANDOM"
73+
curl -fL $LOCATION -o $tempfile
74+
LOCATION=https://github.com/$(cat $tempfile | grep "releases/download" | awk '{ split($0,a,/href="/); print a[2]}' | cut -d\" -f 1)
75+
rm -f $tempfile
76+
echo "@@ The location URL matched regex 'https://github.com.*/latest$' so it was converted to '$LOCATION'"
77+
echo "@@ Now downloading '$LOCATION' to '$WORKDIR/$ZIPFILE'."
78+
fi
79+
80+
rm -f $ZIPFILE
81+
curl -fL $LOCATION -o $ZIPFILE
82+
}
83+
84+
download_zip weblogic-deploy-tooling.zip $WDT_INSTALLER_URL DOWNLOAD_WDT
85+
download_zip weblogic-image-tool.zip $WIT_INSTALLER_URL DOWNLOAD_WIT

0 commit comments

Comments
 (0)