summaryrefslogtreecommitdiff
path: root/tests/integration_tests/modules/test_lxd_bridge.py
diff options
context:
space:
mode:
authorzdc <zdc@users.noreply.github.com>2022-04-07 20:24:57 +0300
committerGitHub <noreply@github.com>2022-04-07 20:24:57 +0300
commit45c1d42e15f4a5fe5e176e1516b2da9d21e7837a (patch)
tree0535c3cf76b60dbf585416b4490c5bd9c9c99359 /tests/integration_tests/modules/test_lxd_bridge.py
parent96226f37cdbdaef2fbc51de7b9ca75b61a16792b (diff)
parentaa60d48c2711cdcd9f88a4e5c77379adb0408231 (diff)
downloadvyos-cloud-init-45c1d42e15f4a5fe5e176e1516b2da9d21e7837a.tar.gz
vyos-cloud-init-45c1d42e15f4a5fe5e176e1516b2da9d21e7837a.zip
Merge pull request #52 from vyos/current
T2117: Backport Cloud-init 22.1 with our changes to VyOS 1.3
Diffstat (limited to 'tests/integration_tests/modules/test_lxd_bridge.py')
-rw-r--r--tests/integration_tests/modules/test_lxd_bridge.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/integration_tests/modules/test_lxd_bridge.py b/tests/integration_tests/modules/test_lxd_bridge.py
new file mode 100644
index 00000000..3292a833
--- /dev/null
+++ b/tests/integration_tests/modules/test_lxd_bridge.py
@@ -0,0 +1,46 @@
+"""Integration tests for LXD bridge creation.
+
+(This is ported from
+``tests/cloud_tests/testcases/modules/lxd_bridge.yaml``.)
+"""
+import pytest
+import yaml
+
+from tests.integration_tests.util import verify_clean_log
+
+USER_DATA = """\
+#cloud-config
+lxd:
+ init:
+ storage_backend: dir
+ bridge:
+ mode: new
+ name: lxdbr0
+ ipv4_address: 10.100.100.1
+ ipv4_netmask: 24
+ ipv4_dhcp_first: 10.100.100.100
+ ipv4_dhcp_last: 10.100.100.200
+ ipv4_nat: true
+ domain: lxd
+"""
+
+
+@pytest.mark.no_container
+@pytest.mark.user_data(USER_DATA)
+class TestLxdBridge:
+ @pytest.mark.parametrize("binary_name", ["lxc", "lxd"])
+ def test_binaries_installed(self, class_client, binary_name):
+ """Check that the expected LXD binaries are installed"""
+ assert class_client.execute(["which", binary_name]).ok
+
+ def test_bridge(self, class_client):
+ """Check that the given bridge is configured"""
+ cloud_init_log = class_client.read_from_file("/var/log/cloud-init.log")
+ verify_clean_log(cloud_init_log)
+
+ # The bridge should exist
+ assert class_client.execute("ip addr show lxdbr0")
+
+ raw_network_config = class_client.execute("lxc network show lxdbr0")
+ network_config = yaml.safe_load(raw_network_config)
+ assert "10.100.100.1/24" == network_config["config"]["ipv4.address"]