def test_android_download(request):

    android_version = request.config.getoption("--android-version")
    android_host = request.config.getoption("--android-host")

    shutil.rmtree("{}/".format(BINARY_DIR))
    os.makedirs("{}".format(BINARY_DIR))

    liteserv = LiteServFactory.create("android",
                                      version_build=android_version,
                                      host=android_host,
                                      port=59840,
                                      storage_engine="SQLite")

    liteserv.download()

    assert len(os.listdir("deps/binaries")) == 1
    assert os.path.isfile(
        "deps/binaries/couchbase-lite-android-liteserv-SQLite-{}-debug.apk".
        format(android_version))

    liteserv_two = LiteServFactory.create("android",
                                          version_build=android_version,
                                          host=android_host,
                                          port=59840,
                                          storage_engine="SQLCipher")

    liteserv_two.download()

    assert len(os.listdir("deps/binaries")) == 2
    assert os.path.isfile(
        "deps/binaries/couchbase-lite-android-liteserv-SQLCipher-ForestDB-Encryption-{}-debug.apk"
        .format(android_version))
def test_android_download(request):

    android_version = request.config.getoption("--android-version")
    android_host = request.config.getoption("--android-host")

    shutil.rmtree("{}/".format(BINARY_DIR))
    os.makedirs("{}".format(BINARY_DIR))

    liteserv = LiteServFactory.create("android",
                                      version_build=android_version,
                                      host=android_host,
                                      port=59840,
                                      storage_engine="SQLite")

    liteserv.download()

    assert len(os.listdir("deps/binaries")) == 1
    assert os.path.isfile("deps/binaries/couchbase-lite-android-liteserv-SQLite-{}-debug.apk".format(android_version))

    liteserv_two = LiteServFactory.create("android",
                                          version_build=android_version,
                                          host=android_host,
                                          port=59840,
                                          storage_engine="SQLCipher")

    liteserv_two.download()

    assert len(os.listdir("deps/binaries")) == 2
    assert os.path.isfile("deps/binaries/couchbase-lite-android-liteserv-SQLCipher-ForestDB-Encryption-{}-debug.apk".format(android_version))
예제 #3
0
def test_invalid_storage_engine():

    with pytest.raises(ValueError) as ve:
        LiteServFactory.create("macosx",
                               version_build="1.3.1-6",
                               host="localhost",
                               port=59840,
                               storage_engine="SQLit")
    ve_message = str(ve.value)
    assert ve_message == "Unsupported 'storage_engine': SQLit"
예제 #4
0
def test_invalid_platform():

    with pytest.raises(ValueError) as ve:
        LiteServFactory.create("ias",
                               version_build="1.3.1-6",
                               host="localhost",
                               port=59840,
                               storage_engine="SQLite")
    ve_message = str(ve.value)
    assert ve_message == "Unsupported 'platform': ias"
예제 #5
0
def test_running_liteserv(request):
    liteserv = LiteServFactory.create("macosx",
                                      version_build="1.3.1-6",
                                      host="localhost",
                                      port=59840,
                                      storage_engine="SQLite")

    liteserv.download()

    test_name = request.node.name

    logfile = "{}/logs/{}-{}-{}-1.txt".format(RESULTS_DIR,
                                              type(liteserv).__name__,
                                              test_name,
                                              datetime.datetime.now())
    liteserv.start(logfile)

    logfile_2 = "{}/logs/{}-{}-{}-2.txt".format(RESULTS_DIR,
                                                type(liteserv).__name__,
                                                test_name,
                                                datetime.datetime.now())
    with pytest.raises(LiteServError) as lse:
        liteserv.start(logfile_2)

    ex_message = str(lse.value)
    assert ex_message == "There should be no service running on the port"

    liteserv.stop()
예제 #6
0
def remove_liteserv(platform, version_build, host, port, storage_engine):

    liteserv = LiteServFactory.create(platform=platform,
                                      version_build=version_build,
                                      host=host,
                                      port=port,
                                      storage_engine=storage_engine)
    liteserv.remove()
