Skip to content

Commit

Permalink
test/suites: Ensure ping is installed (#447)
Browse files Browse the repository at this point in the history
Sometimes cloud-init fails to install `ping` so try to install it
manually as well.
  • Loading branch information
masnax authored Oct 23, 2024
2 parents 740041a + 9ed1907 commit 2cf45c1
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions test/suites/basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ EOF
"

# Launch a container and VM with CEPH storage & OVN network.
lxc exec micro01 -- lxc init ubuntu-minimal:22.04 v1 -c limits.memory=512MiB -d root,size=3GiB --vm -s remote -n default
lxc exec micro01 -- lxc init ubuntu-minimal:22.04 c1 -c limits.memory=512MiB -d root,size=3GiB -s remote -n default
lxc exec micro01 -- lxc init ubuntu-minimal-daily:22.04 v1 -c limits.memory=512MiB -d root,size=3GiB --vm -s remote -n default
lxc exec micro01 -- lxc init ubuntu-minimal-daily:22.04 c1 -c limits.memory=512MiB -d root,size=3GiB -s remote -n default

# Ensure proper storage pool and network selection by inspecting their used_by.
for m in c1 v1 ; do
Expand Down Expand Up @@ -559,9 +559,9 @@ EOF
if [ "${SKIP_VM_LAUNCH}" = "1" ]; then
echo "::warning::SKIPPING VM LAUNCH TEST"
else
lxc exec micro01 -- lxc launch ubuntu-minimal:22.04 v1 -c limits.memory=512MiB -d root,size=3GiB --vm -s local -n default
lxc exec micro01 -- lxc launch ubuntu-minimal-daily:22.04 v1 -c limits.memory=512MiB -d root,size=3GiB --vm -s local -n default
fi
lxc exec micro01 -- lxc launch ubuntu-minimal:22.04 c1 -c limits.memory=512MiB -d root,size=1GiB -s local -n default
lxc exec micro01 -- lxc launch ubuntu-minimal-daily:22.04 c1 -c limits.memory=512MiB -d root,size=1GiB -s local -n default

# Ensure we can reach the launched instances.
for m in c1 v1 ; do
Expand Down Expand Up @@ -644,8 +644,6 @@ EOF
config:
cloud-init.user-data: |
#cloud-config
packages:
- iputils-ping
write_files:
- content: |
#!/bin/sh
Expand All @@ -665,10 +663,10 @@ EOF
if [ "${SKIP_VM_LAUNCH}" = "1" ]; then
echo "::warning::SKIPPING VM LAUNCH TEST"
else
lxc exec micro01 -- lxc launch ubuntu-minimal:22.04 v1 -c limits.memory=512MiB -d root,size=3GiB --vm -s remote -n default
lxc exec micro01 -- lxc launch ubuntu-minimal-daily:22.04 v1 -c limits.memory=512MiB -d root,size=3GiB --vm -s remote -n default
fi
lxc exec micro01 -- lxc launch ubuntu-minimal:22.04 c1 -c limits.memory=512MiB -d root,size=1GiB -s remote -n default
lxc exec micro01 -- lxc launch ubuntu-minimal:22.04 c2 -c limits.memory=512MiB -d root,size=1GiB -s remote -n default
lxc exec micro01 -- lxc launch ubuntu-minimal-daily:22.04 c1 -c limits.memory=512MiB -d root,size=1GiB -s remote -n default
lxc exec micro01 -- lxc launch ubuntu-minimal-daily:22.04 c2 -c limits.memory=512MiB -d root,size=1GiB -s remote -n default

# Ensure we can reach the launched instances.
for m in c1 c2 v1 ; do
Expand Down Expand Up @@ -697,11 +695,20 @@ EOF
IPV4_GW="$(lxc network get lxdbr0 ipv4.address | cut -d/ -f1)"
IPV6_GW="$(lxc network get lxdbr0 ipv6.address | cut -d/ -f1)"

# Sometimes ping is not installed by cloud-init, so try to install it manually
for m in c1 c2 ; do
lxc exec micro01 -- lxc exec "${m}" -- apt-get update
lxc exec micro01 -- lxc exec "${m}" -- apt-get install -y --no-install-recommends iputils-ping
done

lxc exec micro01 -- lxc exec c1 -- ping -nc1 -w5 -4 "${IPV4_GW}"
lxc exec micro01 -- lxc exec c2 -- ping -nc1 -w5 -4 "${IPV4_GW}"
lxc exec micro01 -- lxc exec c1 -- ping -nc1 -w5 -6 "${IPV6_GW}"
lxc exec micro01 -- lxc exec c2 -- ping -nc1 -w5 -6 "${IPV6_GW}"
if [ "${SKIP_VM_LAUNCH}" != "1" ]; then
# Sometimes ping is not installed by cloud-init, so try to install it manually
lxc exec micro01 -- lxc exec v1 -- apt-get update
lxc exec micro01 -- lxc exec v1 -- apt-get install -y --no-install-recommends iputils-ping
lxc exec micro01 -- lxc exec v1 -- ping -nc1 -w5 -4 "${IPV4_GW}"
lxc exec micro01 -- lxc exec v1 -- ping -nc1 -w5 -6 "${IPV6_GW}"
fi
Expand Down Expand Up @@ -804,9 +811,9 @@ EOF
if [ "${SKIP_VM_LAUNCH}" = "1" ]; then
echo "::warning::SKIPPING VM LAUNCH TEST"
else
lxc exec micro01 -- lxc launch ubuntu-minimal:22.04 v1 -c limits.memory=512MiB -d root,size=3GiB --vm -s remote -n default
lxc exec micro01 -- lxc launch ubuntu-minimal-daily:22.04 v1 -c limits.memory=512MiB -d root,size=3GiB --vm -s remote -n default
fi
lxc exec micro01 -- lxc launch ubuntu-minimal:22.04 c1 -c limits.memory=512MiB -d root,size=1GiB -s remote -n default
lxc exec micro01 -- lxc launch ubuntu-minimal-daily:22.04 c1 -c limits.memory=512MiB -d root,size=1GiB -s remote -n default

# Ensure we can reach the launched instances.
for m in c1 v1 ; do
Expand Down

0 comments on commit 2cf45c1

Please sign in to comment.