Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit testing CI #36

Merged
merged 12 commits into from
Jul 15, 2024
16 changes: 0 additions & 16 deletions .github/workflows/sanity_test.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/unittest_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Unit Tests

on:
push: {}
pull_request:
branches: [main]

jobs:
build:
runs-on: self-hosted

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

# We could choose to set up dependencies manually in the GHA runner instead of installing them during the GHA.
#
# However, I think it's better to do them in the GHA itself so that we're testing our dependency installation step
# in addition to our actual code. It also removes the need to manually reinstall dependencies on the GHA runners
# every time we add a new dependency.
#
# Note that the GHA runners are stateful. Dependencies installed from previous runs will still be on the runner.
# This means this step will usually be pretty fast as most dependencies will already be cached. However, it also
# means that past runs might interfere with the current run, so you sometimes may need to restart the GHA runners.
- name: Install dependencies
run: |
./dependency/install_dependencies.sh
. "$HOME/.cargo/env"

- name: Run unit tests
run: python scripts/run_unittests.py
2 changes: 1 addition & 1 deletion dependency/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# You may want to create a conda environment before doing this
pip install -r dependency/requirements.txt
cat dependency/apt_requirements.txt | xargs sudo apt-get install -y
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
7 changes: 5 additions & 2 deletions scripts/run_unittests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import unittest
import sys

if __name__ == "__main__":
loader = unittest.TestLoader()
suite = loader.discover(".")
print(f"suite={suite}")
runner = unittest.TextTestRunner()
runner.run(suite)
result = runner.run(suite)
if not result.wasSuccessful():
# This is needed so that the GHA fails if the unit tests fail.
sys.exit(1)
5 changes: 2 additions & 3 deletions tune/protox/env/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def __init__(
workload_timeout_penalty: float = 1.0,
logger: Optional[Logger] = None,
) -> None:

self.dbgym_cfg = dbgym_cfg
self.workload_path = workload_path
# Whether we should use benchbase or not.
Expand Down Expand Up @@ -257,7 +256,7 @@ def __init__(
sqls = [
(
line.split(",")[0],
Path(line.split(",")[1]),
self.workload_path / Path(line.split(",")[1]),
1.0,
)
for line in lines
Expand All @@ -271,7 +270,7 @@ def __init__(
sqls = [
(
split[0],
Path(split[1]),
self.workload_path / Path(split[1]),
float(split[2]),
)
for split in splits
Expand Down
4 changes: 2 additions & 2 deletions tune/protox/test/test_index_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class IndexSpaceTests(unittest.TestCase):
@staticmethod
def load(
config_path=Path("tune/protox/test/unittest_benchmark_configs/unittest_tpch.yaml"),
config_path=Path("tune/protox/test/unittest_benchmark_configs/unittest_tpch.yaml").resolve(),
aux_type=True,
aux_include=True,
):
Expand All @@ -27,7 +27,7 @@ def load(
tables=benchmark_config["tables"],
attributes=benchmark_config["attributes"],
query_spec=benchmark_config["query_spec"],
workload_path=Path("tune/protox/test/unittest_tpch_dir"),
workload_path=Path("tune/protox/test/unittest_tpch_dir").resolve(),
pid=None,
workload_timeout=0,
workload_timeout_penalty=1.0,
Expand Down
2 changes: 1 addition & 1 deletion tune/protox/test/test_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_ia(self):
IndexAction.index_counter = 0
self.assertEqual(
ia1.sql(add=True),
"CREATE INDEX index1 ON tbl USING btree (a,b,c) INCLUDE (d,e)",
"CREATE INDEX index0 ON tbl USING btree (a,b,c) INCLUDE (d,e)",
wangpatrick57 marked this conversation as resolved.
Show resolved Hide resolved
)

ia2 = IndexAction(
Expand Down
8 changes: 4 additions & 4 deletions tune/protox/test/test_workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_tpch(self):
for k, v in ref.items()
}

w, i = WorkloadTests.load("tune/protox/test/unittest_benchmark_configs/unittest_tpch.yaml", Path("tune/protox/test/unittest_tpch_dir"))
w, i = WorkloadTests.load("tune/protox/test/unittest_benchmark_configs/unittest_tpch.yaml", Path("tune/protox/test/unittest_tpch_dir").resolve())
self.assertEqual(i.class_mapping, ref)

def test_job(self):
Expand All @@ -68,7 +68,7 @@ def test_job(self):
for k, v in ref.items()
}

w, i = WorkloadTests.load("tune/protox/test/unittest_benchmark_configs/unittest_job_full.yaml", Path("tune/protox/test/unittest_job_full_dir"))
w, i = WorkloadTests.load("tune/protox/test/unittest_benchmark_configs/unittest_job_full.yaml", Path("tune/protox/test/unittest_job_full_dir").resolve())
self.assertEqual(i.class_mapping, ref)

def test_dsb(self):
Expand All @@ -80,7 +80,7 @@ def test_dsb(self):
for k, v in ref.items()
}

w, i = WorkloadTests.load("tune/protox/test/unittest_benchmark_configs/unittest_dsb.yaml", Path("tune/protox/test/unittest_dsb_dir"))
w, i = WorkloadTests.load("tune/protox/test/unittest_benchmark_configs/unittest_dsb.yaml", Path("tune/protox/test/unittest_dsb_dir").resolve())
self.diff_classmapping(ref, i.class_mapping)

def test_tpcc(self):
Expand All @@ -92,7 +92,7 @@ def test_tpcc(self):
for k, v in ref.items()
}

w, i = WorkloadTests.load("tune/protox/test/unittest_benchmark_configs/unittest_tpcc.yaml", Path("tune/protox/test/unittest_tpcc_dir"))
w, i = WorkloadTests.load("tune/protox/test/unittest_benchmark_configs/unittest_tpcc.yaml", Path("tune/protox/test/unittest_tpcc_dir").resolve())
self.assertEqual(i.class_mapping, ref)


Expand Down
Loading