def setup_p2p_suite(request):

    """Suite setup fixture for p2p client tests"""

    log_info("Setting up P2P suite ...")

    liteserv_one_platform = request.config.getoption("--liteserv-one-platform")
    liteserv_one_version = request.config.getoption("--liteserv-one-version")
    liteserv_one_host = request.config.getoption("--liteserv-one-host")
    liteserv_one_port = request.config.getoption("--liteserv-one-port")
    liteserv_one_storage_engine = request.config.getoption("--liteserv-one-storage-engine")

    liteserv_two_platform = request.config.getoption("--liteserv-two-platform")
    liteserv_two_version = request.config.getoption("--liteserv-two-version")
    liteserv_two_host = request.config.getoption("--liteserv-two-host")
    liteserv_two_port = request.config.getoption("--liteserv-two-port")
    liteserv_two_storage_engine = request.config.getoption("--liteserv-two-storage-engine")

    liteserv_one = LiteServFactory.create(platform=liteserv_one_platform,
                                          version_build=liteserv_one_version,
                                          host=liteserv_one_host,
                                          port=liteserv_one_port,
                                          storage_engine=liteserv_one_storage_engine)

    liteserv_two = LiteServFactory.create(platform=liteserv_two_platform,
                                          version_build=liteserv_two_version,
                                          host=liteserv_two_host,
                                          port=liteserv_two_port,
                                          storage_engine=liteserv_two_storage_engine)

    liteserv_one.download()
    liteserv_one.install()

    liteserv_two.download()
    liteserv_two.install()

    yield {"liteserv_one": liteserv_one, "liteserv_two": liteserv_two}

    log_info("Tearing down suite ...")

    liteserv_one.remove()

    liteserv_two.remove()
예제 #8
0
def setup_p2p_suite(request):

    """Suite setup fixture for p2p client tests"""

    log_info("Setting up P2P suite ...")

    liteserv_one_platform = request.config.getoption("--liteserv-one-platform")
    liteserv_one_version = request.config.getoption("--liteserv-one-version")
    liteserv_one_host = request.config.getoption("--liteserv-one-host")
    liteserv_one_port = request.config.getoption("--liteserv-one-port")
    liteserv_one_storage_engine = request.config.getoption("--liteserv-one-storage-engine")

    liteserv_two_platform = request.config.getoption("--liteserv-two-platform")
    liteserv_two_version = request.config.getoption("--liteserv-two-version")
    liteserv_two_host = request.config.getoption("--liteserv-two-host")
    liteserv_two_port = request.config.getoption("--liteserv-two-port")
    liteserv_two_storage_engine = request.config.getoption("--liteserv-two-storage-engine")

    liteserv_one = LiteServFactory.create(platform=liteserv_one_platform,
                                          version_build=liteserv_one_version,
                                          host=liteserv_one_host,
                                          port=liteserv_one_port,
                                          storage_engine=liteserv_one_storage_engine)

    liteserv_two = LiteServFactory.create(platform=liteserv_two_platform,
                                          version_build=liteserv_two_version,
                                          host=liteserv_two_host,
                                          port=liteserv_two_port,
                                          storage_engine=liteserv_two_storage_engine)

    liteserv_one.download()
    liteserv_one.install()

    liteserv_two.download()
    liteserv_two.install()

    yield {"liteserv_one": liteserv_one, "liteserv_two": liteserv_two}

    log_info("Tearing down suite ...")

    liteserv_one.remove()
    liteserv_two.remove()
예제 #9
0
def setup_client_syncgateway_suite(request):

    """Suite setup fixture for client sync_gateway tests"""

    log_info("Setting up client sync_gateway suite ...")

    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")

    sync_gateway_version = request.config.getoption("--sync-gateway-version")

    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()

    cluster_helper = ClusterKeywords()
    cluster_helper.set_cluster_config("1sg")
    cluster_config = os.environ["CLUSTER_CONFIG"]

    clean_cluster(cluster_config=cluster_config)

    log_info("Installing sync_gateway")
    sg_helper = SyncGateway()
    sg_helper.install_sync_gateway(
        cluster_config=cluster_config,
        sync_gateway_version=sync_gateway_version,
        sync_gateway_config="{}/walrus.json".format(SYNC_GATEWAY_CONFIGS),
    )

    # Wait at the yeild until tests referencing this suite setup have run,
    # Then execute the teardown
    yield liteserv

    log_info("Tearing down suite ...")
    cluster_helper.unset_cluster_config()

    liteserv.remove()
