|
28 | 28 | from saltext.vmware.utils.connect import get_service_instance |
29 | 29 |
|
30 | 30 |
|
31 | | -@pytest.fixture(scope="package") |
| 31 | +@pytest.fixture(scope="session") |
32 | 32 | 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()) |
33 | 43 | with master.started(): |
34 | 44 | yield master |
35 | 45 |
|
36 | 46 |
|
37 | | -@pytest.fixture(scope="package") |
| 47 | +@pytest.fixture(scope="session") |
38 | 48 | def minion(minion): |
39 | 49 | with minion.started(): |
| 50 | + minion.salt_call_cli().run("saltutil.refresh_pillar") |
40 | 51 | yield minion |
41 | 52 |
|
42 | 53 |
|
43 | | -@pytest.fixture |
| 54 | +@pytest.fixture(scope="session") |
44 | 55 | def salt_run_cli(master): |
45 | 56 | return master.salt_run_cli() |
46 | 57 |
|
47 | 58 |
|
48 | | -@pytest.fixture |
| 59 | +@pytest.fixture(scope="session") |
49 | 60 | def salt_cli(master): |
50 | 61 | return master.get_salt_cli() |
51 | 62 |
|
52 | 63 |
|
53 | | -@pytest.fixture |
| 64 | +@pytest.fixture(scope="session") |
54 | 65 | def salt_call_cli(minion): |
55 | 66 | return minion.salt_call_cli() |
56 | 67 |
|
57 | 68 |
|
58 | | -@pytest.fixture(scope="session") |
| 69 | +@pytest.fixture |
59 | 70 | 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") |
72 | 72 |
|
73 | 73 |
|
74 | 74 | @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 |
77 | 77 | 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) |
79 | 79 | return si |
80 | 80 | except Exception as e: # pylint: disable=broad-except |
81 | 81 | pytest.skip(f"Unable to create service instance from config. Error = {e}") |
|
0 commit comments