Пример #1
0
 def test_fail_if_down(self):
     top = make_topology(size=3, has_down_host=True)
     done = []
     running = []
     failed = []
     with self.assertRaises(HostIsDown):
         find_next_host(Strategy.ALL, top, None, Progress(done=done, running=running, failed=failed), True, True, None, None, False)
Пример #2
0
 def test_is_healthy_is_true_when_running_jobs_take_down_host(self):
     top = make_topology(3, True)
     state = State(top,
                   None, {},
                   True,
                   True,
                   progress=Progress(running=set(top.get_down())))
     self.assertEqual(state.is_healthy(), True)
Пример #3
0
 def test_healthy_cluster(self):
     top = make_topology(2, True)
     down = set(top.get_down())
     state = State(top,
                   None, {},
                   True,
                   True,
                   progress=Progress(running=down))
     self.assertEqual(state.is_healthy(), True)
Пример #4
0
    def test_succeed_if_down_with_ignore_down_nodes(self):
        top = make_topology(size=3, has_down_host=True)
        done = []
        running = []
        failed = []

        while True:
            h = find_next_host(Strategy.ALL, top, None, Progress(done=done, running=running, failed=failed), True, True, None, None, True)
            if not h:
                break
            running.append(h)
        self.assertEqual(len(running), 12)
Пример #5
0
    def test_all(self):
        top = make_topology(size=3)
        done = []
        running = []
        failed = []

        while True:
            h = find_next_host(Strategy.ALL, top, None, Progress(done=done, running=running, failed=failed), True, True, None, None, False)
            if not h:
                break
            running.append(h)
        self.assertEqual(len(running), 12)
Пример #6
0
    def test_do_with_something(self):
        top = make_topology(2)
        out = ""

        def writer(x):
            nonlocal out
            out = x
        print_progress(top, Progress(running=set((top.first(),))), top.get_down(), writer)
        expected = """ +  Done, up      * Executing, up      !  Failed, up      . Waiting, up
 -  Done, down    / Executing, down    X  Failed, down    : Waiting, down
Cluster: cluster1
DC: eu
*.
DC: us
..
Cluster: cluster2
DC: eu
..
DC: us
..
0 done, 0 failed, 1 executing"""
        self.assertEqual(out.count("*"), expected.count("*"))
Пример #7
0
    def test_do_nothing(self):
        top = make_topology(2)
        out = ""

        def writer(x):
            nonlocal out
            out = x
        print_progress(top, Progress(), top.get_down(), writer)
        expected = """ +  Done, up      * Executing, up      !  Failed, up      . Waiting, up
 -  Done, down    / Executing, down    X  Failed, down    : Waiting, down
Cluster: cluster1
DC: eu
..
DC: us
..
Cluster: cluster2
DC: eu
..
DC: us
..
0 done, 0 failed, 0 executing"""
        self.assertEqual(out, expected)