def install_liteserv(platform, version_build, host, port, storage_engine):

    liteserv = LiteServFactory.create(platform=platform,
                                      version_build=version_build,
                                      host=host,
                                      port=port,
                                      storage_engine=storage_engine)
    liteserv.download()
    liteserv.install()

    # launch to verify version
    liteserv.start("log.txt")
    liteserv.stop()
예제 #11
0
def install_liteserv(platform, version_build, host, port, storage_engine):

    liteserv = LiteServFactory.create(platform=platform,
                                      version_build=version_build,
                                      host=host,
                                      port=port,
                                      storage_engine=storage_engine)
    liteserv.download()
    liteserv.install()

    # launch to verify version
    liteserv.start("log.txt")
    liteserv.stop()
def liteserv_with_storage_engine_from_fixture(request):

    net_version = request.config.getoption("--net-version")

    liteserv = LiteServFactory.create(
        "net-mono", version_build=net_version, host="localhost", port=59840, storage_engine=request.param
    )
    liteserv.download()
    liteserv.install()

    yield liteserv

    liteserv.remove()
def test_ios_download(request):

    ios_version = request.config.getoption("--ios-version")
    ios_host = request.config.getoption("--ios-host")

    shutil.rmtree("{}/".format(BINARY_DIR))
    os.makedirs("{}".format(BINARY_DIR))

    liteserv = LiteServFactory.create("ios",
                                      version_build=ios_version,
                                      host=ios_host,
                                      port=59840,
                                      storage_engine="SQLite")

    liteserv.download()
def test_ios_download(request):

    ios_version = request.config.getoption("--ios-version")
    ios_host = request.config.getoption("--ios-host")

    shutil.rmtree("{}/".format(BINARY_DIR))
    os.makedirs("{}".format(BINARY_DIR))

    liteserv = LiteServFactory.create("ios",
                                      version_build=ios_version,
                                      host=ios_host,
                                      port=59840,
                                      storage_engine="SQLite")

    liteserv.download()
def liteserv_with_storage_engine_from_fixture(request):

    macosx_version = request.config.getoption("--macosx-version")

    liteserv = LiteServFactory.create("macosx",
                                      version_build=macosx_version,
                                      host="localhost",
                                      port=59840,
                                      storage_engine=request.param)
    liteserv.download()
    liteserv.install()

    yield liteserv

    liteserv.remove()
def test_net_mono_download(request):

    shutil.rmtree("{}/".format(BINARY_DIR))
    os.makedirs("{}".format(BINARY_DIR))

    net_version = request.config.getoption("--net-version")

    liteserv = LiteServFactory.create(
        "net-mono", version_build=net_version, host="localhost", port=59840, storage_engine="SQLite"
    )

    liteserv.download()

    assert os.path.isdir("deps/binaries/couchbase-lite-net-mono-{}-liteserv".format(net_version))
    assert os.path.isfile("deps/binaries/couchbase-lite-net-mono-{}-liteserv/LiteServ.exe".format(net_version))
    assert not os.path.isfile("deps/binaries/couchbase-lite-net-mono-{}-liteserv.zip".format(net_version))
def setup_liteserv_ios_no_launch(request):

    ios_version = request.config.getoption("--ios-version")
    ios_host = request.config.getoption("--ios-host")

    liteserv = LiteServFactory.create("ios",
                                      version_build=ios_version,
                                      host=ios_host,
                                      port=59840,
                                      storage_engine="SQLite")
    liteserv.download()
    liteserv.install()

    yield liteserv

    liteserv.remove()
def setup_liteserv_ios_no_launch(request):

    ios_version = request.config.getoption("--ios-version")
    ios_host = request.config.getoption("--ios-host")

    liteserv = LiteServFactory.create("ios",
                                      version_build=ios_version,
                                      host=ios_host,
                                      port=59840,
                                      storage_engine="SQLite")
    liteserv.download()
    liteserv.install()

    yield liteserv

    liteserv.remove()
