From 63849b606fe400fae648b21b25f668e3620e4e1c Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Tue, 26 Nov 2019 13:21:35 +0000 Subject: [PATCH] test: Add GCP Run Test This commit adds the GCP test that formerly ran in LinuxKitCI to run under rtf. As GitHub Actions doesn't currently support adding secret files, I've skipped this test for now. Credentials can be passed via environment variable but as RTF runs with `-x` the contents is viewable in the logs. I will create an issue to follow up and find either a way of writing the variable to file that doesn't compromise it. Or perhaps another approach that is more compatible with GH actions Signed-off-by: Dave Tucker --- .../010_platforms/110_gcp/000_run/test.sh | 40 +++++++++++++++++++ .../010_platforms/110_gcp/000_run/test.yml | 13 ++++++ 2 files changed, 53 insertions(+) create mode 100644 test/cases/010_platforms/110_gcp/000_run/test.sh create mode 100644 test/cases/010_platforms/110_gcp/000_run/test.yml diff --git a/test/cases/010_platforms/110_gcp/000_run/test.sh b/test/cases/010_platforms/110_gcp/000_run/test.sh new file mode 100644 index 000000000..8a16bbcc4 --- /dev/null +++ b/test/cases/010_platforms/110_gcp/000_run/test.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# SUMMARY: Check that gcp image boots in gcp +# LABELS: skip + +set -e + +# Source libraries. Uncomment if needed/defined +#. "${RT_LIB}" +. "${RT_PROJECT_ROOT}/_lib/lib.sh" + +NAME=gcp-$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1) +export CLOUDSDK_CORE_PROJECT="moby-datakit-ci" +export CLOUDSDK_COMPUTE_ZONE="europe-west1-d" +export CLOUDSDK_IMAGE_BUCKET="linuxkit-gcp-test-bucket" + +clean_up() { + rm -rf ${NAME}* + docker run -i --rm \ + -e CLOUDSDK_CORE_PROJECT \ + -v `pwd`/certs:/certs \ + google/cloud-sdk \ + sh -c "gcloud auth activate-service-account --key-file /certs/svc_account.json; \ + gsutil rm gs://${CLOUDSDK_IMAGE_BUCKET}/${NAME}.img.tar.gz" || true + rm -rf certs +} +trap clean_up EXIT + +[ -n "$GCLOUD_CREDENTIALS" ] || exit 1 +mkdir -p certs +printf '%s' "$GCLOUD_CREDENTIALS" > certs/svc_account.json + +linuxkit build -format gcp -name "${NAME}" test.yml +[ -f "${NAME}.img.tar.gz" ] || exit 1 +linuxkit push gcp -keys certs/svc_account.json -bucket linuxkit-gcp-test-bucket ${NAME}.img.tar.gz +# tee output of lk run to file as grep hides failures and doesn't +# always allow the vm to be cleaned up +linuxkit run gcp -keys certs/svc_account.json ${NAME} | tee ${NAME}.log +grep -q "Welcome to LinuxKit" ${NAME}.log + +exit 0 \ No newline at end of file diff --git a/test/cases/010_platforms/110_gcp/000_run/test.yml b/test/cases/010_platforms/110_gcp/000_run/test.yml new file mode 100644 index 000000000..741c0f220 --- /dev/null +++ b/test/cases/010_platforms/110_gcp/000_run/test.yml @@ -0,0 +1,13 @@ +kernel: + image: linuxkit/kernel:4.19.76 + cmdline: "console=ttyS0" +init: + - linuxkit/init:1d8e0532ca588c5ad0d9ca6038349a70bb7ac626 + - linuxkit/runc:c1f0db27e71d948f3134b31ce76276f843849b0a +onboot: + - name: poweroff + image: linuxkit/poweroff:b498d30dd9660090565537fceb9e757618737a85 + command: ["/bin/sh", "/poweroff.sh", "10"] +trust: + org: + - linuxkit