Skip to content

Commit 8ca7075

Browse files
authored
Merge pull request #1013 from oracle/owls-72998
Include IT class name in archive file name, copy test log archives to workspace and more ..
2 parents e4c5a1d + aeec7e7 commit 8ca7075

File tree

10 files changed

+51
-16
lines changed

10 files changed

+51
-16
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/BaseTest.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,17 @@ private void callWebAppAndVerifyScaling(Domain domain, int replicas) throws Exce
628628
}
629629
}
630630

631-
public static void tearDown() throws Exception {
631+
/**
632+
* Calls statedump.sh which places k8s logs, descriptions, etc in directory
633+
* $RESULT_DIR/state-dump-logs and calls archive.sh on RESULT_DIR locally, and on PV_ROOT via a
634+
* job or pod. Also calls cleanup.sh which does a best-effort delete of acceptance test k8s
635+
* artifacts, the local test tmp directory, and the potentially remote domain pv directories.
636+
*
637+
* @param iTClassName - IT class name to be used in the archive file name
638+
* @throws Exception when errors while running statedump.sh or cleanup.sh scripts or while
639+
* renewing the lease for wercker run
640+
*/
641+
public static void tearDown(String iTClassName) throws Exception {
632642
logger.log(
633643
Level.INFO,
634644
"TEARDOWN: Starting Test Run TearDown (cleanup and state-dump)."
@@ -637,8 +647,14 @@ public static void tearDown() throws Exception {
637647
+ "after the tearDown completes. Note that tearDown itself may report errors,"
638648
+ " but this won't affect the outcome of the test results.");
639649
StringBuffer cmd =
640-
new StringBuffer("export RESULT_ROOT=$RESULT_ROOT && export PV_ROOT=$PV_ROOT && ");
641-
cmd.append(BaseTest.getProjectRoot())
650+
new StringBuffer(
651+
"export RESULT_ROOT=$RESULT_ROOT && export PV_ROOT=$PV_ROOT && export IT_CLASS=");
652+
cmd.append(iTClassName);
653+
if (JENKINS) {
654+
cmd.append(" && export JENKINS_RESULTS_DIR=${WORKSPACE}/logdir/${BUILD_TAG} ");
655+
}
656+
cmd.append(" && ")
657+
.append(BaseTest.getProjectRoot())
642658
.append("/integration-tests/src/test/resources/statedump.sh");
643659
logger.info("Running " + cmd);
644660

integration-tests/src/test/java/oracle/kubernetes/operator/ITOperator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static void staticUnPrepare() throws Exception {
5454
logger.info("BEGIN");
5555
logger.info("Run once, release cluster lease");
5656

57-
tearDown();
57+
tearDown(new Object() {}.getClass().getEnclosingClass().getSimpleName());
5858

5959
logger.info("SUCCESS");
6060
}

integration-tests/src/test/java/oracle/kubernetes/operator/ITPodsRestart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static void staticUnPrepare() throws Exception {
6767
logger.info("Run once, release cluster lease");
6868

6969
destroyPodsRestartdomain();
70-
tearDown();
70+
tearDown(new Object() {}.getClass().getEnclosingClass().getSimpleName());
7171

7272
logger.info("SUCCESS");
7373
}

integration-tests/src/test/java/oracle/kubernetes/operator/ITServerDiscovery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public static void staticUnPrepare() throws Exception {
130130
logger.info("BEGIN");
131131
logger.info("Run once, release cluster lease");
132132

133-
tearDown();
133+
tearDown(new Object() {}.getClass().getEnclosingClass().getSimpleName());
134134

135135
logger.info("SUCCESS");
136136
}

integration-tests/src/test/java/oracle/kubernetes/operator/ITSessionMigration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static void staticUnPrepare() throws Exception {
9797
logger.info("BEGIN");
9898
logger.info("Run once, release cluster lease");
9999

100-
tearDown();
100+
tearDown(new Object() {}.getClass().getEnclosingClass().getSimpleName());
101101

102102
logger.info("SUCCESS");
103103
}

integration-tests/src/test/java/oracle/kubernetes/operator/ITSitConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static void staticUnPrepare() throws Exception {
107107
if (!QUICKTEST) {
108108
ExecResult result = TestUtils.exec("kubectl delete -f " + mysqlYamlFile);
109109
destroySitConfigDomain();
110-
tearDown();
110+
tearDown(new Object() {}.getClass().getEnclosingClass().getSimpleName());
111111
}
112112
}
113113

integration-tests/src/test/java/oracle/kubernetes/operator/ITUsabilityOperatorHelmChart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static void staticUnPrepare() throws Exception {
5959
logger.info("BEGIN");
6060
logger.info("Run once, release cluster lease");
6161

62-
tearDown();
62+
tearDown(new Object() {}.getClass().getEnclosingClass().getSimpleName());
6363

6464
logger.info("SUCCESS");
6565
}

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function state_dump {
1717
local SCRIPTPATH="$PROJECT_ROOT/src/integration-tests/bash"
1818
local LEASE_ID="$LEASE_ID"
1919
local ARCHIVE_DIR="$RESULT_ROOT/acceptance_test_pv_archive"
20-
local ARCHIVE_FILE="IntSuite.`date '+%Y%m%d%H%M%S'`.jar"
20+
local ARCHIVE_FILE="IntSuite.${IT_CLASS}.PV.`date '+%Y%m%d%H%M%S'`.jar"
2121
local ARCHIVE="$ARCHIVE_DIR/$ARCHIVE_FILE"
2222

2323
if [ ! -d "$RESULT_DIR" ]; then
@@ -104,16 +104,26 @@ function state_dump {
104104
fi
105105
else
106106

107-
$SCRIPTPATH/krun.sh -t 300 -d ${RESULT_DIR} -m "${PV_ROOT}:/sharedparent" -c 'jar cf /sharedparent/pvarchive.jar /sharedparent/acceptance_test_pv' 2>&1 | tee ${outfile}
107+
$SCRIPTPATH/krun.sh -i openjdk:11-oracle -t 300 -d ${RESULT_DIR} -m "${PV_ROOT}:/sharedparent" -c 'jar cf /sharedparent/pvarchive.jar /sharedparent/acceptance_test_pv' 2>&1 | tee ${outfile}
108108
if [ "$?" = "0" ]; then
109-
$SCRIPTPATH/krun.sh -t 300 -d ${RESULT_DIR} -m "${PV_ROOT}:/sharedparent" -c 'base64 /sharedparent/pvarchive.jar' > $RESULT_DIR/pvarchive.b64 2>&1
109+
$SCRIPTPATH/krun.sh -i openjdk:11-oracle -t 300 -d ${RESULT_DIR} -m "${PV_ROOT}:/sharedparent" -c 'base64 /sharedparent/pvarchive.jar' > $RESULT_DIR/pvarchive.b64 2>&1
110110
if [ "$?" = "0" ]; then
111111
base64 -di $RESULT_DIR/pvarchive.b64 > $ARCHIVE
112112
if [ "$?" = "0" ]; then
113113
echo Run complete. Archived to $ARCHIVE
114114
else
115115
echo Run failed.
116116
fi
117+
if [ "$JENKINS" = "true" ]; then
118+
# Jenkins can only publish logs under the workspace
119+
mkdir -p ${JENKINS_RESULTS_DIR}
120+
cp $ARCHIVE ${JENKINS_RESULTS_DIR}
121+
if [ "$?" = "0" ]; then
122+
echo Copy complete. Archive $ARCHIVE copied to ${JENKINS_RESULTS_DIR}
123+
else
124+
echo Failed to copy archive $ARCHIVE to ${JENKINS_RESULTS_DIR}
125+
fi
126+
fi
117127
else
118128
# command failed
119129
cat $RESULT_DIR/pvarchive.b64 | head -100
@@ -145,7 +155,11 @@ function state_dump {
145155
rm -rf ${RESULT_DIR}/samples
146156

147157
# now archive all the local test files
148-
$SCRIPTPATH/archive.sh "${RESULT_DIR}" "${RESULT_DIR}_archive"
158+
if [ "$JENKINS" = "true" ]; then
159+
$SCRIPTPATH/archive.sh "${RESULT_DIR}" "${JENKINS_RESULTS_DIR}"
160+
else
161+
$SCRIPTPATH/archive.sh "${RESULT_DIR}" "${RESULT_DIR}_archive"
162+
fi
149163

150164
echo Done with state dump
151165
}

src/integration-tests/bash/archive.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function fail {
2424
function archive {
2525
local SOURCE_DIR="${1?}"
2626
local ARCHIVE_DIR="${2?}"
27-
local ARCHIVE_FILE="IntSuite.`date '+%Y%m%d%H%M%S'`.jar"
27+
local ARCHIVE_FILE="IntSuite.${IT_CLASS}.TMP.`date '+%Y%m%d%H%M%S'`.jar"
2828
local ARCHIVE="$ARCHIVE_DIR/$ARCHIVE_FILE"
2929
local OUTFILE="/tmp/$ARCHIVE_FILE"
3030

@@ -38,7 +38,12 @@ function archive {
3838
[ $? -eq 0 ] || fail "Could not archive, 'jar cf $ARCHIVE $SOURCE_DIR' command failed: `cat $OUTFILE`"
3939
rm -f $OUTFILE
4040

41-
find $ARCHIVE_DIR -maxdepth 1 -name "IntSuite*jar" | sort -r | awk '{ if (NR>10) print $NF }' | xargs rm -f
41+
# Jenkins log cleanup is managed on Jenkins job config
42+
if [ ! "$JENKINS" = "true" ]; then
43+
find $ARCHIVE_DIR -maxdepth 1 -name "IntSuite.${IT_CLASS}.PV.*jar" | sort -r | awk '{ if (NR>5) print $NF }' | xargs rm -f
44+
find $ARCHIVE_DIR -maxdepth 1 -name "IntSuite.${IT_CLASS}.TMP.*jar" | sort -r | awk '{ if (NR>5) print $NF }' | xargs rm -f
45+
fi
46+
4247

4348
trace Archived to \'$ARCHIVE\'.
4449
}

src/integration-tests/bash/cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ if [ "${DELETE_FILES:-true}" = "true" ]; then
354354
if [ "$WERCKER" = "true" ]; then
355355
$SCRIPTPATH/job.sh "rm -fr /scratch/acceptance_test_pv"
356356
else
357-
$SCRIPTPATH/krun.sh -m "${PV_ROOT}:/sharedparent" -c 'rm -fr /sharedparent/acceptance_test_pv'
357+
$SCRIPTPATH/krun.sh -i openjdk:11-oracle -m "${PV_ROOT}:/sharedparent" -c 'rm -fr /sharedparent/acceptance_test_pv'
358358
fi
359359
[ "$?" = "0" ] || SUCCESS="1"
360360
echo @@ SUCCESS=$SUCCESS

0 commit comments

Comments
 (0)