From e712984c15391ceff39e1d073ae01ca145940e55 Mon Sep 17 00:00:00 2001 From: Krzysztof Date: Wed, 26 Aug 2015 15:35:33 +0200 Subject: [PATCH] Update test_frontend.py --- .../autoscaler/demo/tests/test_frontend.py | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/compute/autoscaler/demo/tests/test_frontend.py b/compute/autoscaler/demo/tests/test_frontend.py index a5158d9c6dc0..702371500b1d 100644 --- a/compute/autoscaler/demo/tests/test_frontend.py +++ b/compute/autoscaler/demo/tests/test_frontend.py @@ -19,8 +19,7 @@ class FakeTime(object): - """Fake implementations of GetWallTime, GetUserCpuTime and BusyWait. - + """Fake implementations of GetUserCpuTime, GetUserCpuTime and BusyWait. Each call to BusyWait advances both the cpu and the wall clocks by fixed intervals (cpu_time_step and wall_time_step, respectively). This can be used to simulate arbitrary fraction of CPU time available to the process. @@ -31,13 +30,13 @@ def __init__(self, cpu_time_step=1.0, wall_time_step=1.0): self.cpu_time_step = cpu_time_step self.wall_time_step = wall_time_step - def GetWallTime(self): + def get_walltime(self): return self.wall_time - def GetUserCpuTime(self): + def get_user_cputime(self): return self.cpu_time - def BusyWait(self): + def busy_wait(self): self.wall_time += self.wall_time_step self.cpu_time += self.cpu_time_step @@ -46,24 +45,24 @@ class TestHandlers(unittest.TestCase): def setUp(self): self.fake_time = FakeTime() self.cpu_burner = frontend.CpuBurner() - self.cpu_burner.GetUserCpuTime = self.fake_time.GetUserCpuTime - self.cpu_burner.GetWallTime = self.fake_time.GetWallTime - self.cpu_burner.BusyWait = self.fake_time.BusyWait + self.cpu_burner.get_user_cputime = self.fake_time.get_user_cputime + self.cpu_burner.get_walltime = self.fake_time.get_walltime + self.cpu_burner.busy_wait = self.fake_time.busy_wait - # In this test scenario CPU time advances at 25% of the wall clock rate. + # In this test scenario CPU time advances at 25% of the wall time speed. # Given the request requires 1 CPU core second, we expect it to finish # within the timeout (5 seconds) and return success. def test_ok_response(self): self.fake_time.cpu_time_step = 0.25 - (code, _) = self.cpu_burner.HandleHttpRequest() + (code, _) = self.cpu_burner.handle_http_request() self.assertEqual(200, code) - # In this test scenario CPU time advances at 15% of the wall clock rate. + # In this test scenario CPU time advances at 15% of the wall time speed. # Given the request requires 1 CPU core second, we expect it to timeout - # after 5 simulated wall time seconds and return HTTP error 500. + # after 5 simulated wall time seconds and return error 500. def test_timeout(self): self.fake_time.cpu_time_step = 0.15 - (code, _) = self.cpu_burner.HandleHttpRequest() + (code, _) = self.cpu_burner.handle_http_request() self.assertEqual(500, code)