Skip to content

Commit

Permalink
Add CRIU PingPerf test (#4312)
Browse files Browse the repository at this point in the history
Signed-off-by: Lan Xia <Lan_Xia@ca.ibm.com>
  • Loading branch information
llxia committed Feb 7, 2023
1 parent fbe94bc commit f49810a
Show file tree
Hide file tree
Showing 4 changed files with 273 additions and 1 deletion.
13 changes: 12 additions & 1 deletion buildenv/jenkins/JenkinsfileBase
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,17 @@ def buildTest() {
echo 'Cannot run copyArtifacts from systemtest.getDependency. Skipping copyArtifacts...'
}

if (BUILD_LIST.contains("external")){
try {
timeout(time: 2, unit: 'HOURS') {
copyArtifacts fingerprintArtifacts: true, projectName: "UploadFileOnJenkins", selector: specific("2"), target: 'aqa-tests/external/criu/'
}
} catch (Exception e) {
echo 'Exception: ' + e.toString()
echo 'Cannot run copyArtifacts from UploadFileOnJenkins. Skipping copyArtifacts...'
}
}

if (fileExists('openjdkbinary/openjdk-test-image')) {
env.TESTIMAGE_PATH = "$WORKSPACE/openjdkbinary/openjdk-test-image"
}
Expand Down Expand Up @@ -643,7 +654,7 @@ def runTest( ) {
}
for (int i = 1; i <= ITERATIONS; i++) {
echo "ITERATION: ${i}/${ITERATIONS}"
if (env.SPEC.contains('linux') && !(LABEL.contains('ci.agent.dynamic') && CLOUD_PROVIDER == 'azure')) {
if (env.SPEC.contains('linux') && !(LABEL.contains('ci.agent.dynamic') && CLOUD_PROVIDER == 'azure') && (BUILD_LIST != "external")) {
// Add an additional 10 second timeout due to issue: https://github.com/adoptium/temurin-build/issues/2368#issuecomment-756683888
wrap([$class: 'Xvfb', autoDisplayName: true, timeout:10]) {
def DISPLAY = sh (
Expand Down
27 changes: 27 additions & 0 deletions external/criu/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<project name="criu-portable-checkpoint" default="build" basedir=".">
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<description>
CRIU PingPerf
</description>
<import file="${TEST_ROOT}/external/build.xml"/>

<!-- set properties for this build -->
<property name="TEST" value="criu" />
<property name="DEST" value="${BUILD_ROOT}/external/${TEST}" />
<property name="src" location="." />

<target name="init">
<mkdir dir="${DEST}"/>
</target>

<target name="dist" description="generate the distribution">
<copy todir="${DEST}">
<fileset dir="${src}" includes="*.xml, *.mk, *.sh"/>
</copy>
</target>

<target name="build">
<antcall target="dist" inheritall="true" />
</target>
</project>
165 changes: 165 additions & 0 deletions external/criu/pingPerf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#!/usr/bin/env bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

pingPerfZipPath=""

prepare() {
echo "prepare at $(pwd)..."
if [ -f "$pingPerfZipPath" ]; then
rm -f PingperfFiles.zip
cp "$pingPerfZipPath" .
unzip PingperfFiles.zip
else
echo "${pingPerfZipPath} does not exist."
exit 1
fi

curl -OLJSks https://github.com/eclipse-openj9/openj9/files/8774222/criuseccompprofile.json.txt
mv criuseccompprofile.json.txt criuseccompprofile.json
git clone https://github.com/OpenLiberty/ci.docker.git
(
cd ci.docker || exit
git checkout instanton
)
}

buildImage() {
echo "build image at $(pwd)..."
sudo podman build -t icr.io/appcafe/open-liberty:beta-instanton -f ci.docker/releases/latest/beta-instanton/Dockerfile.ubi.openjdk17 ci.docker/releases/latest/beta-instanton
sudo podman build -t ol-instanton-test-pingperf:latest -f Dockerfile.pingperf .
}

createRestoreImage() {
echo "create restore image ..."
sudo podman run --name ol-instanton-test-checkpoint-container --privileged --env WLP_CHECKPOINT=applications ol-instanton-test-pingperf:latest
sudo podman commit ol-instanton-test-checkpoint-container ol-instanton-test-pingperf-restore
sudo podman rm ol-instanton-test-checkpoint-container
}

unprivilegedRestore() {
echo "unprivileged restore ..."
echo -ne "CONTAINER_ID=" > containerId.log
sudo podman run \
--rm \
--detach \
-p 9080:9080 \
--cap-add=CHECKPOINT_RESTORE \
--cap-add=NET_ADMIN \
--cap-add=SYS_PTRACE \
--security-opt seccomp=criuseccompprofile.json \
ol-instanton-test-pingperf-restore >> containerId.log
}

privilegedRestore() {
echo "privileged restore ..."
echo -ne "CONTAINER_ID=" > containerId.log
sudo podman run \
--rm \
--detach \
--privileged \
-p 9080:9080 \
ol-instanton-test-pingperf-restore >> containerId.log
}

response() {
echo "response ..."
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://127.0.0.1:9080/pingperf/ping/greeting)" != "200" ]]; do sleep .00001; done'
}

checkLog() {
echo "check log ..."
if [ -f ./containerId.log ]; then
cat ./containerId.log
else
echo "./containerId.log does not exist."
exit 1
fi
sleep 1
source ./containerId.log
echo "podman logs --tail 10 ${CONTAINER_ID}"
sudo podman logs --tail 10 "${CONTAINER_ID}"
echo "find response ..."
sudo podman logs --tail 10 "${CONTAINER_ID}" | grep "FR "
}

clean() {
echo "clean ..."
sudo podman stop --all
sudo podman container rm --all -f
}

testCreateRestoreImageOnly() {
clean
prepare
buildImage
createRestoreImage
}

testUnprivilegedRestoreOnly() {
unprivilegedRestore
response
checkLog
}

testPrivilegedRestoreOnly() {
privilegedRestore
response
checkLog
}

testCreateImageAndUnprivilegedRestore() {
testCreateRestoreImageOnly
testUnprivilegedRestoreOnly
}

testCreateImageAndPrivilegedRestore() {
testCreateRestoreImageOnly
testPrivilegedRestoreOnly
}

if [ "$1" == "prepare" ]; then
pingPerfZipPath=$2
prepare
elif [ "$1" == "buildImage" ]; then
buildImage
elif [ "$1" == "createRestoreImage" ]; then
createRestoreImage
elif [ "$1" == "unprivilegedRestore" ]; then
unprivilegedRestore
elif [ "$1" == "privilegedRestore" ]; then
privilegedRestore
elif [ "$1" == "response" ]; then
response
elif [ "$1" == "checkLog" ]; then
checkLog
elif [ "$1" == "clean" ]; then
clean
elif [ "$1" == "testCreateRestoreImageOnly" ]; then
pingPerfZipPath=$2
testCreateRestoreImageOnly
elif [ "$1" == "testUnprivilegedRestoreOnly" ]; then
testUnprivilegedRestoreOnly
elif [ "$1" == "testPrivilegedRestoreOnly" ]; then
testPrivilegedRestoreOnly
elif [ "$1" == "testCreateImageAndUnprivilegedRestore" ]; then
pingPerfZipPath=$2
testCreateImageAndUnprivilegedRestore
elif [ "$1" == "testCreateImageAndPrivilegedRestore" ]; then
pingPerfZipPath=$2
testCreateImageAndPrivilegedRestore
else
echo "unknown command"
fi
69 changes: 69 additions & 0 deletions external/criu/playlist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-->
<playlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../TKG/playlist.xsd">
<test>
<testCaseName>criu_pingPerf_testCreateImageAndUnprivilegedRestore</testCaseName>
<command>$(TEST_ROOT)/external/criu/pingPerf.sh testCreateImageAndUnprivilegedRestore $(TEST_ROOT)/external/criu/upload/PingperfFiles.zip; \
$(TEST_STATUS); \
$(TEST_ROOT)/external/criu/pingPerf.sh clean
</command>
<features>
<feature>CRIU:required</feature>
</features>
<levels>
<level>dev</level>
</levels>
<groups>
<group>external</group>
</groups>
</test>
<test>
<testCaseName>criu_pingPerf_testCreateImageAndPrivilegedRestore</testCaseName>
<command>$(TEST_ROOT)/external/criu/pingPerf.sh testCreateImageAndPrivilegedRestore $(TEST_ROOT)/external/criu/upload/PingperfFiles.zip; \
$(TEST_STATUS); \
$(TEST_ROOT)/external/criu/pingPerf.sh clean
</command>
<features>
<feature>CRIU:required</feature>
</features>
<levels>
<level>dev</level>
</levels>
<groups>
<group>external</group>
</groups>
</test>
<test>
<testCaseName>criu_pingPerf_testCreateRestoreImageOnly</testCaseName>
<disables>
<disable>
<comment>runtimes_backlog_issues_879</comment>
</disable>
</disables>
<command>$(TEST_ROOT)/external/criu/pingPerf.sh testCreateRestoreImageOnly $(TEST_ROOT)/external/criu/upload/PingperfFiles.zip; \
$(TEST_STATUS); \
$(TEST_ROOT)/external/criu/pingPerf.sh clean
</command>
<features>
<feature>CRIU:required</feature>
</features>
<levels>
<level>dev</level>
</levels>
<groups>
<group>external</group>
</groups>
</test>
</playlist>

0 comments on commit f49810a

Please sign in to comment.