def liteserv_with_storage_engine_from_fixture(request):

    android_version = request.config.getoption("--android-version")
    android_host = request.config.getoption("--android-host")

    liteserv = LiteServFactory.create("android",
                                      version_build=android_version,
                                      host=android_host,
                                      port=59840,
                                      storage_engine=request.param)
    liteserv.download()
    liteserv.install()

    yield liteserv

    liteserv.remove()
def liteserv_with_storage_engine_from_fixture(request):

    ios_version = request.config.getoption("--ios-version")
    ios_host = request.config.getoption("--ios-host")

    liteserv = LiteServFactory.create("ios",
                                      version_build=ios_version,
                                      host=ios_host,
                                      port=59840,
                                      storage_engine=request.param)
    liteserv.download()
    liteserv.install()

    yield liteserv

    liteserv.remove()
def test_macosx_download(request):

    shutil.rmtree("{}/".format(BINARY_DIR))
    os.makedirs("{}".format(BINARY_DIR))

    macosx_version = request.config.getoption("--macosx-version")

    liteserv = LiteServFactory.create(
        "macosx", version_build=macosx_version, host="localhost", port=59840, storage_engine="SQLite"
    )

    liteserv.download()

    assert os.path.isdir("deps/binaries/couchbase-lite-macosx-enterprise_{}".format(macosx_version))
    assert os.path.isfile("deps/binaries/couchbase-lite-macosx-enterprise_{}/LiteServ".format(macosx_version))
    assert not os.path.isfile("deps/binaries/couchbase-lite-macosx-enterprise_{}.zip".format(macosx_version))
def liteserv_with_storage_engine_from_fixture(request):

    net_version = request.config.getoption("--net-version")
    net_msft_host = request.config.getoption("--net-msft-host")

    liteserv = LiteServFactory.create("net-msft",
                                      version_build=net_version,
                                      host=net_msft_host,
                                      port=59840,
                                      storage_engine=request.param)
    liteserv.download()
    liteserv.install()

    yield liteserv

    liteserv.remove()
def test_android_install_and_remove(request):

    android_version = request.config.getoption("--android-version")
    android_host = request.config.getoption("--android-host")

    liteserv = LiteServFactory.create("android",
                                      version_build=android_version,
                                      host=android_host,
                                      port=59840,
                                      storage_engine="SQLite")

    liteserv.download()
    liteserv.install()

    output = subprocess.check_output(["adb", "shell", "pm", "list", "packages"])
    assert "com.couchbase.liteservandroid" in output

    liteserv.remove()

    output = subprocess.check_output(["adb", "shell", "pm", "list", "packages"])
    assert "com.couchbase.liteservandroid" not in output
예제 #24
0
def test_running_liteserv(request):
    liteserv = LiteServFactory.create("macosx",
                                      version_build="1.3.1-6",
                                      host="localhost",
                                      port=59840,
                                      storage_engine="SQLite")

    liteserv.download()

    test_name = request.node.name

    logfile = "{}/logs/{}-{}-{}-1.txt".format(RESULTS_DIR, type(liteserv).__name__, test_name, datetime.datetime.now())
    liteserv.start(logfile)

    logfile_2 = "{}/logs/{}-{}-{}-2.txt".format(RESULTS_DIR, type(liteserv).__name__, test_name, datetime.datetime.now())
    with pytest.raises(LiteServError) as lse:
        liteserv.start(logfile_2)

    ex_message = str(lse.value)
    assert ex_message == "There should be no service running on the port"

    liteserv.stop()
def test_android_install_and_remove(request):

    android_version = request.config.getoption("--android-version")
    android_host = request.config.getoption("--android-host")

    liteserv = LiteServFactory.create("android",
                                      version_build=android_version,
                                      host=android_host,
                                      port=59840,
                                      storage_engine="SQLite")

    liteserv.download()
    liteserv.install()

    output = subprocess.check_output(
        ["adb", "shell", "pm", "list", "packages"])
    assert "com.couchbase.liteservandroid" in output

    liteserv.remove()

    output = subprocess.check_output(
        ["adb", "shell", "pm", "list", "packages"])
    assert "com.couchbase.liteservandroid" not in output
