コード例 #1
0
ファイル: ServiceGroupTest.py プロジェクト: cea-hpc/milkcheck
 def test_eval_deps_status_done(self):
     '''Test the method eval_deps_status NO_STATUS'''
     group = ServiceGroup('group')
     e1 = Service('E1')
     e2 = Service('E2')
     group.add_dep(target=e1)
     group.add_dep(target=e2)
     group.add_inter_dep(target=Service('I1'))
     self.assertEqual(group.eval_deps_status(), NO_STATUS)
     e1.status = DONE
     e2.status = DONE
     self.assertEqual(group.eval_deps_status(), NO_STATUS)
コード例 #2
0
 def test_eval_deps_status_done(self):
     '''Test the method eval_deps_status NO_STATUS'''
     group = ServiceGroup('group')
     e1 = Service('E1')
     e2 = Service('E2')
     group.add_dep(target=e1)
     group.add_dep(target=e2)
     group.add_inter_dep(target=Service('I1'))
     self.assertEqual(group.eval_deps_status(), NO_STATUS)
     e1.status = DONE
     e2.status = DONE
     self.assertEqual(group.eval_deps_status(), NO_STATUS)
コード例 #3
0
 def test_eval_deps_status_ws(self):
     '''Test the method eval_deps_status WAITING_STATUS'''
     group = ServiceGroup('group')
     ext1 = Service('E1')
     ext2 = Service('E2')
     ext1.status = DONE
     ext2.status = WARNING
     group.add_dep(target=ext1)
     group.add_dep(target=ext2)
     int1 = Service('E1')
     group.add_inter_dep(target=int1)
     int1.status = WAITING_STATUS
     self.assertEqual(group.eval_deps_status(), WAITING_STATUS)
コード例 #4
0
ファイル: ServiceGroupTest.py プロジェクト: cea-hpc/milkcheck
 def test_eval_deps_status_ws(self):
     '''Test the method eval_deps_status WAITING_STATUS'''
     group = ServiceGroup('group')
     ext1 = Service('E1')
     ext2 = Service('E2')
     ext1.status = DONE
     ext2.status = WARNING
     group.add_dep(target=ext1)
     group.add_dep(target=ext2)
     int1 = Service('E1')
     group.add_inter_dep(target=int1)
     int1.status = WAITING_STATUS
     self.assertEqual(group.eval_deps_status(), WAITING_STATUS)
コード例 #5
0
 def test_eval_deps_status_error(self):
     '''Test the method eval_deps_status DEP_ERROR'''
     group = ServiceGroup('group')
     e1 = Service('E1')
     e2 = Service('E2')
     e1.status = DEP_ERROR
     group.add_dep(target=e1)
     group.add_dep(target=e2)
     group.add_inter_dep(target=Service('I1'))
     self.assertEqual(group.eval_deps_status(), DEP_ERROR)
     self.assertEqual(group.eval_deps_status(), DEP_ERROR)
コード例 #6
0
ファイル: ServiceGroupTest.py プロジェクト: cea-hpc/milkcheck
 def test_eval_deps_status_error(self):
     '''Test the method eval_deps_status DEP_ERROR'''
     group = ServiceGroup('group')
     e1 = Service('E1')
     e2 = Service('E2')
     e1.status = DEP_ERROR
     group.add_dep(target=e1)
     group.add_dep(target=e2)
     group.add_inter_dep(target=Service('I1'))
     self.assertEqual(group.eval_deps_status(), DEP_ERROR)
     self.assertEqual(group.eval_deps_status(), DEP_ERROR)
コード例 #7
0
    def test_run_with_skipped_deps(self):
        """Test run with only SKIPPED dependencies"""

        # Define the main service
        serv_test = Service('test_service')
        start = Action(name='start', command='/bin/true')
        serv_test.add_action(start)

        serv_depa = Service('DEP_A')
        serv_depa.status = SKIPPED
        serv_depb = Service('DEP_B')
        serv_depb.status = SKIPPED

        serv_test.add_dep(serv_depa)
        serv_test.add_dep(serv_depb)

        self.assertEqual(serv_test.eval_deps_status(), SKIPPED)

        serv_test.run('start')
        self.assertEqual(serv_test.status, DONE)
        self.assertEqual(serv_depa.status, SKIPPED)
        self.assertEqual(serv_depb.status, SKIPPED)
コード例 #8
0
ファイル: ServiceTest.py プロジェクト: cea-hpc/milkcheck
    def test_run_with_skipped_deps(self):
        """Test run with only SKIPPED dependencies"""

        # Define the main service
        serv_test = Service('test_service')
        start = Action(name='start', command='/bin/true')
        serv_test.add_action(start)

        serv_depa = Service('DEP_A')
        serv_depa.status = SKIPPED
        serv_depb = Service('DEP_B')
        serv_depb.status = SKIPPED

        serv_test.add_dep(serv_depa)
        serv_test.add_dep(serv_depb)

        self.assertEqual(serv_test.eval_deps_status(), SKIPPED)

        serv_test.run('start')
        self.assertEqual(serv_test.status, DONE)
        self.assertEqual(serv_depa.status, SKIPPED)
        self.assertEqual(serv_depb.status, SKIPPED)
