diff options
Diffstat (limited to 'tests/integration_tests/datasources/test_oci_networking.py')
-rw-r--r-- | tests/integration_tests/datasources/test_oci_networking.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/integration_tests/datasources/test_oci_networking.py b/tests/integration_tests/datasources/test_oci_networking.py index f569650e..dc0d343b 100644 --- a/tests/integration_tests/datasources/test_oci_networking.py +++ b/tests/integration_tests/datasources/test_oci_networking.py @@ -116,3 +116,42 @@ def test_oci_networking_iscsi_instance_secondary_vnics( ) assert len(expected_interfaces) + 1 == len(configured_interfaces) assert client.execute("ping -c 2 canonical.com").ok + + +SYSTEM_CFG = """\ +network: + ethernets: + id0: + dhcp4: true + dhcp6: true + match: + name: "ens*" + version: 2 +""" + + +def customize_netcfg( + client: IntegrationInstance, + tmpdir, +): + cfg = tmpdir.join("net.cfg") + with open(cfg, "w") as f: + f.write(SYSTEM_CFG) + client.push_file(cfg, "/etc/cloud/cloud.cfg.d/50-network-test.cfg") + client.execute("cloud-init clean --logs") + client.restart() + + +@pytest.mark.oci +def test_oci_networking_system_cfg(client: IntegrationInstance, tmpdir): + customize_netcfg(client, tmpdir) + log = client.read_from_file("/var/log/cloud-init.log") + verify_clean_log(log) + + assert ( + "Applying network configuration from system_cfg" in log + ), "network source used wasn't system_cfg" + netplan_yaml = client.read_from_file("/etc/netplan/50-cloud-init.yaml") + netplan_cfg = yaml.safe_load(netplan_yaml) + expected_netplan_cfg = yaml.safe_load(SYSTEM_CFG) + assert expected_netplan_cfg == netplan_cfg |