From 5a85c6ae7fed8696650e817a84152e79068af145 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 8 Jul 2024 00:22:13 +0000 Subject: [PATCH 01/11] added basic unittest ci --- .github/workflows/{sanity_test.yml => unittest_ci.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{sanity_test.yml => unittest_ci.yml} (70%) diff --git a/.github/workflows/sanity_test.yml b/.github/workflows/unittest_ci.yml similarity index 70% rename from .github/workflows/sanity_test.yml rename to .github/workflows/unittest_ci.yml index 8cefe9f0..c0868738 100644 --- a/.github/workflows/sanity_test.yml +++ b/.github/workflows/unittest_ci.yml @@ -1,4 +1,4 @@ -name: Example CI +name: CI for Unit Tests on: push: {} @@ -13,4 +13,4 @@ jobs: - uses: actions/checkout@v2 - name: Run a script - run: echo Hello, world! + run: python scripts/run_unittests.py From fe48706c2b2414e41a75404c5bdb8ac76f597efa Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 8 Jul 2024 00:24:56 +0000 Subject: [PATCH 02/11] now downloading python --- .github/workflows/unittest_ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/unittest_ci.yml b/.github/workflows/unittest_ci.yml index c0868738..25fb2e08 100644 --- a/.github/workflows/unittest_ci.yml +++ b/.github/workflows/unittest_ci.yml @@ -12,5 +12,10 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Run a script run: python scripts/run_unittests.py From 1499665d1bf19a08cf94205b6cf459b71c69d4c7 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 8 Jul 2024 00:25:27 +0000 Subject: [PATCH 03/11] fixed tab --- .github/workflows/unittest_ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unittest_ci.yml b/.github/workflows/unittest_ci.yml index 25fb2e08..5ce6fad9 100644 --- a/.github/workflows/unittest_ci.yml +++ b/.github/workflows/unittest_ci.yml @@ -13,9 +13,9 @@ jobs: - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' + uses: actions/setup-python@v4 + with: + python-version: '3.10' - name: Run a script run: python scripts/run_unittests.py From 9bfbc8d468503c4301a2c691be905dcc7d808d15 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 8 Jul 2024 00:27:56 +0000 Subject: [PATCH 04/11] now exiting with code 1 if unit tests fail --- scripts/run_unittests.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/run_unittests.py b/scripts/run_unittests.py index bbd74cb5..53c2edfb 100644 --- a/scripts/run_unittests.py +++ b/scripts/run_unittests.py @@ -1,8 +1,12 @@ 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) From 4444bfe0b600c811656735702539b981150bde00 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 8 Jul 2024 00:30:31 +0000 Subject: [PATCH 05/11] now installing dependencies --- .github/workflows/unittest_ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unittest_ci.yml b/.github/workflows/unittest_ci.yml index 5ce6fad9..53e2e3ac 100644 --- a/.github/workflows/unittest_ci.yml +++ b/.github/workflows/unittest_ci.yml @@ -12,10 +12,18 @@ jobs: steps: - uses: actions/checkout@v2 + # We could choose to set up dependencies manually in the GHA runner. + # + # 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. - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.10' - - name: Run a script + - name: Install dependencies + run: ./dependency/install_dependencies.sh + + - name: Run unit tests run: python scripts/run_unittests.py From 4ead1a159bb143f35f28372de077cd089fa01bf1 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 8 Jul 2024 00:38:24 +0000 Subject: [PATCH 06/11] made rust installation non-interactive and added . '/home/phw2/.cargo/env' --- .github/workflows/unittest_ci.yml | 10 ++++++++-- dependency/install_dependencies.sh | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unittest_ci.yml b/.github/workflows/unittest_ci.yml index 53e2e3ac..ed6956ea 100644 --- a/.github/workflows/unittest_ci.yml +++ b/.github/workflows/unittest_ci.yml @@ -12,18 +12,24 @@ jobs: steps: - uses: actions/checkout@v2 - # We could choose to set up dependencies manually in the GHA runner. + # 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. + # + # This also removes the need to manually reinstall dependencies on + # the GHA runners every time we add a new dependency. - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.10' - name: Install dependencies - run: ./dependency/install_dependencies.sh + run: | + ./dependency/install_dependencies.sh + . "$HOME/.cargo/env" - name: Run unit tests run: python scripts/run_unittests.py diff --git a/dependency/install_dependencies.sh b/dependency/install_dependencies.sh index 8a516880..ee2e3d85 100755 --- a/dependency/install_dependencies.sh +++ b/dependency/install_dependencies.sh @@ -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 \ No newline at end of file +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ No newline at end of file From ffba4f873fd5430247640a4f2307af11366dc62f Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 8 Jul 2024 00:41:19 +0000 Subject: [PATCH 07/11] added longer comment about dependencies in the GHA --- .github/workflows/unittest_ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/unittest_ci.yml b/.github/workflows/unittest_ci.yml index ed6956ea..7855fb01 100644 --- a/.github/workflows/unittest_ci.yml +++ b/.github/workflows/unittest_ci.yml @@ -1,4 +1,4 @@ -name: CI for Unit Tests +name: Unit Tests on: push: {} @@ -12,20 +12,20 @@ jobs: steps: - uses: actions/checkout@v2 - # 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. - # - # This also removes the need to manually reinstall dependencies on - # the GHA runners every time we add a new dependency. - 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 From 92b265fcd5e00173faf32d901749f95ab3a6e559 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 8 Jul 2024 00:49:08 +0000 Subject: [PATCH 08/11] fixed test_workload by making paths absolute --- tune/protox/env/workload.py | 5 ++--- tune/protox/test/test_workload.py | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tune/protox/env/workload.py b/tune/protox/env/workload.py index 2b3c7e8c..5d646f54 100644 --- a/tune/protox/env/workload.py +++ b/tune/protox/env/workload.py @@ -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. @@ -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 @@ -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 diff --git a/tune/protox/test/test_workload.py b/tune/protox/test/test_workload.py index a1e4b97c..71ff10f3 100644 --- a/tune/protox/test/test_workload.py +++ b/tune/protox/test/test_workload.py @@ -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): @@ -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): @@ -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): @@ -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) From ea865d16cdcbbc98a10fb2809832105fcd779bfb Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 8 Jul 2024 00:51:23 +0000 Subject: [PATCH 09/11] fixed test_index_space: --- tune/protox/test/test_index_space.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tune/protox/test/test_index_space.py b/tune/protox/test/test_index_space.py index 2884f758..176ec82d 100644 --- a/tune/protox/test/test_index_space.py +++ b/tune/protox/test/test_index_space.py @@ -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, ): @@ -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, From 340c84f164dd67d8cee292acec2fefe09f2151eb Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 8 Jul 2024 00:54:13 +0000 Subject: [PATCH 10/11] fixed test_primitive. it had a benign bug because I started counting indexes from 0 instead of 1 --- scripts/run_unittests.py | 1 - tune/protox/test/test_primitive.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/run_unittests.py b/scripts/run_unittests.py index 53c2edfb..56aadd28 100644 --- a/scripts/run_unittests.py +++ b/scripts/run_unittests.py @@ -4,7 +4,6 @@ if __name__ == "__main__": loader = unittest.TestLoader() suite = loader.discover(".") - print(f"suite={suite}") runner = unittest.TextTestRunner() result = runner.run(suite) if not result.wasSuccessful(): diff --git a/tune/protox/test/test_primitive.py b/tune/protox/test/test_primitive.py index 9469ffea..f9c2bd29 100644 --- a/tune/protox/test/test_primitive.py +++ b/tune/protox/test/test_primitive.py @@ -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)", ) ia2 = IndexAction( From 8173db013e25d692b6983dc17dc7b0bdca13ef44 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 15 Jul 2024 00:27:26 +0000 Subject: [PATCH 11/11] renamed dependency -> dependencies in code --- .github/workflows/unittest_ci.yml | 2 +- dependencies/install_dependencies.sh | 4 ++-- dependencies/rust.sh | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) delete mode 100755 dependencies/rust.sh diff --git a/.github/workflows/unittest_ci.yml b/.github/workflows/unittest_ci.yml index 7855fb01..0c088c98 100644 --- a/.github/workflows/unittest_ci.yml +++ b/.github/workflows/unittest_ci.yml @@ -28,7 +28,7 @@ jobs: # 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 + ./dependencies/install_dependencies.sh . "$HOME/.cargo/env" - name: Run unit tests diff --git a/dependencies/install_dependencies.sh b/dependencies/install_dependencies.sh index ee2e3d85..da6c7bad 100755 --- a/dependencies/install_dependencies.sh +++ b/dependencies/install_dependencies.sh @@ -1,5 +1,5 @@ #!/bin/bash # 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 +pip install -r dependencies/requirements.txt +cat dependencies/apt_requirements.txt | xargs sudo apt-get install -y curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ No newline at end of file diff --git a/dependencies/rust.sh b/dependencies/rust.sh deleted file mode 100755 index 9af316fc..00000000 --- a/dependencies/rust.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh \ No newline at end of file