diff options
author | James Falcon <james.falcon@canonical.com> | 2022-02-03 15:37:14 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-03 15:37:14 -0600 |
commit | 3f0918b57c6042de99da25bc6a9d120a074b8a8e (patch) | |
tree | 858bd67b4f66a059da101a521e96bb15b512f815 /tests/integration_tests | |
parent | 6127f3f63df8b8229f67f26c1ba3f4220f93f509 (diff) | |
download | vyos-cloud-init-3f0918b57c6042de99da25bc6a9d120a074b8a8e.tar.gz vyos-cloud-init-3f0918b57c6042de99da25bc6a9d120a074b8a8e.zip |
Integration test changes (#1240)
* Wrap the log fetching code in a try/except in case file is missing
* Stop checking NoCloud seed dir when testing datasource detection
Diffstat (limited to 'tests/integration_tests')
-rw-r--r-- | tests/integration_tests/conftest.py | 6 | ||||
-rw-r--r-- | tests/integration_tests/modules/test_combined.py | 34 |
2 files changed, 21 insertions, 19 deletions
diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py index b2bc9eb7..a90a5d49 100644 --- a/tests/integration_tests/conftest.py +++ b/tests/integration_tests/conftest.py @@ -206,7 +206,11 @@ def _collect_logs( os.symlink(log_dir.parent, last_symlink) tarball_path = log_dir / "cloud-init.tar.gz" - instance.pull_file("/var/tmp/cloud-init.tar.gz", tarball_path) + try: + instance.pull_file("/var/tmp/cloud-init.tar.gz", tarball_path) + except Exception as e: + log.error("Failed to pull logs: %s", e) + return tarball = TarFile.open(str(tarball_path)) tarball.extractall(path=str(log_dir)) diff --git a/tests/integration_tests/modules/test_combined.py b/tests/integration_tests/modules/test_combined.py index c88f40d3..43aa809e 100644 --- a/tests/integration_tests/modules/test_combined.py +++ b/tests/integration_tests/modules/test_combined.py @@ -205,24 +205,22 @@ class TestCombined: """Test datasource is detected at the proper boot stage.""" client = class_client status_file = client.read_from_file("/run/cloud-init/status.json") - - platform_datasources = { - "azure": "DataSourceAzure [seed=/dev/sr0]", - "ec2": "DataSourceEc2Local", - "gce": "DataSourceGCELocal", - "oci": "DataSourceOracle", - "openstack": "DataSourceOpenStackLocal [net,ver=2]", - "lxd_container": ( - "DataSourceNoCloud " - "[seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]" - ), - "lxd_vm": "DataSourceNoCloud [seed=/dev/sr0][dsmode=net]", - } - - assert ( - platform_datasources[client.settings.PLATFORM] - == json.loads(status_file)["v1"]["datasource"] - ) + parsed_datasource = json.loads(status_file)["v1"]["datasource"] + + if client.settings.PLATFORM in ["lxd_container", "lxd_vm"]: + assert parsed_datasource.startswith("DataSourceNoCloud") + else: + platform_datasources = { + "azure": "DataSourceAzure [seed=/dev/sr0]", + "ec2": "DataSourceEc2Local", + "gce": "DataSourceGCELocal", + "oci": "DataSourceOracle", + "openstack": "DataSourceOpenStackLocal [net,ver=2]", + } + assert ( + platform_datasources[client.settings.PLATFORM] + == parsed_datasource + ) def _check_common_metadata(self, data): assert data["base64_encoded_keys"] == [] |