Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
tests: add core revert test #3348
Merged
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
078af40
add core-revert test
fgimenez 8aa2d62
added checks for core tracking channels
fgimenez cf55c05
fixed network interface name
fgimenez c356b70
* fix tracking pattern
fgimenez 31a5da4
wait for revert pattern simplified
fgimenez a4f8214
check changes output from host so that we can use MATCH
fgimenez 5824842
fi wait ordering
fgimenez 447a1dc
refactored; extra-snaps-assertions without additional task
fgimenez b9b30bb
comment tracking check after revert
fgimenez 4ccdb4a
after reverting the channel tracked is not changed
fgimenez 349c1df
merged master and deconflicted
fgimenez da517ed
surface refresh issue
fgimenez 1c2405b
Merge branch 'master' into core-revert
fgimenez 9222266
configure network-manager to control eth0 and disable netplan
fgimenez c0f9fd3
use proper ext4 disk for assertion autoimport
fgimenez aa7df4e
do not return assertions disk name
fgimenez e670e43
install bluez too
fgimenez 852f623
make connected pattern more specific
fgimenez 11ac450
remove bluez; nm without devmode; added aliases check
fgimenez c8d4d88
add debug info
fgimenez add03b4
move ubuntu-image management to the suite level; remove trap
fgimenez dc0a2e4
timeout restrictions; fix ubuntu-core install; fir debug section
fgimenez 37c5b5d
fix typo
fgimenez 4382841
reduced kill timeout, enough to hit the revert issue
fgimenez 581fe0a
Merge branch 'master' into core-revert
fgimenez 7ed01b5
show debug info even when grep considers syslog as a binary file
fgimenez 78802c4
merged master and deconflicted
fgimenez
Jump to file or symbol
Failed to load files and symbols.
| @@ -0,0 +1,66 @@ | ||
| +#!/bin/sh | ||
| +. $TESTSLIB/systemd.sh | ||
| + | ||
| +wait_for_ssh(){ | ||
| + retry=300 | ||
| + while ! execute_remote true; do | ||
| + retry=$(( retry - 1 )) | ||
| + if [ $retry -le 0 ]; then | ||
| + echo "Timed out waiting for ssh. Aborting!" | ||
| + exit 1 | ||
| + fi | ||
| + sleep 1 | ||
| + done | ||
| +} | ||
| + | ||
| +prepare_ssh(){ | ||
| + execute_remote "sudo adduser --extrausers --quiet --disabled-password --gecos '' test" | ||
| + execute_remote "echo test:ubuntu | sudo chpasswd" | ||
| + execute_remote "echo 'test ALL=(ALL) NOPASSWD:ALL' | sudo tee /etc/sudoers.d/test-user" | ||
| +} | ||
| + | ||
| +create_assertions_disk(){ | ||
| + dd if=/dev/null of=assertions.disk bs=1M seek=1 | ||
| + mkfs.ext4 -F assertions.disk | ||
| + mkdir /mnt/assertions | ||
| + mount -t ext4 -o loop assertions.disk /mnt/assertions | ||
| + cp $TESTSLIB/assertions/auto-import.assert /mnt/assertions | ||
| + umount /mnt/assertions && rm -rf /mnt/assertions | ||
| +} | ||
| + | ||
| +create_nested_core_vm(){ | ||
| + # determine arch related vars | ||
| + case "$NESTED_ARCH" in | ||
| + amd64) | ||
| + QEMU="$(which qemu-system-x86_64)" | ||
| + ;; | ||
| + i386) | ||
| + QEMU="$(which qemu-system-i386)" | ||
|
|
||
| + ;; | ||
| + *) | ||
| + echo "unsupported architecture" | ||
| + exit 1 | ||
| + ;; | ||
| + esac | ||
| + | ||
| + # create ubuntu-core image | ||
| + mkdir -p /tmp/work-dir | ||
|
|
||
| + /snap/bin/ubuntu-image --image-size 3G $TESTSLIB/assertions/nested-${NESTED_ARCH}.model --channel $CORE_CHANNEL --output ubuntu-core.img | ||
| + mv ubuntu-core.img /tmp/work-dir | ||
| + | ||
| + create_assertions_disk | ||
| + | ||
| + systemd_create_and_start_unit nested-vm "${QEMU} -m 1024 -nographic -net nic,model=virtio -net user,hostfwd=tcp::8022-:22 -drive file=/tmp/work-dir/ubuntu-core.img,if=virtio,cache=none -drive file=${PWD}/assertions.disk,if=virtio,cache=none" | ||
| + | ||
| + wait_for_ssh | ||
| + prepare_ssh | ||
| +} | ||
| + | ||
| +destroy_nested_core_vm(){ | ||
| + systemd_stop_and_destroy_unit nested-vm | ||
| + rm -rf /tmp/work-dir | ||
| +} | ||
| + | ||
| +execute_remote(){ | ||
| + sshpass -p ubuntu ssh -p 8022 -q -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user1@localhost "$*" | ||
| +} | ||
| @@ -0,0 +1,71 @@ | ||
| +summary: core revert test | ||
|
|
||
| + | ||
| +systems: [ubuntu-16.04-64] | ||
fgimenez
Contributor
|
||
| + | ||
| +prepare: | | ||
| + apt install -y --no-install-recommends kpartx | ||
| + | ||
| + . $TESTSLIB/nested.sh | ||
| + create_nested_core_vm | ||
| + | ||
| +restore: | | ||
| + apt autoremove -y --purge kpartx | ||
| + | ||
| + . $TESTSLIB/nested.sh | ||
| + destroy_nested_core_vm | ||
| + | ||
| +debug: | | ||
| + systemctl stop nested-vm || true | ||
| + if [ -f /tmp/work-dir/ubuntu-core.img ]; then | ||
| + loops=$(kpartx -avs /tmp/work-dir/ubuntu-core.img | cut -d' ' -f 3) | ||
| + | ||
| + part=$(echo "$loops" | tail -1) | ||
| + | ||
| + tmp=$(mktemp -d) | ||
| + mount /dev/mapper/$part $tmp | ||
| + | ||
| + grep --text "hsearch_r failed for.* No such process" $tmp/system-data/var/log/syslog | ||
| + | ||
| + umount $tmp | ||
| + rm -rf $tmp | ||
| + kpartx -ds /tmp/work-dir/ubuntu-core.img | ||
| + fi | ||
| + | ||
| +kill-timeout: 35m | ||
| + | ||
| +execute: | | ||
| + . $TESTSLIB/nested.sh | ||
| + | ||
| + cd $SPREAD_PATH | ||
| + execute_remote "sudo snap install network-manager" | ||
| + execute_remote "snap aliases" | MATCH "nmcli" | ||
| + | ||
| + # configure network-manager to take over the connection control on next reboot | ||
| + execute_remote "sudo mv /etc/netplan/00-snapd-config.yaml /etc/netplan/00-snapd-config.yaml.back" | ||
| + execute_remote "sudo sed -i 's/unmanaged-devices+=interface-name:eth*/#unmanaged-devices+=interface-name:eth*/' /var/snap/network-manager/current/conf.d/disable-ethernet.conf" | ||
| + | ||
| + execute_remote "snap info core" | MATCH "tracking: +${CORE_CHANNEL}" | ||
| + execute_remote "sudo snap refresh --${CORE_REFRESH_CHANNEL} core" || true | ||
| + | ||
| + wait_for_ssh | ||
| + | ||
| + while ! execute_remote "snap changes" | MATCH "Done.*Refresh \"core\" snap from \"${CORE_REFRESH_CHANNEL}\" channel"; do sleep 1 ; done | ||
| + execute_remote "snap info core" | MATCH "tracking: +${CORE_REFRESH_CHANNEL}" | ||
| + # make sure network-manager is on charge of eth0 | ||
| + execute_remote "nmcli c" | MATCH eth0 | ||
| + execute_remote "nmcli d" | MATCH "eth0 +ethernet +connected" | ||
| + # sanity check, no refresh should be done here but the command shouldn't fail | ||
| + execute_remote "sudo snap refresh" | ||
| + | ||
| + execute_remote "snap aliases" | MATCH "nmcli" | ||
| + | ||
| + execute_remote "sudo snap revert core" || true | ||
| + | ||
| + wait_for_ssh | ||
| + | ||
| + while ! execute_remote "snap changes" | MATCH "Done.*Revert \"core\" snap"; do sleep 1 ; done | ||
| + execute_remote "snap aliases" | MATCH "nmcli" | ||
| + execute_remote "snap info core" | MATCH "tracking: +${CORE_REFRESH_CHANNEL}" | ||
| + execute_remote "ifconfig" | MATCH eth0 | ||
| + # this currently fails, refresh from the old version conflicts with aliases | ||
| + # execute_remote "sudo snap refresh" | ||
| @@ -1,12 +0,0 @@ | ||
| -summary: check that prepare-image worked well from inside the generated image | ||
| -systems: [ubuntu-core-16-*] | ||
| -manual: true | ||
| -execute: | | ||
| - echo "Wait for first boot to be done" | ||
| - while ! snap changes | grep -q "Done.*Initialize system state"; do sleep 1; done | ||
| - | ||
| - echo "We have a model assertion" | ||
| - snap known model|grep "series: 16" | ||
| - | ||
| - echo "Make sure core has an actual revision" | ||
| - snap list | MATCH "^core +[0-9]+\-[0-9]+ +[0-9]+ +canonical +\-" |
QEMUcan expand to "". This is not a big deal but I'd rather get aqemu-system-x86_64: command not foundthan a more confusing message below when the first argument of qemu becomes the command. Could we please drop thewhich?