def params_from_base_test_setup(request, params_from_base_suite_setup): test_name = request.node.name log_info("Setting up test '{}'".format(test_name)) cluster_config = params_from_base_suite_setup["cluster_config"] mode = params_from_base_suite_setup["mode"] yield { "cluster_config": cluster_config, "mode": mode } log_info("Tearing down test '{}'".format(test_name)) # Capture testkit socket usage network_utils = NetworkUtils() network_utils.list_connections() # Verify all sync_gateways and sg_accels are reachable c = cluster.Cluster(cluster_config) errors = c.verify_alive(mode) assert len(errors) == 0 # if the test failed pull logs if request.node.rep_call.failed: logging_helper = Logging() logging_helper.fetch_and_analyze_logs(cluster_config=cluster_config, test_name=test_name)
def params_from_base_test_setup(request, params_from_base_suite_setup): # Code before the yeild will execute before each test starts cluster_config = params_from_base_suite_setup["cluster_config"] mode = params_from_base_suite_setup["mode"] test_name = request.node.name log_info("Setting up test '{}'".format(test_name)) network_utils = NetworkUtils() network_utils.start_packet_capture(cluster_config) # This dictionary is passed to each test yield {"cluster_config": cluster_config, "mode": mode} # Code after the yeild will execute when each test finishes log_info("Tearing down test '{}'".format(test_name)) network_utils.list_connections() network_utils.stop_packet_capture(cluster_config) network_utils.collect_packet_capture(cluster_config=cluster_config, test_name=test_name) # Verify all sync_gateways and sg_accels are reachable c = cluster.Cluster(cluster_config) errors = c.verify_alive(mode) assert len(errors) == 0 # if the test failed pull logs if request.node.rep_call.failed: logging_helper = Logging() logging_helper.fetch_and_analyze_logs(cluster_config=cluster_config, test_name=test_name)
def setup_1sg_1cbs_test(request): test_name = request.node.name log_info("Setting up test '{}'".format(test_name)) yield {"cluster_config": os.environ["CLUSTER_CONFIG"]} log_info("Tearing down test '{}'".format(test_name)) # if the test failed pull logs if request.node.rep_call.failed: logging_helper = Logging() logging_helper.fetch_and_analyze_logs(cluster_config=os.environ["CLUSTER_CONFIG"], test_name=test_name)
def setup_client_syncgateway_test(request, setup_client_syncgateway_suite): """Test setup fixture for client sync_gateway tests""" log_info("Setting up client sync_gateway test ...") liteserv = setup_client_syncgateway_suite test_name = request.node.name ls_url = liteserv.start( "{}/logs/{}-{}-{}.txt".format(RESULTS_DIR, type(liteserv).__name__, test_name, datetime.datetime.now()) ) cluster_helper = ClusterKeywords() sg_helper = SyncGateway() cluster_hosts = cluster_helper.get_cluster_topology(os.environ["CLUSTER_CONFIG"]) sg_url = cluster_hosts["sync_gateways"][0]["public"] sg_admin_url = cluster_hosts["sync_gateways"][0]["admin"] sg_helper.stop_sync_gateway(cluster_config=os.environ["CLUSTER_CONFIG"], url=sg_url) # Yield values to test case via fixture argument yield { "cluster_config": os.environ["CLUSTER_CONFIG"], "ls_url": ls_url, "sg_url": sg_url, "sg_admin_url": sg_admin_url, } log_info("Tearing down test") # Teardown test client = MobileRestClient() client.delete_databases(ls_url) liteserv.stop() sg_helper.stop_sync_gateway(cluster_config=os.environ["CLUSTER_CONFIG"], url=sg_url) # if the test failed pull logs if request.node.rep_call.failed: logging_helper = Logging() logging_helper.fetch_and_analyze_logs(cluster_config=os.environ["CLUSTER_CONFIG"], test_name=test_name)
def setup_client_2sgs_test(request): """Test setup fixture for client sync_gateway tests""" log_info("Setting up client sync_gateway test ...") liteserv_platform = request.config.getoption("--liteserv-platform") liteserv_version = request.config.getoption("--liteserv-version") liteserv_host = request.config.getoption("--liteserv-host") liteserv_port = request.config.getoption("--liteserv-port") liteserv_storage_engine = request.config.getoption("--liteserv-storage-engine") ls = LiteServ() client = MobileRestClient() test_name = request.node.name # Verify LiteServ is not running ls.verify_liteserv_not_running(host=liteserv_host, port=liteserv_port) ls_cluster_target = None if liteserv_platform == "net-win": ls_cluster_target = "resources/cluster_configs/windows" print("Starting LiteServ ...") if liteserv_platform != "net-win": # logging is file ls_logging = open("{}/logs/{}-ls1-{}-{}.txt".format(RESULTS_DIR, datetime.datetime.now(), liteserv_platform, test_name), "w") else: # logging is name ls_logging = "{}/logs/{}-ls1-{}-{}.txt".format(RESULTS_DIR, datetime.datetime.now(), liteserv_platform, test_name) ls_url, ls_handle = ls.start_liteserv( platform=liteserv_platform, version=liteserv_version, host=liteserv_host, port=liteserv_port, storage_engine=liteserv_storage_engine, logfile=ls_logging, cluster_config=ls_cluster_target ) cluster_helper = ClusterKeywords() sg_helper = SyncGateway() cluster_hosts = cluster_helper.get_cluster_topology(os.environ["CLUSTER_CONFIG"]) sg_one_url = cluster_hosts["sync_gateways"][0]["public"] sg_one_admin_url = cluster_hosts["sync_gateways"][0]["admin"] sg_two_url = cluster_hosts["sync_gateways"][1]["public"] sg_two_admin_url = cluster_hosts["sync_gateways"][1]["admin"] sg_helper.stop_sync_gateway(cluster_config=os.environ["CLUSTER_CONFIG"], url=sg_one_url) sg_helper.stop_sync_gateway(cluster_config=os.environ["CLUSTER_CONFIG"], url=sg_two_url) # Yield values to test case via fixture argument yield { "cluster_config": os.environ["CLUSTER_CONFIG"], "ls_url": ls_url, "sg_one_url": sg_one_url, "sg_one_admin_url": sg_one_admin_url, "sg_two_url": sg_two_url, "sg_two_admin_url": sg_two_admin_url } log_info("Tearing down test") # Teardown test client.delete_databases(ls_url) ls.shutdown_liteserv(host=liteserv_host, platform=liteserv_platform, version=liteserv_version, storage_engine=liteserv_storage_engine, process_handle=ls_handle, logfile=ls_logging, cluster_config=ls_cluster_target) # Verify LiteServ is killed ls.verify_liteserv_not_running(host=liteserv_host, port=liteserv_port) sg_helper.stop_sync_gateway(cluster_config=os.environ["CLUSTER_CONFIG"], url=sg_one_url) sg_helper.stop_sync_gateway(cluster_config=os.environ["CLUSTER_CONFIG"], url=sg_two_url) # if the test failed pull logs if request.node.rep_call.failed: logging_helper = Logging() logging_helper.fetch_and_analyze_logs(cluster_config=os.environ["CLUSTER_CONFIG"], test_name=test_name)