From b1ae3ab611347845bcc4ce75f2b7e08b2ba1afac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jake=20Buchholz=20G=C3=B6kt=C3=BCrk?= Date: Sat, 19 Oct 2024 16:12:22 -0700 Subject: [PATCH] Makefile & tests for new clouds --- Makefile | 26 ++++++++++++++-------- tests/imds.test | 52 +++++++++++++++++++++---------------------- tests/tiny-cloud.test | 2 +- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 4eaf745..71ed91a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PREFIX?=/ -SUBPACKAGES = core network openrc aws azure gcp oci nocloud incus +SUBPACKAGES = core network openrc aws azure gcp hetzner incus nocloud oci scaleway .PHONY: check install $(SUBPACKAGES) @@ -53,9 +53,15 @@ gcp: install -Dm644 -t $(PREFIX)/lib/tiny-cloud/cloud/gcp \ lib/tiny-cloud/cloud/gcp/* -oci: - install -Dm644 -t $(PREFIX)/lib/tiny-cloud/cloud/oci \ - lib/tiny-cloud/cloud/oci/* +hetzner: + install -Dm644 -t $(PREFIX)/lib/tiny-cloud/cloud/hetzner \ + lib/tiny-cloud/cloud/hetzner/* + +incus: + install -Dm644 -t $(PREFIX)/lib/tiny-cloud/cloud/incus \ + lib/tiny-cloud/cloud/incus/imds + install -Dm755 -t $(PREFIX)/lib/tiny-cloud/cloud/incus \ + lib/tiny-cloud/cloud/incus/autodetect nocloud: install -Dm644 -t $(PREFIX)/lib/tiny-cloud/cloud/nocloud \ @@ -64,11 +70,13 @@ nocloud: install -Dm755 -t $(PREFIX)/lib/tiny-cloud/cloud/nocloud \ lib/tiny-cloud/cloud/nocloud/autodetect -incus: - install -Dm644 -t $(PREFIX)/lib/tiny-cloud/cloud/incus \ - lib/tiny-cloud/cloud/incus/imds - install -Dm755 -t $(PREFIX)/lib/tiny-cloud/cloud/incus \ - lib/tiny-cloud/cloud/incus/autodetect +oci: + install -Dm644 -t $(PREFIX)/lib/tiny-cloud/cloud/oci \ + lib/tiny-cloud/cloud/oci/* + +scaleway: + install -Dm644 -t $(PREFIX)/lib/tiny-cloud/cloud/scaleway \ + lib/tiny-cloud/cloud/scaleway/* check: tests/Kyuafile Kyuafile kyua --variable parallelism=$(shell nproc) test || (kyua report --verbose && exit 1) diff --git a/tests/imds.test b/tests/imds.test index 6898803..e7a90b6 100755 --- a/tests/imds.test +++ b/tests/imds.test @@ -5,7 +5,7 @@ . $(atf_get_srcdir)/test_env.sh export PREFIX="$srcdir" -PROVIDERS="aws azure gcp nocloud scaleway" +PROVIDERS="aws azure gcp hetzner incus oci nocloud scaleway" init_tests \ imds_help \ @@ -72,6 +72,7 @@ check_hostname() { imds_hostname_aws_body() { check_hostname aws; } imds_hostname_azure_body() { check_hostname azure; } imds_hostname_gcp_body() { check_hostname gcp; } +imds_hostname_hetzner_body() { check_hostname hetzner; } imds_hostname_incus_body() { fake_metadata incus <<-EOF #cloud-config @@ -87,7 +88,6 @@ HOSTNAME=myhostname EOF CLOUD="scaleway" atf_check -o match:"myhostname" imds @hostname } -imds_hostname_hetzner_body() { check_hostname hetzner; } check_local_hostname() { fake_metadata "$1" <<-EOF @@ -107,6 +107,7 @@ check_local_hostname() { imds_local_hostname_aws_body() { check_local_hostname aws; } imds_local_hostname_azure_body() { check_local_hostname azure; } imds_local_hostname_gcp_body() { check_local_hostname gcp; } +imds_local_hostname_hetzner_body() { check_local_hostname hetzner; } imds_local_hostname_incus_body() { check_local_hostname incus; } imds_local_hostname_nocloud_body() { check_local_hostname nocloud; } imds_local_hostname_oci_body() { check_local_hostname oci; } @@ -117,8 +118,6 @@ FOO=bar EOF CLOUD="scaleway" atf_check -o match:"^myhostname$" imds @local-hostname } -imds_local_hostname_hetzner_body() { check_local_hostname hetzner; } -imds_local_hostname_incus_body() { check_local_hostname incus; } check_ssh_keys() { local key="ssh-ed25519 keydata" @@ -146,6 +145,28 @@ check_ssh_keys() { imds_ssh_keys_aws_body() { check_ssh_keys aws; } imds_ssh_keys_azure_body() { check_ssh_keys azure; } imds_ssh_keys_gcp_body() { check_ssh_keys gcp; } +imds_ssh_keys_hetzner_body() { + local key="ssh-ed25519 keydata" + fake_metadata "hetzner" <<-EOF + # hetzner + public-keys: '["$key"]' + EOF + CLOUD="hetzner" atf_check -o match:"$key" imds @ssh-keys +} +imds_ssh_keys_incus_body() { + local key="ssh-ed25519 keydata" + fake_userdata_incus <<-EOF + ssh_authorized_keys: + - asdasdf + # other key + - $key + foo: bar + EOF + CLOUD="incus" atf_check \ + -o match:"$key" \ + -o not-match:"other key" \ + imds @ssh-keys +} imds_ssh_keys_nocloud_body() { check_ssh_keys nocloud; } imds_ssh_keys_oci_body() { check_ssh_keys oci; } imds_ssh_keys_scaleway_body() { @@ -163,29 +184,6 @@ SSH_PUBLIC_KEYS_0_IP= EOF CLOUD="scaleway" atf_check -o match:"$key" imds @ssh-keys } -imds_ssh_keys_hetzner_body() { - local key="ssh-ed25519 keydata" - fake_metadata "hetzner" <<-EOF - # hetzner - public-keys: '["$key"]' - EOF - CLOUD="hetzner" atf_check -o match:"$key" imds @ssh-keys -} - -imds_ssh_keys_incus_body() { - local key="ssh-ed25519 keydata" - fake_userdata_incus <<-EOF - ssh_authorized_keys: - - asdasdf - # other key - - $key - foo: bar - EOF - CLOUD="incus" atf_check \ - -o match:"$key" \ - -o not-match:"other key" \ - imds @ssh-keys -} imds_nocloud_cmdline_local_hostname_body() { atf_require_prog yx diff --git a/tests/tiny-cloud.test b/tests/tiny-cloud.test index cde611f..2639c36 100755 --- a/tests/tiny-cloud.test +++ b/tests/tiny-cloud.test @@ -6,7 +6,7 @@ export PREFIX="$srcdir" export MOCK=echo -PROVIDERS="alpine aws azure gcp nocloud oci scaleway hetzner" +PROVIDERS="alpine aws azure gcp incus hetzner nocloud oci scaleway" init_tests \ tiny_cloud_help \