Example #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()
Example #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()
Example #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()
Example #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()
Example #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()
Example #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()
Example #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)
Example #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)
Example #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()
Example #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
Example #11
0
 def test_no_nodes(self, session):
     assert not util.get_next_node()
Example #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()
Example #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
Example #14
0
 def test_no_nodes(self, session):
     assert not util.get_next_node()