Skip to content

Commit 7fe6e9b

Browse files
authored
Convert to use real .sls file for service instance (#344)
Previously we were building a config file. Now we're going to read `local/vcenter.sls` and use that, if it's found.
1 parent 4106f17 commit 7fe6e9b

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ def salt_factories_config():
2828
}
2929

3030

31-
@pytest.fixture(scope="package")
31+
@pytest.fixture(scope="session")
3232
def master(salt_factories):
3333
return salt_factories.salt_master_daemon(
3434
random_string("master-"), defaults={"enable_fqdns_grains": False}
3535
)
3636

3737

38-
@pytest.fixture(scope="package")
38+
@pytest.fixture(scope="session")
3939
def minion(master):
4040
return master.salt_minion_daemon(
4141
random_string("minion-"), defaults={"enable_fqdns_grains": False}

tests/integration/conftest.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,54 +28,54 @@
2828
from saltext.vmware.utils.connect import get_service_instance
2929

3030

31-
@pytest.fixture(scope="package")
31+
@pytest.fixture(scope="session")
3232
def master(master):
33+
default_path = Path(__file__).parent.parent.parent / "local" / "vcenter.sls"
34+
default_path = (
35+
default_path
36+
if default_path.exists()
37+
else Path(__file__).parent.parent.parent / "local" / "vcenter.conf"
38+
)
39+
config_path = Path(os.environ.get("VCENTER_CONFIG", default_path))
40+
pillar_path = master.pillar_tree.base.paths[0]
41+
(pillar_path / "top.sls").write_text('base:\n "*":\n - vcenter')
42+
(pillar_path / "vcenter.sls").write_bytes(config_path.read_bytes())
3343
with master.started():
3444
yield master
3545

3646

37-
@pytest.fixture(scope="package")
47+
@pytest.fixture(scope="session")
3848
def minion(minion):
3949
with minion.started():
50+
minion.salt_call_cli().run("saltutil.refresh_pillar")
4051
yield minion
4152

4253

43-
@pytest.fixture
54+
@pytest.fixture(scope="session")
4455
def salt_run_cli(master):
4556
return master.salt_run_cli()
4657

4758

48-
@pytest.fixture
59+
@pytest.fixture(scope="session")
4960
def salt_cli(master):
5061
return master.get_salt_cli()
5162

5263

53-
@pytest.fixture
64+
@pytest.fixture(scope="session")
5465
def salt_call_cli(minion):
5566
return minion.salt_call_cli()
5667

5768

58-
@pytest.fixture(scope="session")
69+
@pytest.fixture
5970
def integration_test_config():
60-
# Most of the values in the vcenter config are pulled using the vcenter
61-
# credentials *in* the vcenter config, and are populated via a manual call
62-
# to tools/test_value_scraper.py.
63-
# This is not ideal.
64-
default_path = Path(__file__).parent.parent.parent / "local" / "vcenter.conf"
65-
config_path = Path(os.environ.get("VCENTER_CONFIG", default_path))
66-
67-
try:
68-
with config_path.open() as f:
69-
return json.load(f)
70-
except Exception as e: # pylint: disable=broad-except
71-
return None
71+
pytest.skip("TODO stop using integration test config")
7272

7373

7474
@pytest.fixture(scope="session")
75-
def service_instance(integration_test_config):
76-
config = integration_test_config
75+
def service_instance(salt_call_cli):
76+
config = salt_call_cli.run("pillar.items").json
7777
try:
78-
si = get_service_instance(config={"saltext.vmware": config.copy()} if config else None)
78+
si = get_service_instance(config=config if config else None)
7979
return si
8080
except Exception as e: # pylint: disable=broad-except
8181
pytest.skip(f"Unable to create service instance from config. Error = {e}")

0 commit comments

Comments
 (0)