def params_from_base_test_setup(request, params_from_base_suite_setup): # pytest command line parameters collect_logs = request.config.getoption("--collect-logs") 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) # if the test failed pull logs if collect_logs or request.node.rep_call.failed or len(errors) != 0: logging_helper = Logging() logging_helper.fetch_and_analyze_logs(cluster_config=cluster_config, test_name=test_name) assert len(errors) == 0
def params_from_base_test_setup(request, params_from_base_suite_setup): # Code before the yeild will execute before each test starts # pytest command line parameters collect_logs = request.config.getoption("--collect-logs") cluster_config = params_from_base_suite_setup["cluster_config"] mode = params_from_base_suite_setup["mode"] xattrs_enabled = params_from_base_suite_setup["xattrs_enabled"] test_name = request.node.name log_info("Setting up test '{}'".format(test_name)) # This dictionary is passed to each test yield { "cluster_config": cluster_config, "mode": mode, "xattrs_enabled": xattrs_enabled } # Code after the yeild will execute when each test finishes log_info("Tearing down test '{}'".format(test_name)) # Verify all sync_gateways and sg_accels are reachable c = cluster.Cluster(cluster_config) errors = c.verify_alive(mode) # if the test failed pull logs if collect_logs or request.node.rep_call.failed or len(errors) != 0: logging_helper = Logging() logging_helper.fetch_and_analyze_logs(cluster_config=cluster_config, test_name=test_name) assert len(errors) == 0
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["liteserv"] cluster_config = setup_client_syncgateway_suite["cluster_config"] xattrs_enabled = setup_client_syncgateway_suite["xattrs_enabled"] device_enabled = setup_client_syncgateway_suite["device_enabled"] liteserv_platform = setup_client_syncgateway_suite["liteserv_platform"] liteserv_version = setup_client_syncgateway_suite["liteserv_version"] test_name = request.node.name if request.config.getoption("--liteserv-platform") == "macosx" and \ str(request.config.getoption("--liteserv-version")).startswith("1.3.1") and \ str(test_name).startswith("test_longpoll_changes_termination"): pytest.skip("test_longpoll_changes_termination tests are known to fail on macosx with 1.3.1 CBL") client = MobileRestClient() # Start LiteServ and delete any databases log_info("Starting LiteServ...") if device_enabled and liteserv_platform == "ios": ls_url = liteserv.start_device("{}/logs/{}-{}-{}.txt".format(RESULTS_DIR, type(liteserv).__name__, test_name, datetime.datetime.now())) else: ls_url = liteserv.start("{}/logs/{}-{}-{}.txt".format(RESULTS_DIR, type(liteserv).__name__, test_name, datetime.datetime.now())) client.delete_databases(ls_url) cluster_helper = ClusterKeywords() cluster_hosts = cluster_helper.get_cluster_topology(cluster_config=cluster_config) sg_url = cluster_hosts["sync_gateways"][0]["public"] sg_admin_url = cluster_hosts["sync_gateways"][0]["admin"] # Yield values to test case via fixture argument yield { "cluster_config": cluster_config, "sg_mode": setup_client_syncgateway_suite["sg_mode"], "ls_url": ls_url, "sg_url": sg_url, "sg_admin_url": sg_admin_url, "xattrs_enabled": xattrs_enabled, "liteserv": liteserv, "liteserv_platform": liteserv_platform, "device_enabled": device_enabled, "liteserv_version": liteserv_version } log_info("Tearing down test") client.delete_databases(ls_url) liteserv.stop() # 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["liteserv"] cluster_config = setup_client_syncgateway_suite["cluster_config"] xattrs_enabled = setup_client_syncgateway_suite["xattrs_enabled"] test_name = request.node.name client = MobileRestClient() # Start LiteServ and delete any databases ls_url = liteserv.start("{}/logs/{}-{}-{}.txt".format( RESULTS_DIR, type(liteserv).__name__, test_name, datetime.datetime.now())) client.delete_databases(ls_url) cluster_helper = ClusterKeywords() cluster_hosts = cluster_helper.get_cluster_topology( cluster_config=cluster_config) sg_url = cluster_hosts["sync_gateways"][0]["public"] sg_admin_url = cluster_hosts["sync_gateways"][0]["admin"] # Yield values to test case via fixture argument yield { "cluster_config": cluster_config, "sg_mode": setup_client_syncgateway_suite["sg_mode"], "ls_url": ls_url, "sg_url": sg_url, "sg_admin_url": sg_admin_url, "xattrs_enabled": xattrs_enabled } log_info("Tearing down test") client.delete_databases(ls_url) liteserv.stop() # 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_suite_setup(request): log_info("Setting up 'params_from_base_suite_setup' ...") # pytest command line parameters server_version = request.config.getoption("--server-version") sync_gateway_version = request.config.getoption("--sync-gateway-version") mode = request.config.getoption("--mode") skip_provisioning = request.config.getoption("--skip-provisioning") race_enabled = request.config.getoption("--race") cbs_ssl = request.config.getoption("--server-ssl") xattrs_enabled = request.config.getoption("--xattrs") sg_lb = request.config.getoption("--sg-lb") sg_ce = request.config.getoption("--sg-ce") use_sequoia = request.config.getoption("--sequoia") no_conflicts_enabled = request.config.getoption("--no-conflicts") if xattrs_enabled and version_is_binary(sync_gateway_version): check_xattr_support(server_version, sync_gateway_version) log_info("server_version: {}".format(server_version)) log_info("sync_gateway_version: {}".format(sync_gateway_version)) log_info("mode: {}".format(mode)) log_info("skip_provisioning: {}".format(skip_provisioning)) log_info("race_enabled: {}".format(race_enabled)) log_info("cbs_ssl: {}".format(cbs_ssl)) log_info("xattrs_enabled: {}".format(xattrs_enabled)) log_info("sg_lb: {}".format(sg_lb)) log_info("sg_ce: {}".format(sg_ce)) log_info("no conflicts enabled {}".format(no_conflicts_enabled)) # sg-ce is invalid for di mode if mode == "di" and sg_ce: raise FeatureSupportedError( "SGAccel is only available as an enterprise edition") if no_conflicts_enabled and sync_gateway_version < "2.0": raise FeatureSupportedError( 'No conflicts feature not available for sync-gateway version below 2.0, so skipping the test' ) # Make sure mode for sync_gateway is supported ('cc' or 'di') validate_sync_gateway_mode(mode) # use load_balancer_cc cluster config if mode is "cc" or load_balancer_di cluster config if mode is "di" cluster_config = "{}/load_balancer_{}".format( keywords.constants.CLUSTER_CONFIGS_DIR, mode) sg_config = sync_gateway_config_path_for_mode( "sync_gateway_default_functional_tests", mode) # Add load balancer prop and check if load balancer IP is available if sg_lb: persist_cluster_config_environment_prop(cluster_config, 'sg_lb_enabled', True) log_info("Running tests with load balancer enabled: {}".format( get_load_balancer_ip(cluster_config))) else: log_info("Running tests with load balancer disabled") persist_cluster_config_environment_prop(cluster_config, 'sg_lb_enabled', False) if cbs_ssl: log_info("Running tests with cbs <-> sg ssl enabled") # Enable ssl in cluster configs persist_cluster_config_environment_prop(cluster_config, 'cbs_ssl_enabled', True) else: log_info("Running tests with cbs <-> sg ssl disabled") # Disable ssl in cluster configs persist_cluster_config_environment_prop(cluster_config, 'cbs_ssl_enabled', False) if xattrs_enabled: log_info("Running test with xattrs for sync meta storage") persist_cluster_config_environment_prop(cluster_config, 'xattrs_enabled', True) else: log_info("Using document storage for sync meta data") persist_cluster_config_environment_prop(cluster_config, 'xattrs_enabled', False) try: server_version except NameError: log_info("Server version is not provided") persist_cluster_config_environment_prop(cluster_config, 'server_version', "") else: log_info("Running test with server version {}".format(server_version)) persist_cluster_config_environment_prop(cluster_config, 'server_version', server_version) try: sync_gateway_version except NameError: log_info("Sync gateway version is not provided") persist_cluster_config_environment_prop(cluster_config, 'sync_gateway_version', "") else: log_info("Running test with sync_gateway version {}".format( sync_gateway_version)) persist_cluster_config_environment_prop(cluster_config, 'sync_gateway_version', sync_gateway_version) if no_conflicts_enabled: log_info("Running with no conflicts") persist_cluster_config_environment_prop(cluster_config, 'no_conflicts_enabled', True) else: log_info("Running with allow conflicts") persist_cluster_config_environment_prop(cluster_config, 'no_conflicts_enabled', False) if sync_gateway_version < "2.0.0" and no_conflicts_enabled: pytest.skip( "Test cannot run with no-conflicts with sg version < 2.0.0") # Skip provisioning if user specifies '--skip-provisoning' or '--sequoia' should_provision = True if skip_provisioning or use_sequoia: should_provision = False cluster_utils = ClusterKeywords() if should_provision: try: cluster_utils.provision_cluster( cluster_config=cluster_config, server_version=server_version, sync_gateway_version=sync_gateway_version, sync_gateway_config=sg_config, race_enabled=race_enabled, sg_ce=sg_ce) except ProvisioningError: logging_helper = Logging() logging_helper.fetch_and_analyze_logs( cluster_config=cluster_config, test_name=request.node.name) raise # Hit this intalled running services to verify the correct versions are installed cluster_utils.verify_cluster_versions( cluster_config, expected_server_version=server_version, expected_sync_gateway_version=sync_gateway_version) yield {"cluster_config": cluster_config, "mode": mode} log_info("Tearing down 'params_from_base_suite_setup' ...") # Stop all sync_gateway and sg_accels as test finished c = cluster.Cluster(cluster_config) c.stop_sg_and_accel()
def params_from_base_test_setup(request, params_from_base_suite_setup): # Code before the yeild will execute before each test starts # pytest command line parameters collect_logs = request.config.getoption("--collect-logs") cluster_config = params_from_base_suite_setup["cluster_config"] cluster_topology = params_from_base_suite_setup["cluster_topology"] mode = params_from_base_suite_setup["mode"] xattrs_enabled = params_from_base_suite_setup["xattrs_enabled"] sg_lb = params_from_base_suite_setup["sg_lb"] no_conflicts_enabled = params_from_base_suite_setup["no_conflicts_enabled"] sync_gateway_version = params_from_base_suite_setup["sync_gateway_version"] test_name = request.node.name if sg_lb: # These tests target one SG node skip_tests = ['resync', 'log_rotation', 'openidconnect'] for test in skip_tests: if test in test_name: pytest.skip("Skipping online/offline tests with load balancer") # Certain test are diabled for certain modes # Given the run conditions, check if the test needs to be skipped skip_if_unsupported( sync_gateway_version=params_from_base_suite_setup["sync_gateway_version"], mode=mode, test_name=test_name, no_conflicts_enabled=no_conflicts_enabled ) log_info("Running test '{}'".format(test_name)) log_info("cluster_config: {}".format(cluster_config)) log_info("cluster_topology: {}".format(cluster_topology)) log_info("mode: {}".format(mode)) log_info("xattrs_enabled: {}".format(xattrs_enabled)) # This dictionary is passed to each test yield { "cluster_config": cluster_config, "cluster_topology": cluster_topology, "mode": mode, "xattrs_enabled": xattrs_enabled, "no_conflicts_enabled": no_conflicts_enabled, "sync_gateway_version": sync_gateway_version } # Code after the yield will execute when each test finishes log_info("Tearing down test '{}'".format(test_name)) 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) # if the test failed or a node is down, pull logs if collect_logs or request.node.rep_call.failed or len(errors) != 0: logging_helper = Logging() logging_helper.fetch_and_analyze_logs(cluster_config=cluster_config, test_name=test_name) assert len(errors) == 0
def params_from_base_test_setup(request, params_from_base_suite_setup): # Code before the yeild will execute before each test starts # pytest command line parameters collect_logs = request.config.getoption("--collect-logs") cluster_config = params_from_base_suite_setup["cluster_config"] cluster_topology = params_from_base_suite_setup["cluster_topology"] mode = params_from_base_suite_setup["mode"] xattrs_enabled = params_from_base_suite_setup["xattrs_enabled"] test_name = request.node.name log_info("Running test '{}'".format(test_name)) log_info("cluster_config: {}".format(cluster_config)) log_info("cluster_topology: {}".format(cluster_topology)) log_info("mode: {}".format(mode)) log_info("xattrs_enabled: {}".format(xattrs_enabled)) # This dictionary is passed to each test yield { "cluster_config": cluster_config, "cluster_topology": cluster_topology, "mode": mode, "xattrs_enabled": xattrs_enabled, "server_seed_docs": params_from_base_suite_setup["server_seed_docs"], "max_docs": params_from_base_suite_setup["max_docs"], "num_users": params_from_base_suite_setup["num_users"], "create_batch_size": params_from_base_suite_setup["create_batch_size"], "create_delay": params_from_base_suite_setup["create_delay"], "update_runtime_sec": params_from_base_suite_setup["update_runtime_sec"], "update_batch_size": params_from_base_suite_setup["update_batch_size"], "update_docs_percentage": params_from_base_suite_setup["update_docs_percentage"], "update_delay": params_from_base_suite_setup["update_delay"], "changes_delay": params_from_base_suite_setup["changes_delay"], "changes_limit": params_from_base_suite_setup["changes_limit"] } # Code after the yield will execute when each test finishes log_info("Tearing down test '{}'".format(test_name)) 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) # if the test failed or a node is down, pull logs logging_helper = Logging() if collect_logs or request.node.rep_call.failed or len(errors) != 0: logging_helper.fetch_and_analyze_logs(cluster_config=cluster_config, test_name=test_name) assert len(errors) == 0 # Scan logs # SG logs for panic, data race # System logs for OOM ansible_runner = AnsibleRunner(cluster_config) script_name = "{}/utilities/check_logs.sh".format(os.getcwd()) status = ansible_runner.run_ansible_playbook( "check-logs.yml", extra_vars={"script_name": script_name}) if status != 0: logging_helper.fetch_and_analyze_logs(cluster_config=cluster_config, test_name=test_name) raise LogScanningError("Errors found in the logs")
def params_from_base_suite_setup(request): log_info("Setting up 'params_from_base_suite_setup' ...") # pytest command line parameters server_version = request.config.getoption("--server-version") sync_gateway_version = request.config.getoption("--sync-gateway-version") mode = request.config.getoption("--mode") use_sequoia = request.config.getoption("--sequoia") skip_provisioning = request.config.getoption("--skip-provisioning") cbs_ssl = request.config.getoption("--server-ssl") xattrs_enabled = request.config.getoption("--xattrs") server_seed_docs = request.config.getoption("--server-seed-docs") max_docs = request.config.getoption("--max-docs") num_users = request.config.getoption("--num-users") create_batch_size = request.config.getoption("--create-batch-size") create_delay = request.config.getoption("--create-delay") update_runtime_sec = request.config.getoption("--update-runtime-sec") update_batch_size = request.config.getoption("--update-batch-size") update_docs_percentage = request.config.getoption( "--update-docs-percentage") update_delay = request.config.getoption("--update-delay") changes_delay = request.config.getoption("--changes-delay") changes_limit = request.config.getoption("--changes-limit") if xattrs_enabled and version_is_binary(sync_gateway_version): check_xattr_support(server_version, sync_gateway_version) log_info("server_version: {}".format(server_version)) log_info("sync_gateway_version: {}".format(sync_gateway_version)) log_info("mode: {}".format(mode)) log_info("skip_provisioning: {}".format(skip_provisioning)) log_info("cbs_ssl: {}".format(cbs_ssl)) log_info("xattrs_enabled: {}".format(xattrs_enabled)) # Make sure mode for sync_gateway is supported ('cc' or 'di') validate_sync_gateway_mode(mode) # use ci_lb_cc cluster config if mode is "cc" or ci_lb_di cluster config if more is "di" log_info("Using 'ci_lb_{}' config!".format(mode)) cluster_config = "{}/ci_lb_{}".format(CLUSTER_CONFIGS_DIR, mode) try: server_version except NameError: log_info("Server version is not provided") persist_cluster_config_environment_prop(cluster_config, 'server_version', "") else: log_info("Running test with server version {}".format(server_version)) persist_cluster_config_environment_prop(cluster_config, 'server_version', server_version) try: sync_gateway_version except NameError: log_info("Sync gateway version is not provided") persist_cluster_config_environment_prop(cluster_config, 'sync_gateway_version', "") else: log_info("Running test with sync_gateway version {}".format( sync_gateway_version)) persist_cluster_config_environment_prop(cluster_config, 'sync_gateway_version', sync_gateway_version) # Only works with load balancer configs persist_cluster_config_environment_prop(cluster_config, 'sg_lb_enabled', True) if cbs_ssl: log_info("Running tests with cbs <-> sg ssl enabled") # Enable ssl in cluster configs persist_cluster_config_environment_prop(cluster_config, 'cbs_ssl_enabled', True) else: log_info("Running tests with cbs <-> sg ssl disabled") # Disable ssl in cluster configs persist_cluster_config_environment_prop(cluster_config, 'cbs_ssl_enabled', False) if xattrs_enabled: log_info("Running test with xattrs for sync meta storage") persist_cluster_config_environment_prop(cluster_config, 'xattrs_enabled', True) else: log_info("Using document storage for sync meta data") persist_cluster_config_environment_prop(cluster_config, 'xattrs_enabled', False) sg_config = sync_gateway_config_path_for_mode( "sync_gateway_default_functional_tests", mode) # Skip provisioning if user specifies '--skip-provisoning' or '--sequoia' should_provision = True if skip_provisioning or use_sequoia: should_provision = False cluster_utils = ClusterKeywords() if should_provision: try: cluster_utils.provision_cluster( cluster_config=cluster_config, server_version=server_version, sync_gateway_version=sync_gateway_version, sync_gateway_config=sg_config) except ProvisioningError: logging_helper = Logging() logging_helper.fetch_and_analyze_logs( cluster_config=cluster_config, test_name=request.node.name) raise # Hit this intalled running services to verify the correct versions are installed cluster_utils.verify_cluster_versions( cluster_config, expected_server_version=server_version, expected_sync_gateway_version=sync_gateway_version) # Load topology as a dictionary cluster_topology = cluster_utils.get_cluster_topology(cluster_config) yield { "cluster_config": cluster_config, "cluster_topology": cluster_topology, "mode": mode, "xattrs_enabled": xattrs_enabled, "server_seed_docs": server_seed_docs, "max_docs": max_docs, "num_users": num_users, "create_batch_size": create_batch_size, "create_delay": create_delay, "update_runtime_sec": update_runtime_sec, "update_batch_size": update_batch_size, "update_docs_percentage": update_docs_percentage, "update_delay": update_delay, "changes_delay": changes_delay, "changes_limit": changes_limit } log_info("Tearing down 'params_from_base_suite_setup' ...")
def params_from_base_test_setup(request, params_from_base_suite_setup): # Code before the yeild will execute before each test starts # pytest command line parameters cluster_config = params_from_base_suite_setup["cluster_config"] cluster_topology = params_from_base_suite_setup["cluster_topology"] mode = params_from_base_suite_setup["mode"] xattrs_enabled = params_from_base_suite_setup["xattrs_enabled"] server_version = params_from_base_suite_setup["server_version"] sync_gateway_version = params_from_base_suite_setup["sync_gateway_version"] server_upgraded_version = params_from_base_suite_setup[ "server_upgraded_version"] sync_gateway_upgraded_version = params_from_base_suite_setup[ "sync_gateway_upgraded_version"] liteserv_host = params_from_base_suite_setup["liteserv_host"] liteserv_port = params_from_base_suite_setup["liteserv_port"] liteserv_version = params_from_base_suite_setup["liteserv_version"] liteserv_platform = params_from_base_suite_setup["liteserv_platform"] liteserv_storage_engine = params_from_base_suite_setup[ "liteserv_storage_engine"] liteserv = params_from_base_suite_setup["liteserv"] num_docs = params_from_base_suite_setup["num_docs"] cbs_platform = params_from_base_suite_setup["cbs_platform"] cbs_toy_build = params_from_base_suite_setup["cbs_toy_build"] test_name = request.node.name log_info("Running test '{}'".format(test_name)) log_info("cluster_config: {}".format(cluster_config)) log_info("cluster_topology: {}".format(cluster_topology)) log_info("mode: {}".format(mode)) log_info("xattrs_enabled: {}".format(xattrs_enabled)) client = MobileRestClient() # Start LiteServ and delete any databases ls_url = liteserv.start("{}/logs/{}-{}-{}.txt".format( RESULTS_DIR, type(liteserv).__name__, test_name, datetime.datetime.now())) client.delete_databases(ls_url) cluster_helper = ClusterKeywords() cluster_hosts = cluster_helper.get_cluster_topology( cluster_config=cluster_config) sg_url = cluster_hosts["sync_gateways"][0]["public"] sg_admin_url = cluster_hosts["sync_gateways"][0]["admin"] if xattrs_enabled: log_info("Running upgrade with xattrs for sync meta storage") persist_cluster_config_environment_prop(cluster_config, 'xattrs_enabled', True) else: log_info("Using document storage for sync meta data") persist_cluster_config_environment_prop(cluster_config, 'xattrs_enabled', False) # This dictionary is passed to each test yield { "cluster_config": cluster_config, "cluster_topology": cluster_topology, "mode": mode, "xattrs_enabled": xattrs_enabled, "server_version": server_version, "sync_gateway_version": sync_gateway_version, "server_upgraded_version": server_upgraded_version, "sync_gateway_upgraded_version": sync_gateway_upgraded_version, "liteserv_host": liteserv_host, "liteserv_port": liteserv_port, "liteserv_version": liteserv_version, "liteserv_platform": liteserv_platform, "liteserv_storage_engine": liteserv_storage_engine, "ls_url": ls_url, "sg_url": sg_url, "sg_admin_url": sg_admin_url, "num_docs": num_docs, "cbs_platform": cbs_platform, "cbs_toy_build": cbs_toy_build } client.delete_databases(ls_url) liteserv.stop() # Code after the yield will execute when each test finishes log_info("Tearing down test '{}'".format(test_name)) 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) # Fetch logs logging_helper = Logging() logging_helper.fetch_and_analyze_logs(cluster_config=cluster_config, test_name=test_name) assert len(errors) == 0 # Scan logs # SG logs for panic, data race # System logs for OOM ansible_runner = AnsibleRunner(cluster_config) script_name = "{}/utilities/check_logs.sh".format(os.getcwd()) status = ansible_runner.run_ansible_playbook( "check-logs.yml", extra_vars={"script_name": script_name}) if status != 0: raise LogScanningError("Errors found in the logs")
def params_from_base_suite_setup(request): log_info("Setting up 'params_from_base_suite_setup' ...") # pytest command line parameters server_version = request.config.getoption("--server-version") sync_gateway_version = request.config.getoption("--sync-gateway-version") server_upgraded_version = request.config.getoption( "--server-upgraded-version") sync_gateway_upgraded_version = request.config.getoption( "--sync-gateway-upgraded-version") mode = request.config.getoption("--mode") cluster_config = request.config.getoption("--cluster-config") # use_sequoia = request.config.getoption("--sequoia") skip_provisioning = request.config.getoption("--skip-provisioning") cbs_ssl = request.config.getoption("--server-ssl") xattrs_enabled = request.config.getoption("--xattrs") liteserv_host = request.config.getoption("--liteserv-host") liteserv_port = request.config.getoption("--liteserv-port") liteserv_version = request.config.getoption("--liteserv-version") liteserv_platform = request.config.getoption("--liteserv-platform") liteserv_storage_engine = request.config.getoption( "--liteserv-storage-engine") num_docs = request.config.getoption("--num-docs") cbs_platform = request.config.getoption("--cbs-platform") cbs_toy_build = request.config.getoption("--cbs-upgrade-toybuild") if xattrs_enabled and version_is_binary(sync_gateway_version): check_xattr_support(server_upgraded_version, sync_gateway_upgraded_version) log_info("server_version: {}".format(server_version)) log_info("sync_gateway_version: {}".format(sync_gateway_version)) log_info("server_upgraded_version: {}".format(server_upgraded_version)) log_info("sync_gateway_upgraded_version: {}".format( sync_gateway_upgraded_version)) log_info("mode: {}".format(mode)) log_info("skip_provisioning: {}".format(skip_provisioning)) log_info("cbs_ssl: {}".format(cbs_ssl)) log_info("xattrs_enabled: {}".format(xattrs_enabled)) log_info("liteserv_host: {}".format(liteserv_host)) log_info("liteserv_port: {}".format(liteserv_port)) log_info("liteserv_version: {}".format(liteserv_version)) log_info("liteserv_platform: {}".format(liteserv_platform)) log_info("liteserv_storage_engine: {}".format(liteserv_storage_engine)) log_info("num_docs: {}".format(num_docs)) log_info("cbs_platform: {}".format(cbs_platform)) log_info("cbs_toy_build: {}".format(cbs_toy_build)) # Make sure mode for sync_gateway is supported ('cc' or 'di') validate_sync_gateway_mode(mode) # use ci_lb_cc cluster config if mode is "cc" or ci_lb_di cluster config if more is "di" # use base_(lb_)cc cluster config if mode is "cc" or base_(lb_)di cluster config if mode is "di" cluster_config = "{}/{}_{}".format(CLUSTER_CONFIGS_DIR, cluster_config, mode) log_info("Using '{}' config!".format(cluster_config)) try: server_version except NameError: log_info("Server version is not provided") persist_cluster_config_environment_prop(cluster_config, 'server_version', "") else: log_info("Running test with server version {}".format(server_version)) persist_cluster_config_environment_prop(cluster_config, 'server_version', server_version) try: sync_gateway_version except NameError: log_info("Sync gateway version is not provided") persist_cluster_config_environment_prop(cluster_config, 'sync_gateway_version', "") else: log_info("Running test with sync_gateway version {}".format( sync_gateway_version)) persist_cluster_config_environment_prop(cluster_config, 'sync_gateway_version', sync_gateway_version) # Only works with load balancer configs persist_cluster_config_environment_prop(cluster_config, 'sg_lb_enabled', True) if cbs_ssl: log_info("Running tests with cbs <-> sg ssl enabled") # Enable ssl in cluster configs persist_cluster_config_environment_prop(cluster_config, 'cbs_ssl_enabled', True) else: log_info("Running tests with cbs <-> sg ssl disabled") # Disable ssl in cluster configs persist_cluster_config_environment_prop(cluster_config, 'cbs_ssl_enabled', False) sg_config = sync_gateway_config_path_for_mode( "sync_gateway_default_functional_tests", mode) liteserv = LiteServFactory.create(platform=liteserv_platform, version_build=liteserv_version, host=liteserv_host, port=liteserv_port, storage_engine=liteserv_storage_engine) log_info("Downloading LiteServ ...") # Download LiteServ liteserv.download() # Install LiteServ liteserv.install() # Skip provisioning if user specifies '--skip-provisoning' or '--sequoia' should_provision = True if skip_provisioning: should_provision = False cluster_utils = ClusterKeywords() if should_provision: try: cluster_utils.provision_cluster( cluster_config=cluster_config, server_version=server_version, sync_gateway_version=sync_gateway_version, sync_gateway_config=sg_config, cbs_platform=cbs_platform) except ProvisioningError: logging_helper = Logging() logging_helper.fetch_and_analyze_logs( cluster_config=cluster_config, test_name=request.node.name) raise # Hit this intalled running services to verify the correct versions are installed cluster_utils.verify_cluster_versions( cluster_config, expected_server_version=server_version, expected_sync_gateway_version=sync_gateway_version) # Load topology as a dictionary cluster_topology = cluster_utils.get_cluster_topology(cluster_config) yield { "cluster_config": cluster_config, "cluster_topology": cluster_topology, "mode": mode, "xattrs_enabled": xattrs_enabled, "server_version": server_version, "sync_gateway_version": sync_gateway_version, "server_upgraded_version": server_upgraded_version, "sync_gateway_upgraded_version": sync_gateway_upgraded_version, "liteserv_host": liteserv_host, "liteserv_port": liteserv_port, "liteserv_version": liteserv_version, "liteserv_platform": liteserv_platform, "liteserv_storage_engine": liteserv_storage_engine, "liteserv": liteserv, "num_docs": num_docs, "cbs_platform": cbs_platform, "cbs_toy_build": cbs_toy_build } log_info("Tearing down 'params_from_base_suite_setup' ...")