def test_scm_isolation_two_node(run_second_phase): """ In this test, two datanodes cannot communicate with SCM. Expectation : The container should eventually have at three closed replicas or, two open replicas and one quasi-closed replica. """ first_set = [OM[0], DATANODES[0], DATANODES[1], DATANODES[2]] second_set = [OM[0], SCM[0], DATANODES[1]] Blockade.blockade_create_partition(first_set, second_set) Blockade.blockade_status() ClusterUtils.run_freon(FILE, 1, 1, 1, 10240, "RATIS", "THREE") logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status(FILE, SCALE) closed_container_datanodes = [ x for x in all_datanodes_container_status if x == 'CLOSED' ] qausiclosed_container_datanodes = [ x for x in all_datanodes_container_status if x == 'QUASI_CLOSED' ] count_open_container_datanodes = [ x for x in all_datanodes_container_status if x == 'OPEN' ] assert len(closed_container_datanodes) == 3 or \ (len(count_open_container_datanodes) == 2 and len(qausiclosed_container_datanodes) == 1), \ "The container should have three closed replicas or two open " \ "replicas and one quasi_closed replica." if str(run_second_phase).lower() == "true": ClusterUtils.cluster_setup(FILE, INCREASED_SCALE, False) Blockade.blockade_status() logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status(FILE, INCREASED_SCALE) closed_container_datanodes = [ x for x in all_datanodes_container_status if x == 'CLOSED' ] qausiclosed_container_datanodes = \ [x for x in all_datanodes_container_status if x == 'QUASI_CLOSED'] assert len(closed_container_datanodes) >= 3 or \ len(qausiclosed_container_datanodes) >= 3 Blockade.blockade_join() Blockade.blockade_status() if len(closed_container_datanodes) < 3: time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status(FILE, INCREASED_SCALE) closed_container_datanodes = [ x for x in all_datanodes_container_status if x == 'CLOSED' ] assert len(closed_container_datanodes) >= 3 _, output = \ ClusterUtils.run_freon(FILE, 1, 1, 1, 10240, "RATIS", "THREE") assert re.search("Status: Success", output) is not None
def test_two_dns_isolate_scm_different_partition(run_second_phase): """ In this test, there are three datanodes, DN1, DN2, DN3 DN1 is on a network partition and DN2, DN3 are on a different network partition. DN1 and DN2 cannot communicate with SCM. Expectation : The container replica state in datanode DN1 should be open. The container replica states can be either 'closed' in DN2 and DN3, or, 'open' in DN2 and 'quasi-closed' in DN3. """ first_set = [OM[0], DATANODES[0]] second_set = [OM[0], DATANODES[1], DATANODES[2]] third_set = [SCM[0], DATANODES[2]] Blockade.blockade_create_partition(first_set, second_set, third_set) Blockade.blockade_status() ClusterUtils.run_freon(FILE, 1, 1, 1, 10240, "RATIS", "THREE") logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status(FILE, SCALE) first_datanode_status = all_datanodes_container_status[0] second_datanode_status = all_datanodes_container_status[1] third_datanode_status = all_datanodes_container_status[2] assert first_datanode_status == 'OPEN' assert (second_datanode_status == 'CLOSED' and third_datanode_status == 'CLOSED') or \ (second_datanode_status == 'OPEN' and third_datanode_status == 'QUASI_CLOSED') if str(run_second_phase).lower() == "true": ClusterUtils.cluster_setup(FILE, INCREASED_SCALE, False) Blockade.blockade_status() logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status( FILE, INCREASED_SCALE) count_closed_container_datanodes = filter( lambda x: x == 'CLOSED', all_datanodes_container_status) count_qausi_closed_container_datanodes = filter( lambda x: x == 'QUASI_CLOSED', all_datanodes_container_status) assert len(count_closed_container_datanodes) >= 3 or \ len(count_qausi_closed_container_datanodes) >= 3 Blockade.blockade_join() Blockade.blockade_status() if len(count_closed_container_datanodes) < 3: time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status( FILE, INCREASED_SCALE) count_closed_container_datanodes = filter( lambda x: x == 'CLOSED', all_datanodes_container_status) assert len(count_closed_container_datanodes) >= 3 _, output = \ ClusterUtils.run_freon(FILE, 1, 1, 1, 10240, "RATIS", "THREE") assert re.search("Status: Success", output) is not None
def test_three_dns_isolate_threescmfailure(run_second_phase): """ In this test, all datanodes are isolated from each other and also cannot communicate with SCM. Expectation : The container replica state in first datanode should be open. The container replica state in second datanode should be open. The container replica state in third datanode should be open. """ first_set = [OM[0], DATANODES[0]] second_set = [OM[0], DATANODES[1]] third_set = [OM[0], DATANODES[2]] Blockade.blockade_create_partition(first_set, second_set, third_set) Blockade.blockade_status() ClusterUtils.run_freon(FILE, 1, 1, 1, 10240, "RATIS", "THREE") logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status(FILE, SCALE) first_datanode_status = all_datanodes_container_status[0] second_datanode_status = all_datanodes_container_status[1] third_datanode_status = all_datanodes_container_status[2] assert first_datanode_status == 'OPEN' assert second_datanode_status == 'OPEN' assert third_datanode_status == 'OPEN' if str(run_second_phase).lower() == "true": ClusterUtils.cluster_setup(FILE, INCREASED_SCALE, False) Blockade.blockade_status() logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) output = ClusterUtils.get_pipelines(FILE) if output: assert re.search("Factor:THREE", output) is None all_datanodes_container_status = \ ClusterUtils.findall_container_status( FILE, INCREASED_SCALE) datanodes_having_container_status = filter( lambda x: x != 'None', all_datanodes_container_status) assert len(datanodes_having_container_status) == 3, \ "Containers should not be replicated on addition of new nodes." Blockade.blockade_join() Blockade.blockade_status() logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status( FILE, INCREASED_SCALE) count_closed_container_datanodes = filter( lambda x: x == 'CLOSED', all_datanodes_container_status) assert len(count_closed_container_datanodes) == 3, \ "The container should have three closed replicas."
def test_three_dns_isolate_twoscmfailure(run_second_phase): """ In this test, all datanodes are isolated from each other. two datanodes cannot communicate with SCM (second datanode and third datanode) Expectation : The container replica state in first datanode should be quasi-closed. The container replica state in second datanode should be open. The container replica state in third datanode should be open. """ first_set = [OM[0], SCM[0], DATANODES[0]] second_set = [OM[0], DATANODES[1]] third_set = [OM[0], DATANODES[2]] Blockade.blockade_create_partition(first_set, second_set, third_set) Blockade.blockade_status() ClusterUtils.run_freon(FILE, 1, 1, 1, 10240, "RATIS", "THREE") logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status(FILE, SCALE) first_datanode_status = all_datanodes_container_status[0] second_datanode_status = all_datanodes_container_status[1] third_datanode_status = all_datanodes_container_status[2] assert first_datanode_status == 'QUASI_CLOSED' assert second_datanode_status == 'OPEN' assert third_datanode_status == 'OPEN' if str(run_second_phase).lower() == "true": ClusterUtils.cluster_setup(FILE, INCREASED_SCALE, False) Blockade.blockade_status() logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status( FILE, INCREASED_SCALE) count_quasi_closed_container_datanodes = filter( lambda x: x == 'QUASI_CLOSED', all_datanodes_container_status) assert len(count_quasi_closed_container_datanodes) >= 3, \ "The container should have at least three quasi-closed replicas." Blockade.blockade_join() Blockade.blockade_status() logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status( FILE, INCREASED_SCALE) count_closed_container_datanodes = filter( lambda x: x == 'CLOSED', all_datanodes_container_status) assert len(count_closed_container_datanodes) == 3, \ "The container should have three closed replicas."
def test_isolatedatanode_singlenode(run_second_phase): """ In this test, one of the datanodes (first datanode) cannot communicate with other two datanodes. All datanodes can communicate with SCM. Expectation : The container replica state in first datanode should be quasi-closed. The container replica state in other datanodes should be closed. """ first_set = [OM[0], SCM[0], DATANODES[0]] second_set = [OM[0], SCM[0], DATANODES[1], DATANODES[2]] Blockade.blockade_create_partition(first_set, second_set) Blockade.blockade_status() ClusterUtils.run_freon(FILE, 1, 1, 1, 10240, "RATIS", "THREE") logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status(FILE, SCALE) first_datanode_status = all_datanodes_container_status[0] closed_container_datanodes = [ x for x in all_datanodes_container_status if x == 'CLOSED' ] assert first_datanode_status == 'QUASI_CLOSED' assert len(closed_container_datanodes) == 2, \ "The container should have two closed replicas." if str(run_second_phase).lower() == "true": ClusterUtils.cluster_setup(FILE, INCREASED_SCALE, False) Blockade.blockade_status() logger.info("Waiting for %s seconds before checking container status", os.environ["CONTAINER_STATUS_SLEEP"]) time.sleep(int(os.environ["CONTAINER_STATUS_SLEEP"])) all_datanodes_container_status = \ ClusterUtils.findall_container_status(FILE, INCREASED_SCALE) closed_container_datanodes = [ x for x in all_datanodes_container_status if x == 'CLOSED' ] assert len(closed_container_datanodes) >= 3, \ "The container should have at least three closed replicas." Blockade.blockade_join() Blockade.blockade_status() _, output = \ ClusterUtils.run_freon(FILE, 1, 1, 1, 10240, "RATIS", "THREE") assert re.search("Status: Success", output) is not None
def restore_network(self): """ Restores the network partition. """ Blockade.blockade_join()