blob: f68c6f2de1c0019edd213ac31c77a8733a90910b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
"""Integration tests for LXD bridge creation.
(This is ported from
``tests/cloud_tests/testcases/modules/lxd_bridge.yaml``.)
"""
import pytest
import yaml
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.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
@pytest.mark.sru_2020_11
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")
assert "WARN" not in 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"]
|