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 <dave@dtucker.co.uk>
This commit is contained in:
Dave Tucker 2019-11-26 13:21:35 +00:00
parent a98046999f
commit 63849b606f
2 changed files with 53 additions and 0 deletions

View File

@ -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

View File

@ -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