コード例 #9
0
    def test_run_with_locked_service(self):
        '''Test run services with locked dependencies'''
        s1 = Service('S1')
        s2 = Service('S2')
        s3 = Service('S3')
        s4 = Service('S4')
        s5 = Service('S5')

        # Actions S1
        start_s1 = Action('start', command='/bin/true')
        stop_s1 = Action('stop', command='/bin/true')
        s1.add_actions(start_s1, stop_s1)
        # Actions S2
        start_s2 = Action('start', command='/bin/true')
        stop_s2 = Action('stop', command='/bin/true')
        s2.add_actions(start_s2, stop_s2)
        # Actions S3
        start_s3 = Action('start', command='/bin/false')
        stop_s3 = Action('stop', command='/bin/false')
        s3.add_actions(start_s3, stop_s3)
        # Actions S4
        start_s4 = Action('start', command='/bin/true')
        stop_s4 = Action('stop', command='/bin/true')
        s4.add_actions(start_s4, stop_s4)
        # Actions I1
        start_s5 = Action('start', command='/bin/true')
        stop_s5 = Action('stop', command='/bin/true')
        s5.add_actions(start_s5, stop_s5)

        # Locked services
        s3.status = LOCKED

        # Build graph
        s1.add_dep(target=s2)
        s1.add_dep(target=s3)
        s3.add_dep(target=s4)
        s3.add_dep(target=s5)

        # Run service S1
        s1.run('start')

        self.assertEqual(s1.status, DONE)
        self.assertEqual(s2.status, DONE)
        self.assertEqual(s3.status, LOCKED)
        self.assertEqual(s4.status, NO_STATUS)
        self.assertEqual(s5.status, NO_STATUS)
コード例 #10
0
 def test_reset_service_group(self):
     '''Test the ability to reset values of a service group'''
     group = ServiceGroup('GROUP')
     ser1 = Service('I1')
     action = Action(name='start', delay=3)
     action.maxretry = 5
     action.tries = 3
     action.status = DONE
     ser1.add_action(action)
     ser1.status = ERROR
     group.add_inter_dep(target=ser1)
     group.status = DEP_ERROR
     group.reset()
     self.assertEqual(group.status, NO_STATUS)
     self.assertEqual(ser1.status, NO_STATUS)
     self.assertEqual(action.status, NO_STATUS)
     self.assertEqual(action.tries, 0)
コード例 #11
0
ファイル: ServiceTest.py プロジェクト: cea-hpc/milkcheck
    def test_run_with_locked_service(self):
        '''Test run services with locked dependencies'''
        s1 = Service('S1')
        s2 = Service('S2')
        s3 = Service('S3')
        s4 = Service('S4')
        s5 = Service('S5')

        # Actions S1
        start_s1 = Action('start', command='/bin/true')
        stop_s1 = Action('stop', command='/bin/true')
        s1.add_actions(start_s1, stop_s1)
        # Actions S2
        start_s2 = Action('start', command='/bin/true')
        stop_s2 = Action('stop', command='/bin/true')
        s2.add_actions(start_s2, stop_s2)
        # Actions S3
        start_s3 = Action('start', command='/bin/false')
        stop_s3 = Action('stop', command='/bin/false')
        s3.add_actions(start_s3, stop_s3)
        # Actions S4
        start_s4 = Action('start', command='/bin/true')
        stop_s4 = Action('stop', command='/bin/true')
        s4.add_actions(start_s4, stop_s4)
        # Actions I1
        start_s5 = Action('start', command='/bin/true')
        stop_s5 = Action('stop', command='/bin/true')
        s5.add_actions(start_s5, stop_s5)

        # Locked services
        s3.status = LOCKED

        # Build graph
        s1.add_dep(target=s2)
        s1.add_dep(target=s3)
        s3.add_dep(target=s4)
        s3.add_dep(target=s5)
        
        # Run service S1
        s1.run('start')

        self.assertEqual(s1.status, DONE)
        self.assertEqual(s2.status, DONE)
        self.assertEqual(s3.status, LOCKED)
        self.assertEqual(s4.status, NO_STATUS)
        self.assertEqual(s5.status, NO_STATUS)
コード例 #12
0
ファイル: ServiceGroupTest.py プロジェクト: cea-hpc/milkcheck
 def test_reset_service_group(self):
     '''Test the ability to reset values of a service group'''
     group = ServiceGroup('GROUP')
     ser1 = Service('I1')
     action = Action(name='start', delay=3)
     action.maxretry = 5
     action.tries = 3
     action.status = DONE
     ser1.add_action(action)
     ser1.status = ERROR
     group.add_inter_dep(target=ser1)
     group.status = DEP_ERROR
     group.reset()
     self.assertEqual(group.status, NO_STATUS)
     self.assertEqual(ser1.status, NO_STATUS)
     self.assertEqual(action.status, NO_STATUS)
     self.assertEqual(action.tries, 0)