Esempio n. 1
0
 def test_get_relevant_action_for_not_scheduled_state(self):
     action_runs = [
         {
             'id':
             'MASTER.test.1.2',
             'state':
             'succeeded',
             'end_time':
             time.strftime(
                 '%Y-%m-%d %H:%M:%S',
                 time.localtime(time.time() - 600),
             ),
         },
         {
             'id':
             'MASTER.test.1.1',
             'state':
             'succeeded',
             'end_time':
             time.strftime(
                 '%Y-%m-%d %H:%M:%S',
                 time.localtime(time.time() - 1200),
             ),
         },
     ]
     actual = check_tron_jobs.get_relevant_action(
         action_runs=action_runs,
         last_state=State.NOT_SCHEDULED,
         actions_expected_runtime={
             'action1': 86400.0,
             'action2': 86400.0,
             'action3': 86400.0,
         })
     assert_equal(actual["id"], "MASTER.test.1.1")
Esempio n. 2
0
 def test_get_relevant_action_pick_the_one_exceeds_expected_runtime_with_long_duration(
         self):
     action_runs = [
         {
             'id':
             'MASTER.test.1.action3',
             'action_name':
             'action3',
             'state':
             'running',
             'start_time':
             time.strftime('%Y-%m-%d %H:%M:%S',
                           time.localtime(time.time() - 600)),
             'duration':
             '1 day, 0:10:00.006305',
         },
         {
             'id':
             'MASTER.test.1.action2',
             'action_name':
             'action2',
             'state':
             'running',
             'start_time':
             time.strftime('%Y-%m-%d %H:%M:%S',
                           time.localtime(time.time() - 600)),
             'duration':
             '2 days, 0:10:00.006383',
         },
         {
             'id':
             'MASTER.test.1.action1',
             'action_name':
             'action1',
             'state':
             'running',
             'start_time':
             time.strftime('%Y-%m-%d %H:%M:%S',
                           time.localtime(time.time() - 600)),
             'duration':
             '1 day, 0:10:00.006331',
         },
     ]
     actions_expected_runtime = {
         'action3': 100000.0,
         'action2': 100000.0,
         'action1': 100000.0
     }
     actual = check_tron_jobs.get_relevant_action(
         action_runs=action_runs,
         last_state=State.STUCK,
         actions_expected_runtime=actions_expected_runtime)
     assert_equal(actual["id"], "MASTER.test.1.action2")
Esempio n. 3
0
 def test_get_relevant_action_picks_the_one_that_failed(self):
     action_runs = [
         {
             'node': {
                 'username': '******',
                 'hostname': 'localhost',
                 'name': 'localhost',
                 'port': 22,
             },
             'raw_command': '/bin/false',
             'requirements': [],
             'run_num': '582',
             'exit_status': 1,
             'stdout': None,
             'start_time': '2018-02-05 17:40:00',
             'id': 'MASTER.kwatest.582.action1',
             'action_name': 'action1',
             'state': 'failed',
             'command': '/bin/false',
             'end_time': '2018-02-05 17:40:00',
             'stderr': None,
             'duration': '0:00:00.065018',
             'job_name': 'MASTER.kwatest',
         },
         {
             'node': {
                 'username': '******',
                 'hostname': 'localhost',
                 'name': 'localhost',
                 'port': 22,
             },
             'raw_command': '/bin/true',
             'requirements': [],
             'run_num': '582',
             'exit_status': 0,
             'stdout': None,
             'start_time': '2018-02-05 17:40:00',
             'id': 'MASTER.kwatest.582.action2',
             'action_name': 'action2',
             'state': 'succeeded',
             'command': '/bin/true',
             'end_time': '2018-02-05 17:40:00',
             'stderr': None,
             'duration': '0:00:00.046243',
             'job_name': 'MASTER.kwatest',
         },
     ]
     actual = check_tron_jobs.get_relevant_action(
         action_runs=action_runs,
         last_state=State.FAILED,
         actions_expected_runtime={})
     assert_equal(actual["state"], "failed")
Esempio n. 4
0
 def test_get_relevant_action_picks_the_first_one_succeeded(self):
     action_runs = [
         {
             'id':
             'MASTER.test.action1',
             'action_name':
             'action1',
             'state':
             'succeeded',
             'start_time':
             time.strftime('%Y-%m-%d %H:%M:%S',
                           time.localtime(time.time() - 1200)),
             'duration':
             '0:18:01.475067',
         },
         {
             'id':
             'MASTER.test.action2',
             'action_name':
             'action2',
             'state':
             'succeeded',
             'start_time':
             time.strftime('%Y-%m-%d %H:%M:%S',
                           time.localtime(time.time() - 600)),
             'duration':
             '0:08:02.005783',
         },
         {
             'id':
             'MASTER.test.action1',
             'action_name':
             'action1',
             'state':
             'succeeded',
             'start_time':
             time.strftime('%Y-%m-%d %H:%M:%S',
                           time.localtime(time.time())),
             'duration':
             '0:00:01.006305',
         },
     ]
     actual = check_tron_jobs.get_relevant_action(
         action_runs=action_runs,
         last_state=State.SUCCEEDED,
         actions_expected_runtime={
             'action1': 86400.0,
             'action2': 86400.0,
             'action3': 86400.0
         },
     )
     assert_equal(actual["id"], "MASTER.test.action1")
Esempio n. 5
0
 def test_get_relevant_action_pick_the_one_stuck(self):
     action_runs = [
         {
             'id':
             'MASTER.test.1.action3',
             'state':
             'succeeded',
             'start_time':
             time.strftime('%Y-%m-%d %H:%M:%S',
                           time.localtime(time.time() - 1200)),
             'duration':
             '0:18:01.475067',
         },
         {
             'id':
             'MASTER.test.1.action2',
             'state':
             'running',
             'start_time':
             time.strftime('%Y-%m-%d %H:%M:%S',
                           time.localtime(time.time() - 1100)),
             'duration':
             '0:18:40.005783',
         },
         {
             'id':
             'MASTER.test.1.action1',
             'state':
             'succeeded',
             'start_time':
             time.strftime('%Y-%m-%d %H:%M:%S',
                           time.localtime(time.time() - 1000)),
             'duration':
             '0:00:01.006305',
         },
     ]
     actual = check_tron_jobs.get_relevant_action(action_runs=action_runs,
                                                  last_state=State.STUCK,
                                                  actions_expected_runtime={
                                                      'action1': 86400.0,
                                                      'action2': 86400.0,
                                                      'action3': 86400.0,
                                                  })
     assert_equal(actual["id"], "MASTER.test.1.action2")