1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2026-02-04 04:22:43 +03:00

tests: fix tests to use init__ prefix

commit 4b86923358c0 (Fixes for tiny-cloud Wrapper) changed API so all
init functions had an init__ prefix and the SKIP_INIT_ACTION was moved
to tiny-cloud.

Adjust the tests for this.
This commit is contained in:
Natanael Copa 2023-05-02 14:32:10 +02:00
parent 4b86923358
commit c46b12ea04
3 changed files with 10 additions and 64 deletions

View File

@ -9,33 +9,21 @@ lib="$srcdir"/lib/tiny-cloud/init
init_tests \
expand_root \
expand_root_partition \
expand_root_skip \
install_hotplugs_skip \
install_hotplugs_fail
PROVIDERS="aws azure gcp nocloud oci"
expand_root_body() {
fake_bin test-expand-root <<-EOF
#!/bin/sh
. "$lib"
expand_root
EOF
mkdir proc
echo "/dev/xvda / ext4 rw,noatime 0 0" > proc/mounts
for provider in $PROVIDERS; do
CLOUD="$provider" atf_check \
-o match:"resize2fs /dev/xvda" \
test-expand-root
sh -c ". $lib; init__expand_root"
done
}
expand_root_partition_body() {
fake_bin test-expand-root <<-EOF
#!/bin/sh
. "$lib"
expand_root
EOF
mkdir -p proc sys/class/block \
sys/devices/pci0000:00/0000:00:1b.0/0000:01:00.0/nvme/nvme0/nvme0n1/nvme0n1p2 \
sys/devices/pci0000:00/0000:00:1b.0/0000:01:00.0/nvme/nvme0/nvme0n1/device
@ -49,46 +37,12 @@ expand_root_partition_body() {
-o match:"sfdisk .*/dev/nvme0n1" \
-o match:"partx .*/dev/nvme0n1" \
-o match:"resize2fs /dev/nvme0n1p2" \
test-expand-root
done
}
expand_root_skip_body() {
fake_bin test-expand-root <<-EOF
#!/bin/sh
SKIP_INIT_ACTIONS=expand_root
. "$lib"
expand_root
EOF
for provider in $PROVIDERS; do
CLOUD="$provider" atf_check \
-o match:'^ SKIPPING$' \
test-expand-root
done
}
install_hotplugs_skip_body() {
fake_bin test-install-hotplugs <<-EOF
#!/bin/sh
SKIP_INIT_ACTIONS=install_hotplugs
. "$lib"
install_hotplugs
EOF
for provider in $PROVIDERS; do
CLOUD="$provider" atf_check \
-o match:'^ SKIPPING$' \
test-install-hotplugs
sh -c ". $lib; init__expand_root"
done
}
install_hotplugs_fail_body() {
fake_bin test-install-hotplugs <<-EOF
#!/bin/sh
HOTPLUG_MODULES="vnic_eth_hotplug"
. "$lib"
install_hotplugs
EOF
CLOUD=aws atf_check -s not-exit:0 \
-o match:"^ vnic_eth_hotplug\(!\)$" \
test-install-hotplugs
-e match:"vnic_eth_hotplug\(!\)" \
sh -c ". $lib; HOTPLUG_MODULES='vnic_eth_hotplug'; init__install_hotplugs"
}

View File

@ -38,10 +38,10 @@ run_userdata_body() {
echo "hello from user-data"
EOF
CLOUD="nocloud" atf_check \
sh -c ". \"$lib\"; save_userdata"
sh -c ". \"$lib\"; init__save_userdata"
CLOUD="nocloud" atf_check \
-o match:"hello from user-data" \
sh -c ". \"$lib\"; run_userdata"
sh -c ". \"$lib\"; init__run_userdata"
grep "hello from user-data" var/log/user-data.log || atf_fail "user-data.log failed"
grep -w "0" var/log/user-data.exit || atf_fail "user-data.exit failed"
}

View File

@ -42,16 +42,8 @@ set_hostname_body() {
CLOUD="nocloud" atf_check \
-o match:"hostname.*-F $PWD/etc/hostname" \
sh -c ". \"$lib\"; set_hostname"
sh -c ". \"$lib\"; init__set_hostname"
atf_check -o match:"^myhostname$" cat etc/hostname
rm etc/hostname
CLOUD="nocloud" atf_check \
-o not-match:"hostname.*-F $PWD/etc/hostname" \
sh -c "SKIP_INIT_ACTIONS=set_hostname ; . \"$lib\"; set_hostname"
if test -f etc/hostname; then
atf_fail "etc/hostname should not exist"
fi
}
set_ssh_keys_body() {
@ -66,7 +58,7 @@ set_ssh_keys_body() {
EOF
CLOUD="nocloud" atf_check \
-o match:"chown.*/\.ssh" \
sh -c ". \"$lib\"; set_ssh_keys"
sh -c ". \"$lib\"; init__set_ssh_keys"
atf_check -o match:"^ssh-ed25519 keydata" \
-o match:"^ssh-rsa foobar" \
cat home/alpine/.ssh/authorized_keys
@ -77,7 +69,7 @@ save_userdata_plain_body() {
#userdata
EOF
CLOUD="nocloud" atf_check \
sh -c ". \"$lib\"; save_userdata"
sh -c ". \"$lib\"; init__save_userdata"
atf_check -o match:"^#userdata" cat var/lib/cloud/user-data
}
@ -88,7 +80,7 @@ save_userdata_compressed_body() {
fake_userdata_nocloud < tmpfile
CLOUD="nocloud" atf_check \
sh -c ". \"$lib\"; save_userdata"
sh -c ". \"$lib\"; init__save_userdata"
if ! grep "^#userdata" var/lib/cloud/user-data; then
atf_fail "$comp failed"