Runner instantiated wrong class.
Details
Details
Diff Detail
Diff Detail
- Repository
- rLTRN libtaskotron
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
kparal | |
jskladan |
Runner instantiated wrong class.
muanual test
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | libtaskotron/runner.py (2 lines) | |||
M | testing/test_runner.py (18 lines) |
Commit | Tree | Parents | Author | Summary | Date |
---|---|---|---|---|---|
3b995546cc7b | 1635936a2d37 | 3900f18a444d | Lukas Brabec | test polish | Jul 22 2015, 12:54 PM |
3900f18a444d | 9d0b01a2ac3b | cc2a8ca851d8 | Lukas Brabec | unit test | Jul 22 2015, 12:42 PM |
cc2a8ca851d8 | b36d8f2eda8c | aa0b7e587ea3 | Lukas Brabec | Runner fix (Show More…) | Jul 22 2015, 12:24 PM |
Show First 20 Lines • Show All 350 Lines • ▼ Show 20 Line(s) | 350 | else: | |||
---|---|---|---|---|---|
351 | self._run_locally() | 351 | self._run_locally() | ||
352 | 352 | | |||
353 | def _run_locally(self): | 353 | def _run_locally(self): | ||
354 | '''Init environment, instantiate LocalRunner and run it.''' | 354 | '''Init environment, instantiate LocalRunner and run it.''' | ||
355 | 355 | | |||
356 | filelog_path = os.path.join(self.uuid_dir, 'taskotron.log') | 356 | filelog_path = os.path.join(self.uuid_dir, 'taskotron.log') | ||
357 | logger.add_filehandler(filelog_path=filelog_path, remove_mem_handler=True) | 357 | logger.add_filehandler(filelog_path=filelog_path, remove_mem_handler=True) | ||
358 | # run the task locally | 358 | # run the task locally | ||
359 | task_runner = Runner(self.task_data, self.arg_data) | 359 | task_runner = LocalRunner(self.task_data, self.arg_data) | ||
360 | task_runner.run() | 360 | task_runner.run() | ||
361 | 361 | | |||
362 | def _run_remotely(self): | 362 | def _run_remotely(self): | ||
363 | '''Init environment, instantiate RemoteRunner and run it.''' | 363 | '''Init environment, instantiate RemoteRunner and run it.''' | ||
364 | 364 | | |||
365 | filelog_path = os.path.join(self.uuid_dir, 'taskotron-initiator.log') | 365 | filelog_path = os.path.join(self.uuid_dir, 'taskotron-initiator.log') | ||
366 | logger.add_filehandler(filelog_path=filelog_path, remove_mem_handler=True) | 366 | logger.add_filehandler(filelog_path=filelog_path, remove_mem_handler=True) | ||
367 | log.info("Running Task in VM") | 367 | log.info("Running Task in VM") | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |
Show First 20 Lines • Show All 541 Lines • ▼ Show 20 Line(s) | 541 | ref_taskdata = { | |||
---|---|---|---|---|---|
542 | 'environment': {'machine': 'HAL9000', 'rpm': ['foo', 'bar']} | 542 | 'environment': {'machine': 'HAL9000', 'rpm': ['foo', 'bar']} | ||
543 | } | 543 | } | ||
544 | 544 | | |||
545 | test_runner = runner.Runner(ref_taskdata, ref_inputdata, self.uuid_dir) | 545 | test_runner = runner.Runner(ref_taskdata, ref_inputdata, self.uuid_dir) | ||
546 | 546 | | |||
547 | test_runner.run() | 547 | test_runner.run() | ||
548 | 548 | | |||
549 | assert len(self.stub_local.calls()) == 1 and len(self.stub_remote.calls()) == 0 | 549 | assert len(self.stub_local.calls()) == 1 and len(self.stub_remote.calls()) == 0 | ||
550 | | ||||
551 | | ||||
552 | class TestRunnerLocalRunner(): | ||||
553 | def test_local_runner_used(self, monkeypatch): | ||||
554 | ref_inputdata = {'local': True} | ||||
555 | ref_taskdata = { | ||||
556 | 'environment': {'machine': 'HAL9000', 'rpm': ['foo', 'bar']} | ||||
557 | } | ||||
558 | uuid_dir = '/something/totally/random' | ||||
559 | stub_local_runner = Dingus() | ||||
560 | monkeypatch.setattr(runner, 'LocalRunner', stub_local_runner) | ||||
561 | | ||||
562 | test_runner = runner.Runner(ref_taskdata, ref_inputdata, uuid_dir) | ||||
563 | | ||||
564 | test_runner.run() | ||||
565 | | ||||
566 | # check that LocalRunner was instantiated | ||||
567 | assert len(stub_local_runner.calls()) == 1 |