Skip to content

Commit

Permalink
Merge pull request #58 from simondeziel/misc-fixes
Browse files Browse the repository at this point in the history
Misc fixes
  • Loading branch information
tomponline authored Feb 2, 2024
2 parents 3bf0ae8 + c170185 commit 050ca9b
Show file tree
Hide file tree
Showing 14 changed files with 252 additions and 175 deletions.
13 changes: 4 additions & 9 deletions bin/helpers
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
# waitSnapdSeed: wait for snapd to be seeded.
waitSnapdSeed() (
set +x
for i in $(seq 60); do # Wait up to 60s.
if systemctl show snapd.seeded.service --value --property SubState | grep -qx exited; then
return 0 # Success.
fi

sleep 1
done

echo "snapd not seeded after ${i}s"
if timeout 60 snap wait system seed.loaded; then
return 0 # Success.
fi
echo "snapd not seeded after 60s"
return 1 # Failed.
)

Expand Down
4 changes: 2 additions & 2 deletions bin/openstack-run
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ _script="$(mktemp)"
test_name="$(basename "${script}")"

KEY_NAME="ssh-key"
FLAVOR="$(openstack flavor list -f value -c Name | grep -m1 'cpu8-ram32-disk20\b')"
FLAVOR="$(openstack flavor list -f value -c Name | grep -m1 'cpu8-ram32-disk50\b')"
NETWORK="$(openstack network list -f value -c Name | grep -Fm1 "net_stg-lxd-cloud-testing")"
IMAGE="$(openstack image list -f value -c Name --sort-column Name --sort-descending | grep -m1 "auto-sync/ubuntu-${serie}-.*-amd64-")"
NAME="lxd-ci-${test_name}-${serie}-$(echo "${lxd_snap_channel}" | sed 's/[./]/-/g')"
Expand Down Expand Up @@ -101,7 +101,7 @@ if echo "${IP}" | grep -q ":"; then
else
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${_script}" "ubuntu@${IP}:test-script"
fi
ssh -n -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "ubuntu@${IP}" sudo "https_proxy=http://squid.internal:3128" bash test-script "$@"
ssh -n -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "ubuntu@${IP}" sudo "https_proxy=http://squid.internal:3128" "PURGE_LXD=1" bash test-script "$@"

# Success
RET=0
2 changes: 1 addition & 1 deletion bin/testflinger-run
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test_data:
\$SCP "\${_script}" "ubuntu@\${DEVICE_IP}:test-script"
# Run the test
\$SSH "ubuntu@\${DEVICE_IP}" -- sudo bash test-script $@
\$SSH "ubuntu@\${DEVICE_IP}" -- sudo "PURGE_LXD=1" bash test-script $@
EOF
}

Expand Down
2 changes: 1 addition & 1 deletion tests/cgroup
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -x

# Start a container with no limits
echo "=> Start a container with no limits"
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" c1
lxc launch "${TEST_IMG:-ubuntu-minimal-daily:22.04}" c1

