diff --git a/.github/workflows/ci-on-push.yaml b/.github/workflows/ci-on-push.yaml index 819a9b33c8..eed6d21917 100644 --- a/.github/workflows/ci-on-push.yaml +++ b/.github/workflows/ci-on-push.yaml @@ -55,4 +55,6 @@ jobs: run-metrics-tests: needs: build-kata-static-tarball-amd64 - uses: ./.github/workflows/run-launchtimes-metrics.yaml + uses: ./.github/workflows/run-metrics.yaml + with: + tarball-suffix: -${{ github.event.pull_request.number}}-${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/run-launchtimes-metrics.yaml b/.github/workflows/run-launchtimes-metrics.yaml deleted file mode 100644 index bfbb9f2eb5..0000000000 --- a/.github/workflows/run-launchtimes-metrics.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: CI | Run launch-times metrics -on: - workflow_call: - -jobs: - launch-times-tests: - runs-on: metrics - env: - GOPATH: ${{ github.workspace }} - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - name: run launch times on qemu - run: bash tests/metrics/gha-run.sh run-test-launchtimes-qemu - - - name: run launch times on clh - run: bash tests/metrics/gha-run.sh run-test-launchtimes-clh diff --git a/.github/workflows/run-metrics.yaml b/.github/workflows/run-metrics.yaml new file mode 100644 index 0000000000..fa9153dea2 --- /dev/null +++ b/.github/workflows/run-metrics.yaml @@ -0,0 +1,33 @@ +name: CI | Run test metrics +on: + workflow_call: + inputs: + tarball-suffix: + required: false + type: string + +jobs: + run-metrics: + runs-on: metrics + env: + GOPATH: ${{ github.workspace }} + ARTIFACTS_DIR: kata-artifacts + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: get-kata-tarball + uses: actions/download-artifact@v3 + with: + name: kata-static-tarball-amd64${{ inputs.tarball-suffix }} + path: ${{ ARTIFACTS_DIR }} + + - name: Install kata + run: bash tests/metrics/gha-run.sh install-kata ${{ ARTIFACTS_DIR }} + + - name: run launch times on qemu + run: bash tests/metrics/gha-run.sh run-test-launchtimes-qemu + + - name: run launch times on clh + run: bash tests/metrics/gha-run.sh run-test-launchtimes-clh diff --git a/tests/metrics/gha-run.sh b/tests/metrics/gha-run.sh index e3656b2cde..cf0b95d49a 100755 --- a/tests/metrics/gha-run.sh +++ b/tests/metrics/gha-run.sh @@ -9,27 +9,58 @@ set -o errexit set -o nounset set -o pipefail +kata_tarball_dir=${2:-kata-artifacts} metrics_dir="$(dirname "$(readlink -f "$0")")" +create_symbolic_links() { + hypervisor="${1:-qemu}" + local link_configuration_file="/opt/kata/share/defaults/kata-containers/configuration.toml" + local source_configuration_file="/opt/kata/share/defaults/kata-containers/configuration-${hypervisor}.toml" + + if [ ${hypervisor} != 'qemu' ] && [ ${hypervisor} != 'clh' ]; then + exit 2 + fi + + sudo ln -sf "${source_configuration_file}" "${link_configuration_file}" +} + +install_kata() { + local katadir="/opt/kata" + local destdir="/" + + # Removing previous kata installation + sudo rm -rf "${katadir}" + + pushd ${kata_tarball_dir} + for c in kata-static-*.tar.xz; do + echo "untarring tarball "${c}" into ${destdir}" + sudo tar -xvf "${c}" -C "${destdir}" + done + popd +} + function run_test_launchtimes() { - hypervisor="${1}" + hypervisor="${1}" - echo "Running launchtimes tests: " + echo "Running launchtimes tests: " - if [ "${hypervisor}" = 'qemu' ]; then - echo "qemu" - elif [ "${hypervisor}" = 'clh' ]; then - echo "clh" - fi + create_symbolic_links "${hypervisor}" + + if [ "${hypervisor}" = 'qemu' ]; then + echo "qemu" + elif [ "${hypervisor}" = 'clh' ]; then + echo "clh" + fi } function main() { - action="${1:-}" - case "${action}" in - run-test-launchtimes-qemu) run_test_launchtimes "qemu" ;; - run-test-launchtimes-clh) run_test_launchtimes "clh" ;; - *) >&2 echo "Invalid argument"; exit 2 ;; - esac + action="${1:-}" + case "${action}" in + install-kata) install_kata ;; + run-test-launchtimes-qemu) run_test_launchtimes "qemu" ;; + run-test-launchtimes-clh) run_test_launchtimes "clh" ;; + *) >&2 echo "Invalid argument"; exit 2 ;; + esac } main "$@"