1""" Integration test for LP #187099 2 3Ensure that if fallocate fails during mkswap that we fall back to using dd 4 5https://bugs.launchpad.net/cloud-init/+bug/1897099 6""" 7 8import pytest 9 10 11USER_DATA = """\ 12#cloud-config 13bootcmd: 14 - echo 'whoops' > /usr/bin/fallocate 15swap: 16 filename: /swap.img 17 size: 10000000 18 maxsize: 10000000 19""" 20 21 22@pytest.mark.sru_2020_11 23@pytest.mark.user_data(USER_DATA) 24@pytest.mark.no_container('Containers cannot configure swap') 25def test_fallocate_fallback(client): 26 log = client.read_from_file('/var/log/cloud-init.log') 27 assert '/swap.img' in client.execute('cat /proc/swaps') 28 assert '/swap.img' in client.execute('cat /etc/fstab') 29 assert 'fallocate swap creation failed, will attempt with dd' in log 30 assert "Running command ['dd', 'if=/dev/zero', 'of=/swap.img'" in log 31 assert 'SUCCESS: config-mounts ran successfully' in log 32