diff options
author | James Falcon <james.falcon@canonical.com> | 2021-12-02 08:51:26 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-02 08:51:26 -0600 |
commit | cf38c2cbc5875813fbb9858f45e5b95789b7ffea (patch) | |
tree | c345dc97de1c17488fe6c27697f48f0febae6de6 /tests/integration_tests/modules/test_combined.py | |
parent | a1cf55e5e6331b9b3a4f9ceb412dd14c78abb5ea (diff) | |
download | vyos-cloud-init-cf38c2cbc5875813fbb9858f45e5b95789b7ffea.tar.gz vyos-cloud-init-cf38c2cbc5875813fbb9858f45e5b95789b7ffea.zip |
Move GCE metadata fetch to init-local (SC-502) (#1122)
GCE currently fetches metadata after network has come up. There's no
reason we can't fetch at init-local time, so update GCE to fetch at
init-local time to be more performant and consistent with other
datasources.
Diffstat (limited to 'tests/integration_tests/modules/test_combined.py')
-rw-r--r-- | tests/integration_tests/modules/test_combined.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/integration_tests/modules/test_combined.py b/tests/integration_tests/modules/test_combined.py index bc19c2a2..758c96fa 100644 --- a/tests/integration_tests/modules/test_combined.py +++ b/tests/integration_tests/modules/test_combined.py @@ -209,6 +209,31 @@ class TestCombined: log = client.read_from_file('/var/log/cloud-init.log') verify_clean_log(log) + def test_correct_datasource_detected( + self, class_client: IntegrationInstance + ): + """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"] + ) + def _check_common_metadata(self, data): assert data['base64_encoded_keys'] == [] assert data['merged_cfg'] == 'redacted for non-root user' @@ -277,3 +302,19 @@ class TestCombined: assert v1_data['instance_id'] == client.instance.name assert v1_data['local_hostname'].startswith('ip-') assert v1_data['region'] == client.cloud.cloud_instance.region + + @pytest.mark.gce + def test_instance_json_gce(self, class_client: IntegrationInstance): + client = class_client + instance_json_file = client.read_from_file( + "/run/cloud-init/instance-data.json" + ) + data = json.loads(instance_json_file) + self._check_common_metadata(data) + v1_data = data["v1"] + assert v1_data["cloud_name"] == "gce" + assert v1_data["platform"] == "gce" + assert v1_data["subplatform"].startswith("metadata") + assert v1_data["availability_zone"] == client.instance.zone + assert v1_data["instance_id"] == client.instance.instance_id + assert v1_data["local_hostname"] == client.instance.name |