echo "==> Validate default values"
[ "$(lxc exec c1 -- nproc)" = "$(nproc)" ]
Expand Down
3 changes: 2 additions & 1 deletion tests/cluster
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ extra_cleanup() {
# Launch the container
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" "${PREFIX}-1" -c security.nesting=true -c security.devlxd.images=true

sleep 10
waitInstanceBooted "${PREFIX}-1"

lxc exec "${PREFIX}-1" -- snap refresh lxd --channel="$2"

for i in $(seq 2 "$1"); do
lxc copy "${PREFIX}-1" "${PREFIX}-$i"
lxc start "${PREFIX}-$i"
waitInstanceBooted "${PREFIX}-$i"
done

for i in $(seq "$1"); do
Expand Down
37 changes: 20 additions & 17 deletions tests/devlxd-vm
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,32 @@ lxc exec v1 -- curl -s --unix-socket /dev/lxd/sock http://custom.socket/1.0/devi
lxc exec v1 -- curl -s --unix-socket /dev/lxd/sock http://custom.socket/1.0/config | jq
lxc exec v1 -- curl -s --unix-socket /dev/lxd/sock http://custom.socket/1.0/meta-data | grep -q '#cloud-config'

# test instance Ready state
lxc exec v1 -- curl -s --unix-socket /dev/lxd/sock -X PATCH -d '{"state":"Ready"}' http://custom.socket/1.0
[ "$(lxc config get v1 volatile.last_state.ready)" = "true" ]

lxc exec v1 -- curl -s --unix-socket /dev/lxd/sock -X PATCH -d '{"state":"Started"}' http://custom.socket/1.0
[ "$(lxc config get v1 volatile.last_state.ready)" = "false" ]

lxc exec v1 -- curl -s --unix-socket /dev/lxd/sock -X PATCH -d '{"state":"Ready"}' http://custom.socket/1.0
[ "$(lxc config get v1 volatile.last_state.ready)" = "true" ]
lxc stop -f v1
sleep 5
[ "$(lxc config get v1 volatile.last_state.ready)" = "false" ]
if hasNeededAPIExtension instance_ready_state; then
# test instance Ready state
lxc exec v1 -- curl -s --unix-socket /dev/lxd/sock -X PATCH -d '{"state":"Ready"}' http://custom.socket/1.0
[ "$(lxc config get v1 volatile.last_state.ready)" = "true" ]

lxc exec v1 -- curl -s --unix-socket /dev/lxd/sock -X PATCH -d '{"state":"Started"}' http://custom.socket/1.0
[ "$(lxc config get v1 volatile.last_state.ready)" = "false" ]

lxc exec v1 -- curl -s --unix-socket /dev/lxd/sock -X PATCH -d '{"state":"Ready"}' http://custom.socket/1.0
[ "$(lxc config get v1 volatile.last_state.ready)" = "true" ]
lxc stop -f v1
sleep 5
[ "$(lxc config get v1 volatile.last_state.ready)" = "false" ]

lxc start v1
waitInstanceReady v1
else
echo "Skipping instance Ready state tests, not supported"
fi

# Test nested VM functionality.
lxc start v1
waitInstanceReady v1

# Configure to use the proxy
lxc exec v1 -- snap wait system seed.loaded
lxc exec v1 -- snap remove --purge lxd || true
lxc exec v1 -- snap install lxd --channel="${LXD_SNAP_CHANNEL}"
lxc exec v1 -- /snap/bin/lxd init --auto
lxc exec v1 -- /snap/bin/lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" v1v1 --vm
lxc exec v1 -- /snap/bin/lxc launch "${TEST_IMG:-ubuntu-minimal-daily:22.04}" v1v1 --vm
sleep 30
lxc exec v1 -- /snap/bin/lxc info v1v1 | grep -F RUNNING

Expand Down
38 changes: 26 additions & 12 deletions tests/docker
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ lxd init --auto
CNAME="docker-$$"

# Create the container
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" "${CNAME}" -c security.nesting=true "$@"
lxc launch "${TEST_IMG:-ubuntu-minimal-daily:22.04}" "${CNAME}" -c security.nesting=true "$@"

if [ -n "${https_proxy:-""}" ]; then
echo "Using https_proxy=${https_proxy} in ${CNAME}"
lxc config set "${CNAME}" environment.https_proxy="${https_proxy}"
fi

(
cat << EOF
Expand All @@ -21,33 +26,42 @@ set -eux
# Install distro docker
apt-get update
apt-get install --no-install-recommends --yes --force-yes docker.io
apt-get install --no-install-recommends --yes docker.io busybox-static
# Stop the distro docker
systemctl stop docker.service
systemctl stop docker.socket
systemctl stop docker.service docker.socket
# Download binaries built from current git head of the Docker repo.
for BIN in docker dockerd docker-containerd docker-containerd-shim docker-init docker-proxy docker-runc; do
wget -q "https://master.dockerproject.org/linux/x86_64/\${BIN}" -O "/usr/bin/\${BIN}" && \
wget "https://master.dockerproject.org/linux/x86_64/\${BIN}" -O "/usr/bin/\${BIN}" && \
chmod +x "/usr/bin/\${BIN}"
done
unset https_proxy
# Start docker again
systemctl start docker
sleep 5
# Test whether we can pull a simple Docker image.
docker pull busybox:latest
# Test whether we can remove a simple Docker image.
docker rmi busybox:latest
# Show docker info (client and daemon version, etc.)
docker info
# Test whether we can build a simple Docker image.
rm -rf busybox
mkdir busybox
cat << EOD > busybox/Dockerfile
FROM scratch
ADD echo /
ENTRYPOINT ["/echo", "Hello world"]
EOD
cp "\$(command -v busybox)" busybox/echo
docker builder build --tag local:hello busybox/
# Run a basic hello-world
docker run hello-world
docker run --rm local:hello
# Test whether we can remove a simple Docker image.
docker image rm local:hello
EOF
) | lxc exec "${CNAME}" -- sh -eux

Expand Down
13 changes: 8 additions & 5 deletions tests/main-openstack
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ run_test jammy default tests/cgroup "${lxd_snap_channel}"
#run_test jammy cgroup1 tests/cgroup "${lxd_snap_channel}"
run_test jammy swapaccount tests/cgroup "${lxd_snap_channel}"
run_test focal default tests/cgroup "${lxd_snap_channel}"
run_test focal swapaccount tests/cgroup "${lxd_snap_channel}"
# https://github.com/canonical/lxd-ci/issues/7
#run_test focal swapaccount tests/cgroup "${lxd_snap_channel}"

# cluster
#run_test jammy default tests/cluster "${lxd_snap_channel}" 3 "5.0/stable" "${lxd_snap_channel}"
# cluster (upgrade from XX/stable -> ${lxd_snap_channel})
cluster_snap_src_channel="$(echo "${lxd_snap_channel}" | cut -d/ -f1)/stable"
run_test jammy default tests/cluster "${lxd_snap_channel}" 3 "${cluster_snap_src_channel}" "${lxd_snap_channel}"

# cpu-vm
run_test jammy default tests/cpu-vm "${lxd_snap_channel}"
Expand All @@ -43,7 +45,7 @@ run_test jammy default tests/cpu-vm "${lxd_snap_channel}"
run_test jammy default tests/devlxd-vm "${lxd_snap_channel}"

# docker
# XXX: unable to pull docker image due to rate limiting done by docker hub
# XXX: master.dockerproject.org isn't authorized at the proxy level
#run_test jammy default tests/docker "${lxd_snap_channel}"

# gpu
Expand All @@ -63,7 +65,8 @@ if echo "${lxd_snap_channel}" | grep -qE "^(latest|5\.[1-9].)/"; then
fi

# network
run_test jammy default tests/network "${lxd_snap_channel}"
# XXX: requires SR-IOV capable NIC
#run_test jammy default tests/network "${lxd_snap_channel}"
run_test jammy default tests/network-bridge-firewall "${lxd_snap_channel}"
run_test jammy hwe tests/network-bridge-firewall "${lxd_snap_channel}"
run_test jammy default tests/network-ovn "${lxd_snap_channel}"
Expand Down
6 changes: 3 additions & 3 deletions tests/main-testflinger
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ run_test jammy default tests/cgroup "${lxd_snap_channel}"
#run_test jammy cgroup1 tests/cgroup "${lxd_snap_channel}"
run_test jammy swapaccount tests/cgroup "${lxd_snap_channel}"
run_test focal default tests/cgroup "${lxd_snap_channel}"
run_test focal swapaccount tests/cgroup "${lxd_snap_channel}"
# https://github.com/canonical/lxd-ci/issues/7
#run_test focal swapaccount tests/cgroup "${lxd_snap_channel}"

# cluster (upgrade from XX/stable -> ${lxd_snap_channel})
cluster_snap_src_channel="$(echo "${lxd_snap_channel}" | cut -d/ -f1)/stable"
Expand All @@ -47,8 +48,7 @@ run_test jammy default tests/cpu-vm "${lxd_snap_channel}"
run_test jammy default tests/devlxd-vm "${lxd_snap_channel}"

# docker
# XXX: unable to pull docker image due to rate limiting done by docker hub
#run_test jammy default tests/docker "${lxd_snap_channel}"
run_test jammy default tests/docker "${lxd_snap_channel}"

# gpu
# XXX: requires nvidia graphic card to be present in the host
Expand Down
Loading

0 comments on commit 050ca9b

Please sign in to comment.