def test_convert_workflow_time_average(self): test1 = {'worfklow1': {'count': 0, 'avg_time': timedelta(100, 0, 1)}, 'worfklow2': {'count': 2, 'avg_time': timedelta(0, 0, 1000)}, 'worfklow3': {'count': 0, 'avg_time': timedelta(0, 100, 1)}, 'worfklow4': {'count': 100, 'avg_time': timedelta(1, 100, 500)}} expected_json = {'workflows': [{'count': 100, 'avg_time': '1 day, 0:01:40.000500', 'name': 'worfklow4'}, {'count': 2, 'avg_time': '0:00:00.001000', 'name': 'worfklow2'}, {'count': 0, 'avg_time': '0:01:40.000001', 'name': 'worfklow3'}, {'count': 0, 'avg_time': '100 days, 0:00:00.000001', 'name': 'worfklow1'}]} metrics.workflow_metrics = test1 converted = _convert_workflow_time_averages() orderless_list_compare(self, converted.keys(), ['workflows']) self.assertEqual(len(converted['workflows']), len(expected_json['workflows'])) for workflow in expected_json['workflows']: self.assertIn(workflow, converted['workflows'])
def test_workflow_metrics(self): server.running_context.controller.initialize_threading() server.running_context.controller.load_playbook(resource=config.test_workflows_path + 'multistepError.playbook') server.running_context.controller.load_playbook(resource=config.test_workflows_path + 'multiactionWorkflowTest.playbook') server.running_context.controller.execute_workflow('multistepError', 'multiactionErrorWorkflow') server.running_context.controller.execute_workflow('multistepError', 'multiactionErrorWorkflow') server.running_context.controller.execute_workflow('multiactionWorkflowTest', 'multiactionWorkflow') server.running_context.controller.shutdown_pool(3) response = self.app.get('/metrics/workflows', headers=self.headers) self.assertEqual(response.status_code, 200) response = json.loads(response.get_data(as_text=True)) self.assertDictEqual(response, _convert_workflow_time_averages())
def test_workflow_metrics(self): server.running_context.controller.load_workflows_from_file(path=config.test_workflows_path + 'multistepError.playbook') server.running_context.controller.load_workflows_from_file(path=config.test_workflows_path + 'tieredWorkflow.playbook') server.running_context.controller.load_workflows_from_file(path=config.test_workflows_path + 'multiactionWorkflowTest.playbook') server.running_context.controller.execute_workflow('multistepError', 'multiactionErrorWorkflow') server.running_context.controller.execute_workflow('tieredWorkflow', 'parentWorkflow') server.running_context.controller.execute_workflow('multistepError', 'multiactionErrorWorkflow') server.running_context.controller.execute_workflow('tieredWorkflow', 'parentWorkflow') server.running_context.controller.execute_workflow('multiactionWorkflowTest', 'multiactionWorkflow') response = self.app.get('/metrics/workflows', headers=self.headers) self.assertEqual(response.status_code, 200) response = json.loads(response.get_data(as_text=True)) self.assertDictEqual(response, _convert_workflow_time_averages())