Skip to content

Commit

Permalink
DBGYM_CONFIG_PATH is now only set in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
wangpatrick57 committed Dec 26, 2024
1 parent 723a72a commit 2a5ead1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
# Integration tests do require external systems to be running (most commonly a database instance).
# Unlike end-to-end tests though, they test a specific module in a detailed manner, much like a unit test does.
env:
# We set `INTENDED_DBDATA_HARDWARE` so that it's seen when `integtest_pg_conn.py` executes `set_up_gymlib_integtest_workspace.sh`.
# We set `INTENDED_DBDATA_HARDWARE` so that it's seen when `integtest_pg_conn.py` executes `_set_up_gymlib_integtest_workspace.sh`.
INTENDED_DBDATA_HARDWARE: ssd
run: |
. "$HOME/.cargo/env"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

# DO NOT RUN THIS SCRIPT DIRECTLY.
# This script only runs correctly when run by GymlibIntegtestManager.set_up_workspace() as it sets the necessary envvars.
# By allowing GymlibIntegtestManager.set_up_workspace() to set the envvars, we ensure that the envvars are only defined
# in a single location (inside GymlibIntegtestManager).

# Gymlib integration tests relies on Postgres being built and workloads/dbdata being generated.
# Generating these things is not considered a part of the test which is why it's in its own shell script.
# The reason there's a shell script generating them instead of them just being in the repo is because (a)
Expand All @@ -10,8 +15,6 @@ set -euo pipefail

# INTENDED_DBDATA_HARDWARE can be set elsewhere (e.g. by tests_ci.yaml) but we use hdd by default.
INTENDED_DBDATA_HARDWARE="${INTENDED_DBDATA_HARDWARE:-hdd}"
export DBGYM_CONFIG_PATH=env/tests/gymlib_integtest_dbgym_config.yaml # Note that this envvar needs to be exported.
WORKSPACE_PATH=$(grep 'dbgym_workspace_path:' $DBGYM_CONFIG_PATH | sed 's/dbgym_workspace_path: //')

python3 task.py benchmark $BENCHMARK data $SCALE_FACTOR
python3 task.py benchmark $BENCHMARK workload --scale-factor $SCALE_FACTOR
Expand Down
12 changes: 7 additions & 5 deletions env/tests/integtest_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,30 @@ class GymlibIntegtestManager:
inside a class makes it clear that they are related to the gymlib integration tests.
"""

# These constants are also used by set_up_gymlib_integtest_workspace.sh.
# These constants are also used by _set_up_gymlib_integtest_workspace.sh.
BENCHMARK = "tpch"
SCALE_FACTOR = 0.01
# TODO: make DBGYM_CONFIG_FPATH an envvar.
DBGYM_CONFIG_FPATH = Path("env/tests/gymlib_integtest_dbgym_config.yaml")
DBGYM_CONFIG_PATH = Path("env/tests/gymlib_integtest_dbgym_config.yaml")

# This is set at most once by set_up_workspace().
DBGYM_WORKSPACE: Optional[DBGymWorkspace] = None

@staticmethod
def set_up_workspace() -> None:
workspace_path = get_workspace_path_from_config(
GymlibIntegtestManager.DBGYM_CONFIG_FPATH
GymlibIntegtestManager.DBGYM_CONFIG_PATH
)

# This if statement prevents us from setting up the workspace twice, which saves time.
if not workspace_path.exists():
subprocess.run(
["./env/tests/set_up_gymlib_integtest_workspace.sh"],
["./env/tests/_set_up_gymlib_integtest_workspace.sh"],
env={
"BENCHMARK": GymlibIntegtestManager.BENCHMARK,
"SCALE_FACTOR": str(GymlibIntegtestManager.SCALE_FACTOR),
# By setting this envvar, we ensure that when running _set_up_gymlib_integtest_workspace.sh,
# make_standard_dbgym_workspace() will use the correct DBGYM_CONFIG_PATH.
"DBGYM_CONFIG_PATH": str(GymlibIntegtestManager.DBGYM_CONFIG_PATH),
**os.environ,
},
check=True,
Expand Down
1 change: 1 addition & 0 deletions util/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ def make_standard_dbgym_workspace() -> DBGymWorkspace:
default path of dbgym_config.yaml.
"""
dbgym_config_path = Path(os.getenv("DBGYM_CONFIG_PATH", "dbgym_config.yaml"))
assert dbgym_config_path == Path("env/tests/gymlib_integtest_dbgym_config.yaml")
dbgym_workspace_path = get_workspace_path_from_config(dbgym_config_path)
dbgym_workspace = DBGymWorkspace(dbgym_workspace_path)
return dbgym_workspace
Expand Down

0 comments on commit 2a5ead1

Please sign in to comment.