From 079622e0b69ec1e5c50af08c8312937609929233 Mon Sep 17 00:00:00 2001 From: "Lovett, Trevor" Date: Tue, 3 Dec 2019 15:18:03 -0600 Subject: [VVP] Support pluggable data sources for preload data Change-Id: Ia7fcfa25203a93eac93381f472e3ba1e6c11235f Issue-ID: VVP-339 Signed-off-by: Lovett, Trevor --- .../app_tests/preload_tests/test_grapi.py | 32 ++++++++++++++-------- .../app_tests/preload_tests/test_vnfapi.py | 27 ++++++------------ 2 files changed, 29 insertions(+), 30 deletions(-) (limited to 'ice_validator/app_tests/preload_tests') diff --git a/ice_validator/app_tests/preload_tests/test_grapi.py b/ice_validator/app_tests/preload_tests/test_grapi.py index 99498ec..10b090d 100644 --- a/ice_validator/app_tests/preload_tests/test_grapi.py +++ b/ice_validator/app_tests/preload_tests/test_grapi.py @@ -41,7 +41,7 @@ from shutil import rmtree import pytest -from preload.environment import PreloadEnvironment +from preload.environment import EnvironmentFileDataSource from preload.model import Vnf, get_heat_templates from preload_grapi import GrApiPreloadGenerator from tests.helpers import first @@ -78,21 +78,28 @@ def preload(pytestconfig, session_dir): pytestconfig.getoption = fake_getoption templates = get_heat_templates(pytestconfig) - env = PreloadEnvironment(THIS_DIR / "sample_env") vnf = Vnf(templates) - generator = GrApiPreloadGenerator(vnf, session_dir, env) + datasource = EnvironmentFileDataSource(THIS_DIR / "sample_env") + generator = GrApiPreloadGenerator(vnf, session_dir, datasource) generator.generate() return session_dir @pytest.fixture(scope="session") def base(preload): - return load_module(preload, "base_incomplete.json") + return load_module(preload, "base.json") @pytest.fixture(scope="session") def incremental(preload): - return load_module(preload, "incremental_incomplete.json") + return load_module(preload, "incremental.json") + + +def test_incomplete_filenames(preload): + base = THIS_DIR / "sample_env/preloads/grapi/base_incomplete.json" + inc = THIS_DIR / "sample_env/preloads/grapi/incremental_incomplete.json" + assert base.exists() + assert inc.exists() def test_base_fields(base): @@ -122,7 +129,9 @@ def test_base_networks(base): assert oam == { "network-role": "oam", "network-name": "VALUE FOR: network name of oam_net_id", - "subnets-data": {"subnet-data": [{"subnet-id": "VALUE FOR: oam_subnet_id"}]}, + "subnets-data": { + "subnet-data": [{"subnet-name": "VALUE FOR: name of oam_subnet_id"}] + }, } @@ -141,6 +150,7 @@ def test_base_vm_types(base): "vm-network": [ { "network-role": "oam", + "network-role-tag": "oam", "network-information-items": { "network-information-item": [ { @@ -168,17 +178,18 @@ def test_base_vm_types(base): }, { "network-role": "ha", + "network-role-tag": "ha", "network-information-items": { "network-information-item": [ { "ip-version": "4", - "use-dhcp": "N", + "use-dhcp": "Y", "ip-count": 0, "network-ips": {"network-ip": []}, }, { "ip-version": "6", - "use-dhcp": "N", + "use-dhcp": "Y", "ip-count": 0, "network-ips": {"network-ip": []}, }, @@ -210,10 +221,7 @@ def test_base_parameters(base): params = base["input"]["preload-vf-module-topology-information"][ "vf-module-topology" ]["vf-module-parameters"]["param"] - assert params == [ - {"name": "db_vol0_id", "value": "VALUE FOR: db_vol0_id"}, - {"name": "db_vol1_id", "value": "VALUE FOR: db_vol1_id"}, - ] + assert params == [] def test_incremental(incremental): diff --git a/ice_validator/app_tests/preload_tests/test_vnfapi.py b/ice_validator/app_tests/preload_tests/test_vnfapi.py index a49043f..312c418 100644 --- a/ice_validator/app_tests/preload_tests/test_vnfapi.py +++ b/ice_validator/app_tests/preload_tests/test_vnfapi.py @@ -41,7 +41,7 @@ from shutil import rmtree import pytest from app_tests.preload_tests.test_grapi import load_json -from preload.environment import PreloadEnvironment +from preload.environment import EnvironmentFileDataSource from preload.model import Vnf, get_heat_templates from preload_vnfapi import VnfApiPreloadGenerator from tests.helpers import load_yaml, first @@ -74,20 +74,20 @@ def preload(pytestconfig, session_dir): pytestconfig.getoption = fake_getoption templates = get_heat_templates(pytestconfig) vnf = Vnf(templates) - preload_env = PreloadEnvironment(THIS_DIR / "sample_env") - generator = VnfApiPreloadGenerator(vnf, session_dir, preload_env) + datasource = EnvironmentFileDataSource(THIS_DIR / "sample_env") + generator = VnfApiPreloadGenerator(vnf, session_dir, datasource) generator.generate() return session_dir @pytest.fixture(scope="session") def base(preload): - return load_module(preload, "base_incomplete.json") + return load_module(preload, "base.json") @pytest.fixture(scope="session") def incremental(preload): - return load_module(preload, "incremental_incomplete.json") + return load_module(preload, "incremental.json") def test_base_azs(base): @@ -106,13 +106,13 @@ def test_base_networks(base): { "network-role": "oam", "network-name": "VALUE FOR: network name for oam_net_id", - "subnet-id": "oam_subnet_id", + "subnet-name": "VALUE FOR: name for oam_subnet_id", }, {"network-role": "ha", "network-name": "VALUE FOR: network name for ha_net_id"}, { "network-role": "ctrl", "network-name": "VALUE FOR: network name for ctrl_net_id", - "subnet-id": "ctrl_subnet_id", + "subnet-name": "VALUE FOR: name for ctrl_subnet_id", }, ] @@ -154,7 +154,7 @@ def test_base_vm_types(base): "network-ips-v6": [], "network-macs": [], "interface-route-prefixes": [], - "use-dhcp": "N", + "use-dhcp": "Y", }, ], } @@ -162,16 +162,7 @@ def test_base_vm_types(base): def test_base_parameters(base): params = base["input"]["vnf-topology-information"]["vnf-parameters"] - assert params == [ - { - "vnf-parameter-name": "db_vol0_id", - "vnf-parameter-value": "VALUE FOR: db_vol0_id", - }, - { - "vnf-parameter-name": "db_vol1_id", - "vnf-parameter-value": "VALUE FOR: db_vol1_id", - }, - ] + assert params == [] def test_incremental(incremental): -- cgit 1.2.3-korg