def test_macosx_download(request):

    shutil.rmtree("{}/".format(BINARY_DIR))
    os.makedirs("{}".format(BINARY_DIR))

    macosx_version = request.config.getoption("--macosx-version")

    liteserv = LiteServFactory.create("macosx",
                                      version_build=macosx_version,
                                      host="localhost",
                                      port=59840,
                                      storage_engine="SQLite")

    liteserv.download()

    assert os.path.isdir(
        "deps/binaries/couchbase-lite-macosx-enterprise_{}".format(
            macosx_version))
    assert os.path.isfile(
        "deps/binaries/couchbase-lite-macosx-enterprise_{}/LiteServ".format(
            macosx_version))
    assert not os.path.isfile(
        "deps/binaries/couchbase-lite-macosx-enterprise_{}.zip".format(
            macosx_version))
def test_net_mono_download(request):

    shutil.rmtree("{}/".format(BINARY_DIR))
    os.makedirs("{}".format(BINARY_DIR))

    net_version = request.config.getoption("--net-version")

    liteserv = LiteServFactory.create("net-mono",
                                      version_build=net_version,
                                      host="localhost",
                                      port=59840,
                                      storage_engine="SQLite")

    liteserv.download()

    assert os.path.isdir(
        "deps/binaries/couchbase-lite-net-mono-{}-liteserv".format(
            net_version))
    assert os.path.isfile(
        "deps/binaries/couchbase-lite-net-mono-{}-liteserv/net45/LiteServ.exe".
        format(net_version))
    assert not os.path.isfile(
        "deps/binaries/couchbase-lite-net-mono-{}-liteserv.zip".format(
            net_version))
예제 #28
0
def setup_client_syncgateway_suite(request):

    """Suite setup fixture for client sync_gateway tests"""

    log_info("Setting up client sync_gateway suite ...")

    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")

    skip_provisioning = request.config.getoption("--skip-provisioning")
    sync_gateway_version = request.config.getoption("--sync-gateway-version")
    sync_gateway_mode = request.config.getoption("--sync-gateway-mode")

    server_version = request.config.getoption("--server-version")
    xattrs_enabled = request.config.getoption("--xattrs")
    device_enabled = request.config.getoption("--device")

    liteserv = LiteServFactory.create(platform=liteserv_platform,
                                      version_build=liteserv_version,
                                      host=liteserv_host,
                                      port=liteserv_port,
                                      storage_engine=liteserv_storage_engine)

    if xattrs_enabled and version_is_binary(sync_gateway_version):
            check_xattr_support(server_version, sync_gateway_version)

    log_info("Downloading LiteServ ...")
    # Download LiteServ
    liteserv.download()

    # Install LiteServ
    if device_enabled and liteserv_platform == "ios":
        liteserv.install_device()
    else:
        liteserv.install()

    cluster_config = "{}/base_{}".format(CLUSTER_CONFIGS_DIR, sync_gateway_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)

    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("listener_tests/listener_tests", sync_gateway_mode)

    if not skip_provisioning:
        log_info("Installing Sync Gateway + Couchbase Server + Accels ('di' only)")
        cluster_utils = ClusterKeywords()
        cluster_utils.provision_cluster(
            cluster_config=cluster_config,
            server_version=server_version,
            sync_gateway_version=sync_gateway_version,
            sync_gateway_config=sg_config
        )

    # Wait at the yeild until tests referencing this suite setup have run,
    # Then execute the teardown
    yield {
        "liteserv": liteserv,
        "cluster_config": cluster_config,
        "sg_mode": sync_gateway_mode,
        "xattrs_enabled": xattrs_enabled,
        "device_enabled": device_enabled,
        "liteserv_platform": liteserv_platform,
        "liteserv_version": liteserv_version
    }

    log_info("Tearing down suite ...")
    if not (device_enabled and liteserv_platform == "ios"):
        liteserv.remove()
예제 #29
0
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' ...")
def remove_liteserv(platform, version_build, host, port, storage_engine):

    liteserv = LiteServFactory.create(
        platform=platform, version_build=version_build, host=host, port=port, storage_engine=storage_engine
    )
    liteserv.remove()