def test_down_count_is_incremented(self, m_get, session): m_get.return_value.ok = False node = Node("chacra.ceph.com") session.commit() util.is_node_healthy(node) node = Node.get(1) assert node.down_count == 1
def test_node_exceeds_down_count_limit(self, m_get, session): m_get.return_value.ok = False node = Node("chacra.ceph.com") node.down_count = 2 session.commit() util.is_node_healthy(node) node = Node.get(1) assert not node.healthy
def test_down_count_is_cleared_when_healthy(self, m_get, session): m_get.return_value.ok = True node = Node("chacra.ceph.com") node.down_count = 2 session.commit() util.is_node_healthy(node) node = Node.get(1) assert node.down_count == 0
def test_last_check_is_updated(self, m_get, session): m_get.return_value.ok = True node = Node("chacra.ceph.com") last_check = datetime.datetime.now() node.last_check = datetime.datetime.now() session.commit() util.is_node_healthy(node) node = Node.get(1) assert node.last_check.time() > last_check.time()
def test_healthy_is_true_when_rejoining_pool(self, m_get, session): """ Tests the scenario where a node has been marked down, but is now up again and needs to rejoin the pool. """ m_get.return_value.ok = True node = Node("chacra.ceph.com") node.down_count = 3 node.healthy = False session.commit() util.is_node_healthy(node) node = Node.get(1) assert node.down_count == 0 assert node.healthy
def test_node_is_not_healthy(self, m_get, session): m_get.return_value.ok = False node = Node("chacra.ceph.com") session.commit() assert not util.is_node_healthy(node)