def ites(args):
	es = Elasticsearch(args.offline_dir, args.url)

	# create a running instance of Elasticsearch if needed
	if args.url is None:
		es_reset = args.es_full_reset or args.es_reset
		if es_reset:
			es_dir = os.path.abspath(es_reset)
			es.reset(es_dir, args.es_full_reset is not None)
		else:
			assert(args.root_dir)
			root_dir = os.path.abspath(args.root_dir)
			if not args.version:
				toks = args.driver.split("-")
				for i in range(3, len(toks)):
					if re.match("\d+\.\d+\.\d+", toks[-i]):
						version = "-".join(toks[len(toks) - i : -2])
			else:
				version = args.version
			if not version:
				raise Exception("failed to determine Elasticsearch version to test against (params: driver: %s, "
						"version: %s)" % (args.driver, args.version))

			es.spawn(version, root_dir, args.ephemeral)
	elif not es.is_listening():
		raise Exception("no running prestaged Elasticsearch instance found.")
	else:
		print("Using pre-staged Elasticsearch.")

	# add test data into it
	if args.reindex or not (args.skip_indexing and args.skip_tests):
		if args.skip_indexing_tests:
			test_mode = TestData.MODE_NODATA
		elif args.skip_indexing:
			test_mode = TestData.MODE_NOINDEX
		elif args.reindex:
			test_mode = TestData.MODE_REINDEX
		else:
			test_mode = TestData.MODE_INDEX

		data = TestData(es, test_mode, args.offline_dir)
		data.load()

	# install the driver
	if args.driver:
		driver_path = os.path.abspath(args.driver)
		installer = Installer(driver_path)
		installer.install(args.ephemeral)

	# run the tests
	if not args.skip_tests:
		assert(data is not None)
		cluster_name = es.cluster_name()
		assert(len(cluster_name))
		if args.dsn:
			Testing(es, data, cluster_name, args.dsn).perform()
		else:
			Testing(es, data, cluster_name, "Packing=JSON;Compression=on;").perform()
			Testing(es, data, cluster_name, "Packing=CBOR;Compression=off;").perform()
Exemplo n.º 2
0
def ites(args):
    es = Elasticsearch(args.offline_dir)

    # create a running instance of Elasticsearch if needed
    if not args.pre_staged:
        if args.es_reset:
            es_dir = os.path.abspath(args.es_reset)
            es.reset(es_dir)
        else:
            assert (args.root_dir)
            root_dir = os.path.abspath(args.root_dir)
            if not args.version:
                toks = args.driver.split("-")
                for i in range(3, len(toks)):
                    if re.match("\d+\.\d+\.\d+", toks[-i]):
                        version = "-".join(toks[len(toks) - i:-2])
            else:
                version = args.version
            if not version:
                raise Exception(
                    "failed to determine Elasticsearch version to test against (params: driver: %s, "
                    "version: %s)" % (args.driver, args.version))

            es.spawn(version, root_dir, args.ephemeral)
    elif not es.is_listening(Elasticsearch.AUTH_PASSWORD):
        raise Exception("no running prestaged Elasticsearch instance found.")
    else:
        print("Using pre-staged Elasticsearch.")

    # add test data into it
    if args.reindex or not (args.skip_indexing and args.skip_tests):
        if args.skip_indexing:
            test_mode = TestData.MODE_NOINDEX
        elif args.reindex:
            test_mode = TestData.MODE_REINDEX
        else:
            test_mode = TestData.MODE_INDEX

        data = TestData(test_mode, args.offline_dir)
        data.load()

    # install the driver
    if args.driver:
        driver_path = os.path.abspath(args.driver)
        installer = Installer(driver_path)
        installer.install(args.ephemeral)

    # run the tests
    if not args.skip_tests:
        assert (data is not None)
        tests = Testing(data, args.dsn)
        tests.perform()