Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathconftest.py
More file actions
Latest commit
77 lines (56 loc) · 2.46 KB
/
Copy pathconftest.py
File metadata and controls
77 lines (56 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
importjson
importos
importpytest
def_test_config_from_file():
"""Connection details from the JSON file named by ``DATABRICKS_TEST_CONFIG_FILE``,
or ``{}`` when the variable is unset/empty/unreadable.
Why this indirection exists: the engineer-bot (databricks-bot-engine) runs
this e2e suite inside an agent-driven subprocess whose environment has every
credential-shaped variable — anything matching ``*TOKEN*`` / ``*SECRET*`` /
``*PASSWORD*`` etc. — stripped for safety (the engine's ``shared/env_scrub.py``).
``DATABRICKS_TOKEN`` is therefore removed before pytest starts, so the token
can't reach the agent's test run as a plain env var. The bot instead writes the
connection details (token included) to a file and points at it with
``DATABRICKS_TEST_CONFIG_FILE`` — a name the scrub deliberately preserves.
Normal CI (and local dev) leaves the variable unset, so this returns ``{}`` and
every fixture below resolves purely from its env var, unchanged.
"""
path=os.getenv("DATABRICKS_TEST_CONFIG_FILE")
ifnotpath:
return {}
try:
withopen(path) asf:
returnjson.load(f)
except (OSError, ValueError):
return {}
@pytest.fixture(scope="session")
def_test_config():
return_test_config_from_file()
@pytest.fixture(scope="session")
defhost(_test_config):
returnos.getenv("DATABRICKS_SERVER_HOSTNAME") or_test_config.get("host")
@pytest.fixture(scope="session")
defhttp_path(_test_config):
returnos.getenv("DATABRICKS_HTTP_PATH") or_test_config.get("http_path")
@pytest.fixture(scope="session")
defaccess_token(_test_config):
returnos.getenv("DATABRICKS_TOKEN") or_test_config.get("access_token")
@pytest.fixture(scope="session")
defingestion_user(_test_config):
returnos.getenv("DATABRICKS_USER") or_test_config.get("ingestion_user")
@pytest.fixture(scope="session")
defcatalog(_test_config):
returnos.getenv("DATABRICKS_CATALOG") or_test_config.get("catalog")
@pytest.fixture(scope="session")
defschema(_test_config):
returnos.getenv("DATABRICKS_SCHEMA") or_test_config.get("schema") or"default"
@pytest.fixture(scope="session", autouse=True)
defconnection_details(host, http_path, access_token, ingestion_user, catalog, schema):
return {
"host": host,
"http_path": http_path,
"access_token": access_token,
"ingestion_user": ingestion_user,
"catalog": catalog,
"schema": schema,
}