Beispiel #1
0
 def test_use_newly_added_node(self, session, monkeypatch):
     monkeypatch.setattr(util, "is_node_healthy", lambda node: True)
     n1 = Node("chacra01.ceph.com")
     n1.last_used = datetime.datetime.now()
     n2 = Node("chacra02.ceph.com")
     session.commit()
     assert n2 == util.get_next_node()
Beispiel #2
0
 def test_use_newly_added_node(self, session, monkeypatch):
     monkeypatch.setattr(util, "is_node_healthy", lambda node: True)
     n1 = Node("chacra01.ceph.com")
     n1.last_used = datetime.datetime.now()
     n2 = Node("chacra02.ceph.com")
     session.commit()
     assert n2 == util.get_next_node()
Beispiel #3
0
 def test_sets_last_used_on_selection(self, session, monkeypatch):
     monkeypatch.setattr(util, "is_node_healthy", lambda node: True)
     node = Node("chacra.ceph.com")
     session.commit()
     last_used = node.last_used
     next_node = util.get_next_node()
     assert next_node.last_used.time() > last_used.time()
Beispiel #4
0
 def test_sets_last_used_on_selection(self, session, monkeypatch):
     monkeypatch.setattr(util, "is_node_healthy", lambda node: True)
     node = Node("chacra.ceph.com")
     session.commit()
     last_used = node.last_used
     next_node = util.get_next_node()
     assert next_node.last_used.time() > last_used.time()
Beispiel #5
0
 def test_pick_last_used_node(self, session, monkeypatch):
     monkeypatch.setattr(util, "is_node_healthy", lambda node: True)
     n1 = Node("chacra01.ceph.com")
     n1.last_used = datetime.datetime.now() - datetime.timedelta(days=1)
     n2 = Node("chacra02.ceph.com")
     n2.last_used = datetime.datetime.now()
     session.commit()
     assert n1 == util.get_next_node()
Beispiel #6
0
 def test_pick_last_used_node(self, session, monkeypatch):
     monkeypatch.setattr(util, "is_node_healthy", lambda node: True)
     n1 = Node("chacra01.ceph.com")
     n1.last_used = datetime.datetime.now() - datetime.timedelta(days=1)
     n2 = Node("chacra02.ceph.com")
     n2.last_used = datetime.datetime.now()
     session.commit()
     assert n1 == util.get_next_node()
Beispiel #7
0
 def next(self):
     next_node = get_next_node()
     if not next_node:
         abort(404, "There are no healthy chacra nodes available.")
     return "https://{}/".format(next_node.host)
Beispiel #8
0
 def next(self):
     next_node = get_next_node()
     if not next_node:
         abort(404, "There are no healthy chacra nodes available.")
     return "https://{}/".format(next_node.host)
Beispiel #9
0
 def test_no_healthy_nodes(self, session):
     node = Node("chacra.ceph.com")
     node.healthy = False
     session.commit()
     assert not util.get_next_node()
Beispiel #10
0
 def test_finds_a_node(self, session, monkeypatch):
     monkeypatch.setattr(util, "is_node_healthy", lambda node: True)
     node = Node("chacra.ceph.com")
     session.commit()
     next_node = util.get_next_node()
     assert next_node == node
Beispiel #11
0
 def test_no_nodes(self, session):
     assert not util.get_next_node()
Beispiel #12
0
 def test_no_healthy_nodes(self, session):
     node = Node("chacra.ceph.com")
     node.healthy = False
     session.commit()
     assert not util.get_next_node()
Beispiel #13
0
 def test_finds_a_node(self, session, monkeypatch):
     monkeypatch.setattr(util, "is_node_healthy", lambda node: True)
     node = Node("chacra.ceph.com")
     session.commit()
     next_node = util.get_next_node()
     assert next_node == node
Beispiel #14
0
 def test_no_nodes(self, session):
     assert not util.get_next_node()