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