Skip to content

Commit b05965e

Browse files
committed
wrote basic (not yet working) test of functionality
1 parent 3443231 commit b05965e

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

env/integtest_tuning_agent.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,26 @@
55
ENV_INTEGTESTS_DBGYM_CONFIG_FPATH,
66
get_integtest_workspace_path,
77
)
8-
from env.tuning_agent import TuningAgent
8+
from env.tuning_agent import DBMSConfig, TuningAgent
99
from util.workspace import DBGymConfig
1010

1111

1212
class MockTuningAgent(TuningAgent):
13-
pass
13+
def __init__(self, *args, **kwargs) -> None:
14+
super().__init__(*args, **kwargs)
15+
self.config_to_return = None
16+
17+
def _step(self) -> DBMSConfig:
18+
ret = self.config_to_return
19+
assert ret is not None
20+
# This ensures you must set self.config_to_return every time
21+
ret = None
22+
return ret
1423

1524

1625
class PostgresConnTests(unittest.TestCase):
1726
dbgym_cfg: DBGymConfig
18-
27+
1928
@staticmethod
2029
def setUpClass() -> None:
2130
# If you're running the test locally, this check makes runs past the first one much faster.
@@ -26,7 +35,10 @@ def setUpClass() -> None:
2635

2736
def test_test(self) -> None:
2837
agent = MockTuningAgent(PostgresConnTests.dbgym_cfg)
38+
config_a = DBMSConfig(["a"], {"a": "a"}, {"a": ["a"]})
39+
agent.config_to_return = config_a
2940
agent.step()
41+
self.assertEqual(agent.get_past_config(0), config_a)
3042

3143

3244
if __name__ == "__main__":

env/tuning_agent.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ def step(self) -> None:
2626
# Subclasses should override this function.
2727
def _step(self) -> DBMSConfig:
2828
raise NotImplementedError
29+
30+
def get_past_config(self, step_num: int) -> DBMSConfig:
31+
assert step_num >= 0 and step_num < self.next_step_num

0 commit comments

Comments
 (0)