From 16be6c6df82b06c97250e5a1b28833826f293eba Mon Sep 17 00:00:00 2001 From: Gratian Crisan Date: Thu, 14 Dec 2023 09:26:40 -0600 Subject: [PATCH] kernel-containerized-performance-tests: pull container build logic into central script Pull out common container build logic from each containerized performance test file into a single file and run it in run-ptest. Signed-off-by: Gratian Crisan --- .../kernel-tests/files/build-containers | 23 ++++++++++++++++ .../run-ptest | 3 ++- ...est_kernel_cyclictest_fio_containerized.sh | 26 ++----------------- ...rnel_cyclictest_hackbench_containerized.sh | 26 ++----------------- ...st_kernel_cyclictest_idle_containerized.sh | 14 +--------- ...t_kernel_cyclictest_iperf_containerized.sh | 26 ++----------------- .../kernel-containerized-performance-tests.bb | 2 ++ 7 files changed, 34 insertions(+), 86 deletions(-) create mode 100644 recipes-kernel/kernel-tests/files/build-containers diff --git a/recipes-kernel/kernel-tests/files/build-containers b/recipes-kernel/kernel-tests/files/build-containers new file mode 100644 index 00000000..88c7285a --- /dev/null +++ b/recipes-kernel/kernel-tests/files/build-containers @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ "$(docker images -q cyclictest-container:latest)" = "" ]; then + echo "Building cyclictest-container..." + DOCKER_BUILDKIT=1 \ + docker build -t cyclictest-container --network=host ./cyclictest-container + if [ "$(docker images -q cyclictest-container:latest)" = "" ]; then + echo "Failed to build cyclictest-container" + exit 77 + fi +fi + +if [ "$(docker images -q parallel-container:latest)" = "" ]; then + echo "Building parallel-container..." + DOCKER_BUILDKIT=1 \ + docker build -t parallel-container --network=host ./parallel-container + if [ "$(docker images -q parallel-container:latest)" = "" ]; then + echo "Failed to build parallel-container" + exit 77 + fi +fi + +exit 0 diff --git a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/run-ptest b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/run-ptest index 46c4c8eb..eb813f20 100644 --- a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/run-ptest +++ b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/run-ptest @@ -1,9 +1,10 @@ #!/bin/bash +./build-containers || exit $? + ./test_kernel_cyclictest_idle_containerized.sh ./test_kernel_cyclictest_hackbench_containerized.sh ./test_kernel_cyclictest_fio_containerized.sh ./test_kernel_cyclictest_iperf_containerized.sh exit 0 - diff --git a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_fio_containerized.sh b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_fio_containerized.sh index 1cd101e3..55f3a0ec 100644 --- a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_fio_containerized.sh +++ b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_fio_containerized.sh @@ -1,36 +1,14 @@ #!/bin/bash -PTEST_LOCATION=/usr/lib/kernel-containerized-performance-tests/ptest - -# Build the two containers -if [ "$(docker images -q cyclictest-container:latest)" = "" ]; then - echo "Building cyclictest-container..." - DOCKER_BUILDKIT=1 \ - docker build -t cyclictest-container --network=host ${PTEST_LOCATION}/cyclictest-container - if [ "$(docker images -q cyclictest-container:latest)" = "" ]; then - echo "Failed to build cyclictest-container" - exit 77 - fi -fi -if [ "$(docker images -q parallel-container:latest)" = "" ]; then - echo "Building parallel-container..." - DOCKER_BUILDKIT=1 \ - docker build -t parallel-container --network=host ${PTEST_LOCATION}/parallel-container - if [ "$(docker images -q parallel-container:latest)" = "" ]; then - echo "Failed to build parallel-container" - exit 77 - fi -fi - # Start background disk I/O load echo "Starting fio load..." -LOAD_CONT=$(docker run -d --privileged -v ${PTEST_LOCATION}:/ptests -t parallel-container \ +LOAD_CONT=$(docker run -d --privileged -v ${PWD}:/ptests -t parallel-container \ bash run_fio.sh) # Run cyclictest echo "Running cyclictest in docker container..." RESULT=$(docker run --privileged --network=host \ - -v ${LOG_DIR}:${LOG_DIR} -v ${PTEST_LOCATION}:/ptests -v /home/admin:/home/admin \ + -v ${LOG_DIR}:${LOG_DIR} -v ${PWD}:/ptests -v /home/admin:/home/admin \ -v /usr/share/fw_printenv:/usr/share/fw_printenv -v /sbin/fw_printenv:/sbin/fw_printenv \ -v /usr/share/nisysinfo:/usr/share/nisysinfo -v /dev:/dev \ -t cyclictest-container \ diff --git a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_hackbench_containerized.sh b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_hackbench_containerized.sh index 25e3ccc2..1a8d802d 100644 --- a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_hackbench_containerized.sh +++ b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_hackbench_containerized.sh @@ -1,36 +1,14 @@ #!/bin/bash -PTEST_LOCATION=/usr/lib/kernel-containerized-performance-tests/ptest - -# Build the two containers -if [ "$(docker images -q cyclictest-container:latest)" = "" ]; then - echo "Building cyclictest-container..." - DOCKER_BUILDKIT=1 \ - docker build -t cyclictest-container --network=host ${PTEST_LOCATION}/cyclictest-container - if [ "$(docker images -q cyclictest-container:latest)" = "" ]; then - echo "Failed to build cyclictest-container" - exit 77 - fi -fi -if [ "$(docker images -q parallel-container:latest)" = "" ]; then - echo "Building parallel-container..." - DOCKER_BUILDKIT=1 \ - docker build -t parallel-container --network=host ${PTEST_LOCATION}/parallel-container - if [ "$(docker images -q parallel-container:latest)" = "" ]; then - echo "Failed to build parallel-container" - exit 77 - fi -fi - # Start background scheduler load echo "Starting hackbench load..." -LOAD_CONT=$(docker run -d --privileged -v ${PTEST_LOCATION}:/ptests -t parallel-container \ +LOAD_CONT=$(docker run -d --privileged -v ${PWD}:/ptests -t parallel-container \ bash run_hackbench.sh) # Run cyclictest echo "Running cyclictest in docker container..." RESULT=$(docker run --privileged --network=host \ - -v ${LOG_DIR}:${LOG_DIR} -v ${PTEST_LOCATION}:/ptests -v /home/admin:/home/admin \ + -v ${LOG_DIR}:${LOG_DIR} -v ${PWD}:/ptests -v /home/admin:/home/admin \ -v /usr/share/fw_printenv:/usr/share/fw_printenv -v /sbin/fw_printenv:/sbin/fw_printenv \ -v /usr/share/nisysinfo:/usr/share/nisysinfo -v /dev:/dev \ -t cyclictest-container \ diff --git a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_idle_containerized.sh b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_idle_containerized.sh index 9cf74f40..33d63648 100644 --- a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_idle_containerized.sh +++ b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_idle_containerized.sh @@ -1,23 +1,11 @@ #!/bin/bash -PTEST_LOCATION=/usr/lib/kernel-containerized-performance-tests/ptest LOG_DIR="/var/local/ptest-results/kernel-containerized-performance-tests" -# Build the two containers -if [ "$(docker images -q cyclictest-container:latest)" = "" ]; then - echo "Building cyclictest-container..." - DOCKER_BUILDKIT=1 \ - docker build -t cyclictest-container --network=host ${PTEST_LOCATION}/cyclictest-container - if [ "$(docker images -q cyclictest-container:latest)" = "" ]; then - echo "Failed to build cyclictest-container" - exit 77 - fi -fi - # Run cyclictest echo "Running cyclictest in docker container..." RESULT=$(docker run --privileged --network=host \ - -v ${LOG_DIR}:${LOG_DIR} -v ${PTEST_LOCATION}:/ptests -v /home/admin:/home/admin \ + -v ${LOG_DIR}:${LOG_DIR} -v ${PWD}:/ptests -v /home/admin:/home/admin \ -v /usr/share/fw_printenv:/usr/share/fw_printenv -v /sbin/fw_printenv:/sbin/fw_printenv \ -v /usr/share/nisysinfo:/usr/share/nisysinfo -v /dev:/dev \ -t cyclictest-container \ diff --git a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_iperf_containerized.sh b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_iperf_containerized.sh index 18f8c6f9..c20d9fd9 100644 --- a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_iperf_containerized.sh +++ b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests-files/test_kernel_cyclictest_iperf_containerized.sh @@ -1,7 +1,5 @@ #!/bin/bash -PTEST_LOCATION=/usr/lib/kernel-containerized-performance-tests/ptest - source /home/admin/.iperf.info if [ -z "$IPERF_SERVER" ]; then echo "Warning: iperf server not configured; skipping iperf based network load test." @@ -18,36 +16,16 @@ if [ ! -z "$IPERF_PORT" ]; then fi fi -# Build the two containers -if [ "$(docker images -q cyclictest-container:latest)" = "" ]; then - echo "Building cyclictest-container..." - DOCKER_BUILDKIT=1 \ - docker build -t cyclictest-container --network=host ${PTEST_LOCATION}/cyclictest-container - if [ "$(docker images -q cyclictest-container:latest)" = "" ]; then - echo "Failed to build cyclictest-container" - exit 77 - fi -fi -if [ "$(docker images -q parallel-container:latest)" = "" ]; then - echo "Building parallel-container..." - DOCKER_BUILDKIT=1 \ - docker build -t parallel-container --network=host ${PTEST_LOCATION}/parallel-container - if [ "$(docker images -q parallel-container:latest)" = "" ]; then - echo "Failed to build parallel-container" - exit 77 - fi -fi - # Start background network load echo "Starting iperf load..." LOAD_CONT=$(docker run -d --privileged \ - -v ${PTEST_LOCATION}:/ptests -v /home/admin:/home/admin --network=host \ + -v ${PWD}:/ptests -v /home/admin:/home/admin --network=host \ -t parallel-container bash run_iperf.sh) # Run cyclictest echo "Running cyclictest in docker container..." RESULT=$(docker run --privileged --network=host \ - -v ${LOG_DIR}:${LOG_DIR} -v ${PTEST_LOCATION}:/ptests -v /home/admin:/home/admin \ + -v ${LOG_DIR}:${LOG_DIR} -v ${PWD}:/ptests -v /home/admin:/home/admin \ -v /usr/share/fw_printenv:/usr/share/fw_printenv -v /sbin/fw_printenv:/sbin/fw_printenv \ -v /usr/share/nisysinfo:/usr/share/nisysinfo -v /dev:/dev \ -t cyclictest-container \ diff --git a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests.bb b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests.bb index 58828e18..049630e8 100644 --- a/recipes-kernel/kernel-tests/kernel-containerized-performance-tests.bb +++ b/recipes-kernel/kernel-tests/kernel-containerized-performance-tests.bb @@ -18,6 +18,7 @@ RDEPENDS:${PN}-ptest:append:armv7a = " u-boot-fw-utils" ALLOW_EMPTY:${PN} = "1" SRC_URI += "\ + file://build-containers \ file://run-ptest \ file://run-cyclictest \ file://upload_cyclictest_results.py \ @@ -36,6 +37,7 @@ SRC_URI += "\ " do_install_ptest:append() { + install -m 0755 ${S}/build-containers ${D}${PTEST_PATH} install -m 0755 ${S}/run-ptest ${D}${PTEST_PATH} install -m 0755 ${S}/run-cyclictest ${D}${PTEST_PATH} install -m 0755 ${S}/upload_cyclictest_results.py ${D}${PTEST_PATH}