예제 #1
0
    def test_repr(self):
        request_mock = MagicMock()
        to_string_mock = MagicMock()
        info = AppDryRunInfo(request_mock, to_string_mock)
        info.__repr__()
        self.assertEqual(request_mock, info.request)

        to_string_mock.assert_called_once_with(request_mock)
예제 #2
0
 def test_schedule_fail(self, record_tsm_mock):
     app_info = AppDryRunInfo("test", lambda x: "test")
     app_info._scheduler = "default"
     cfg = RunConfig({"image_fetcher": "dir"})
     app_info._cfg = cfg
     session = DummySession("test_session")
     with self.assertRaises(RuntimeError):
         with patch.object(session, "_schedule") as schedule_mock:
             schedule_mock.side_effect = RuntimeError("test error")
             session.schedule(app_info)
     record_tsm_mock.assert_called()
예제 #3
0
 def test_schedule_success(self, record_tsm_mock):
     app_info = AppDryRunInfo("test", lambda x: "test")
     app_info._scheduler = "default"
     cfg = RunConfig({"image_fetcher": "dir"})
     app_info._cfg = cfg
     session = DummySession("test_session")
     app_handle = session.schedule(app_info)
     actual_tsm_event = record_tsm_mock.call_args[0][0]  # first arg
     _, _, app_id = parse_app_handle(app_handle)
     self.assert_tsm_event(
         session._generate_tsm_event(
             "schedule", "default", app_id, runcfg=json.dumps(cfg.cfgs)
         ),
         actual_tsm_event,
     )
예제 #4
0
    def _submit_dryrun(self, app: Application,
                       cfg: RunConfig) -> AppDryRunInfo:
        app_popen_args = self._to_app_popen_args(f"{app.name}_##", app.roles,
                                                 cfg)
        import pprint

        return AppDryRunInfo(app_popen_args,
                             lambda p: pprint.pformat(p, indent=2, width=80))
예제 #5
0
    def _submit_dryrun(self, app: Application,
                       cfg: RunConfig) -> AppDryRunInfo:
        app_id = f"{app.name}_##"
        app_log_dir, redirect_std = self._get_app_log_dir(app_id, cfg)
        app_popen_args = self._to_app_popen_args(app_id, app.roles,
                                                 app_log_dir, redirect_std,
                                                 cfg)

        return AppDryRunInfo(app_popen_args,
                             lambda p: pprint.pformat(p, indent=2, width=80))
예제 #6
0
 def _submit_dryrun(self, app: Application,
                    cfg: RunConfig) -> AppDryRunInfo[PopenRequest]:
     request = self._to_popen_request(app, cfg)
     return AppDryRunInfo(request,
                          lambda p: pprint.pformat(p, indent=2, width=80))
예제 #7
0
 def _submit_dryrun(self, app: Application,
                    cfg: RunConfig) -> AppDryRunInfo:
     return AppDryRunInfo(None, lambda t: "None")
예제 #8
0
 def _dryrun(self, app: Application, scheduler: SchedulerBackend,
             cfg: RunConfig) -> AppDryRunInfo:
     return AppDryRunInfo("<mock request>", lambda r: r)