Esempio n. 1
0
    def test_create_simple_config_no_java_detected(
            self, path_exists, normalize_path, guess_install_location,
            guess_java_home, major_jvm_version, jvm_is_early_access_release):
        guess_install_location.side_effect = ["/tests/usr/bin/git"]
        guess_java_home.return_value = None
        normalize_path.side_effect = [
            "/home/user/.rally/benchmarks", "/tests/java10/home",
            "/tests/java8/home", "/home/user/.rally/benchmarks/src"
        ]
        major_jvm_version.return_value = 10
        jvm_is_early_access_release.return_value = False
        path_exists.return_value = True

        f = config.ConfigFactory(i=MockInput([
            "/tests/java10/home", "/Projects/elasticsearch/src",
            "/tests/java8/home"
        ]),
                                 o=null_output)

        config_store = InMemoryConfigStore("test")
        f.create_config(config_store)

        self.assertIsNotNone(config_store.config)
        self.assertTrue("runtime" in config_store.config)
        self.assertEqual("/tests/java8/home",
                         config_store.config["runtime"]["java.home"])
Esempio n. 2
0
    def test_create_simple_config(self, guess_install_location,
                                  guess_java_home):
        guess_install_location.side_effect = [
            "/tests/usr/bin/git", "/tests/usr/bin/gradle"
        ]
        guess_java_home.return_value = "/tests/java8/home"
        mock_input = MockInput(["/Projects/elasticsearch/src"])

        f = config.ConfigFactory(i=mock_input, sec_i=mock_input, o=null_output)

        config_store = InMemoryConfigStore("test")
        f.create_config(config_store)
        self.assertIsNotNone(config_store.config)
        self.assertTrue("meta" in config_store.config)
        self.assertEqual("8", config_store.config["meta"]["config.version"])
        self.assertTrue("system" in config_store.config)
        self.assertEqual("local", config_store.config["system"]["env.name"])
        self.assertTrue("source" in config_store.config)
        self.assertTrue("build" in config_store.config)
        self.assertEqual("/tests/usr/bin/gradle",
                         config_store.config["build"]["gradle.bin"])
        self.assertTrue("runtime" in config_store.config)
        self.assertEqual("/tests/java8/home",
                         config_store.config["runtime"]["java8.home"])
        self.assertTrue("benchmarks" in config_store.config)
        self.assertTrue("reporting" in config_store.config)
        self.assertEqual("in-memory",
                         config_store.config["reporting"]["datastore.type"])
        self.assertTrue("tracks" in config_store.config)
        self.assertTrue("defaults" in config_store.config)
        self.assertEqual(
            "False",
            config_store.config["defaults"]["preserve_benchmark_candidate"])
Esempio n. 3
0
    def test_create_simple_config(self, guess_install_location, working_copy):
        guess_install_location.side_effect = ["/tests/usr/bin/git"]
        # Rally checks in the parent and sibling directories whether there is an ES working copy. We don't want this detection logic
        # to succeed spuriously (e.g. on developer machines).
        working_copy.return_value = False
        mock_input = MockInput([""])

        f = config.ConfigFactory(i=mock_input, sec_i=mock_input, o=null_output)

        config_store = InMemoryConfigStore("test")
        f.create_config(config_store)
        self.assertIsNotNone(config_store.config)

        for section, _ in config_store.config.items():
            for k, v in config_store.config[section].items():
                print("%s::%s: %s" % (section, k, v))

        root_dir = io.normalize_path(os.path.abspath("./in-memory/benchmarks"))
        self.assertTrue("meta" in config_store.config)
        self.assertEqual(str(config.Config.CURRENT_CONFIG_VERSION), config_store.config["meta"]["config.version"])

        self.assertTrue("system" in config_store.config)
        self.assertEqual("local", config_store.config["system"]["env.name"])

        self.assertTrue("node" in config_store.config)

        self.assertEqual(root_dir, config_store.config["node"]["root.dir"])
        self.assertEqual(os.path.join(root_dir, "src"), config_store.config["node"]["src.root.dir"])

        self.assertTrue("source" in config_store.config)
        self.assertEqual("https://github.com/elastic/elasticsearch.git", config_store.config["source"]["remote.repo.url"])
        self.assertEqual("elasticsearch", config_store.config["source"]["elasticsearch.src.subdir"])

        self.assertTrue("benchmarks" in config_store.config)
        self.assertEqual(os.path.join(root_dir, "data"), config_store.config["benchmarks"]["local.dataset.cache"])

        self.assertTrue("reporting" in config_store.config)
        self.assertEqual("in-memory", config_store.config["reporting"]["datastore.type"])
        self.assertEqual("", config_store.config["reporting"]["datastore.host"])
        self.assertEqual("", config_store.config["reporting"]["datastore.port"])
        self.assertEqual("", config_store.config["reporting"]["datastore.secure"])
        self.assertEqual("", config_store.config["reporting"]["datastore.user"])
        self.assertEqual("", config_store.config["reporting"]["datastore.password"])

        self.assertTrue("tracks" in config_store.config)
        self.assertEqual("https://github.com/elastic/rally-tracks", config_store.config["tracks"]["default.url"])

        self.assertTrue("teams" in config_store.config)
        self.assertEqual("https://github.com/elastic/rally-teams", config_store.config["teams"]["default.url"])

        self.assertTrue("defaults" in config_store.config)
        self.assertEqual("False", config_store.config["defaults"]["preserve_benchmark_candidate"])

        self.assertTrue("distributions" in config_store.config)
        self.assertEqual("true", config_store.config["distributions"]["release.cache"])
Esempio n. 4
0
    def test_create_advanced_config(self):
        f = config.ConfigFactory(i=MockInput([
            # benchmark root directory
            "/var/data/rally",
            # src dir
            "/Projects/elasticsearch/src",
            # metrics store type (Elasticsearch)
            "2",
            # data_store_host
            "localhost",
            # data_store_port
            "9200",
            # data_store_secure
            "Yes",
            # data_store_user
            "user",
            # env
            "unittest-env",
            # preserve benchmark candidate
            "y"
        ]), sec_i=MockInput(["pw"]), o=null_output)

        config_store = InMemoryConfigStore("test")
        f.create_config(config_store, advanced_config=True)

        self.assertIsNotNone(config_store.config)
        self.assertTrue("meta" in config_store.config)
        self.assertEqual(str(config.Config.CURRENT_CONFIG_VERSION), config_store.config["meta"]["config.version"])
        self.assertTrue("system" in config_store.config)
        self.assertEqual("unittest-env", config_store.config["system"]["env.name"])
        self.assertTrue("node" in config_store.config)
        self.assertEqual("/var/data/rally", config_store.config["node"]["root.dir"])
        self.assertTrue("source" in config_store.config)
        self.assertTrue("benchmarks" in config_store.config)

        self.assertTrue("reporting" in config_store.config)
        self.assertEqual("elasticsearch", config_store.config["reporting"]["datastore.type"])
        self.assertEqual("localhost", config_store.config["reporting"]["datastore.host"])
        self.assertEqual("9200", config_store.config["reporting"]["datastore.port"])
        self.assertEqual("True", config_store.config["reporting"]["datastore.secure"])
        self.assertEqual("user", config_store.config["reporting"]["datastore.user"])
        self.assertEqual("pw", config_store.config["reporting"]["datastore.password"])

        self.assertTrue("tracks" in config_store.config)
        self.assertEqual("https://github.com/elastic/rally-tracks", config_store.config["tracks"]["default.url"])

        self.assertTrue("teams" in config_store.config)
        self.assertEqual("https://github.com/elastic/rally-teams", config_store.config["teams"]["default.url"])

        self.assertTrue("defaults" in config_store.config)
        self.assertEqual("True", config_store.config["defaults"]["preserve_benchmark_candidate"])

        self.assertTrue("distributions" in config_store.config)
        self.assertEqual("true", config_store.config["distributions"]["release.cache"])
Esempio n. 5
0
def ensure_configuration_present(cfg, args, sub_command):
    if sub_command == "configure":
        config.ConfigFactory().create_config(cfg.config_file,
                                             advanced_config=args.advanced_config,
                                             assume_defaults=args.assume_defaults)
        sys.exit(0)
    else:
        if cfg.config_present():
            cfg.load_config(auto_upgrade=True)
        else:
            console.error("No config present. Please run '%s configure' first." % PROGRAM_NAME)
            sys.exit(64)
Esempio n. 6
0
def ensure_configuration_present(cfg, args, sub_command):
    if sub_command == "configure":
        config.ConfigFactory().create_config(cfg.config_file, advanced_config=args.advanced_config, assume_defaults=args.assume_defaults)
        exit(0)
    else:
        if cfg.config_present():
            cfg.load_config()
            if not cfg.config_compatible():
                cfg.migrate_config()
                # Reload config after upgrading
                cfg.load_config()
        else:
            console.error("No config present. Please run '%s configure' first." % PROGRAM_NAME)
            exit(64)
Esempio n. 7
0
    def test_create_simple_config_no_java_installed(self,
                                                    guess_install_location,
                                                    guess_java_home):
        guess_install_location.side_effect = ["/tests/usr/bin/git"]
        guess_java_home.return_value = None

        # the input is the question for the JDK home and the JDK 10 home directory - the user does not define one
        f = config.ConfigFactory(i=MockInput(["", ""]), o=null_output)

        config_store = InMemoryConfigStore("test")
        f.create_config(config_store)

        self.assertIsNotNone(config_store.config)
        self.assertFalse("java.home" in config_store.config["runtime"])
        self.assertFalse("java10.home" in config_store.config["runtime"])
Esempio n. 8
0
def ensure_configuration_present(cfg, args, sub_command):
    if sub_command == "configure":
        # TODO dm: Consider creating a simple function
        config.ConfigFactory().create_config(cfg.config_file, advanced_config=args.advanced_config)
        exit(0)
    else:
        if cfg.config_present():
            cfg.load_config()
            if not cfg.config_compatible():
                cfg.migrate_config()
                # Reload config after upgrading
                cfg.load_config()
        else:
            print("Error: No config present. Please run '%s configure' first." % PROGRAM_NAME)
            exit(64)
Esempio n. 9
0
    def test_create_simple_config_no_java8_detected(self, path_exists, normalize_path, guess_install_location,
                                                    guess_java_home):
        guess_install_location.side_effect = ["/tests/usr/bin/git", "/tests/usr/bin/gradle"]
        guess_java_home.return_value = None
        normalize_path.return_value = "/tests/java8/home"
        path_exists.return_value = True

        f = config.ConfigFactory(i=MockInput(["/Projects/elasticsearch/src", "/tests/java8/home"]), o=null_output)

        config_store = InMemoryConfigStore("test")
        f.create_config(config_store)

        self.assertIsNotNone(config_store.config)
        self.assertTrue("runtime" in config_store.config)
        self.assertEqual("/tests/java8/home", config_store.config["runtime"]["java8.home"])
Esempio n. 10
0
    def test_create_advanced_config(self, guess_install_location,
                                    guess_java_home, is_ea_release):
        guess_install_location.side_effect = [
            "/tests/usr/bin/git", "/tests/usr/bin/gradle"
        ]
        guess_java_home.side_effect = [
            "/tests/java9/home", "/tests/java8/home"
        ]
        is_ea_release.return_value = True

        f = config.ConfigFactory(
            i=MockInput([
                # benchmark root directory
                "/var/data/rally",
                # src dir
                "/Projects/elasticsearch/src",
                # env
                "unittest-env",
                # data_store_host
                "localhost",
                # data_store_port
                "9200",
                # data_store_secure
                "Yes",
                # data_store_user
                "user",
                # preserve benchmark candidate
                "y"
            ]),
            sec_i=MockInput(["pw"]),
            o=null_output)

        config_store = InMemoryConfigStore("test")
        f.create_config(config_store, advanced_config=True)

        self.assertIsNotNone(config_store.config)
        self.assertTrue("meta" in config_store.config)
        self.assertEqual("11", config_store.config["meta"]["config.version"])
        self.assertTrue("system" in config_store.config)
        self.assertEqual("unittest-env",
                         config_store.config["system"]["env.name"])
        self.assertTrue("node" in config_store.config)
        self.assertEqual("/var/data/rally",
                         config_store.config["node"]["root.dir"])
        self.assertTrue("source" in config_store.config)
        self.assertTrue("build" in config_store.config)
        self.assertEqual("/tests/usr/bin/gradle",
                         config_store.config["build"]["gradle.bin"])
        self.assertTrue("runtime" in config_store.config)
        self.assertEqual("/tests/java8/home",
                         config_store.config["runtime"]["java.home"])
        self.assertTrue("benchmarks" in config_store.config)

        self.assertTrue("reporting" in config_store.config)
        self.assertEqual("elasticsearch",
                         config_store.config["reporting"]["datastore.type"])
        self.assertEqual("localhost",
                         config_store.config["reporting"]["datastore.host"])
        self.assertEqual("9200",
                         config_store.config["reporting"]["datastore.port"])
        self.assertEqual("True",
                         config_store.config["reporting"]["datastore.secure"])
        self.assertEqual("user",
                         config_store.config["reporting"]["datastore.user"])
        self.assertEqual(
            "pw", config_store.config["reporting"]["datastore.password"])

        self.assertTrue("tracks" in config_store.config)
        self.assertEqual("https://github.com/elastic/rally-tracks",
                         config_store.config["tracks"]["default.url"])

        self.assertTrue("teams" in config_store.config)
        self.assertEqual("https://github.com/elastic/rally-teams",
                         config_store.config["teams"]["default.url"])

        self.assertTrue("defaults" in config_store.config)
        self.assertEqual(
            "True",
            config_store.config["defaults"]["preserve_benchmark_candidate"])

        self.assertTrue("distributions" in config_store.config)
        self.assertEqual(
            "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-{{VERSION}}.tar.gz",
            config_store.config["distributions"]["release.1.url"])
        self.assertEqual(
            "https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/"
            "{{VERSION}}/elasticsearch-{{VERSION}}.tar.gz",
            config_store.config["distributions"]["release.2.url"])
        self.assertEqual(
            "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz",
            config_store.config["distributions"]["release.url"])
        self.assertEqual("true",
                         config_store.config["distributions"]["release.cache"])
Esempio n. 11
0
    def test_create_simple_config(self, guess_install_location,
                                  guess_java_home, is_ea_release):
        guess_install_location.side_effect = [
            "/tests/usr/bin/git", "/tests/usr/bin/gradle"
        ]
        guess_java_home.return_value = "/tests/java9/home"
        is_ea_release.return_value = False
        mock_input = MockInput(["/Projects/elasticsearch/src"])

        f = config.ConfigFactory(i=mock_input, sec_i=mock_input, o=null_output)

        config_store = InMemoryConfigStore("test")
        f.create_config(config_store)
        self.assertIsNotNone(config_store.config)

        for section, _ in config_store.config.items():
            for k, v in config_store.config[section].items():
                print("%s::%s: %s" % (section, k, v))

        self.assertTrue("meta" in config_store.config)
        self.assertEqual("11", config_store.config["meta"]["config.version"])

        self.assertTrue("system" in config_store.config)
        self.assertEqual("local", config_store.config["system"]["env.name"])

        self.assertTrue("node" in config_store.config)
        self.assertEqual("in-memory/benchmarks",
                         config_store.config["node"]["root.dir"])

        self.assertTrue("source" in config_store.config)
        self.assertEqual("/Projects/elasticsearch/src",
                         config_store.config["source"]["local.src.dir"])
        self.assertEqual("https://github.com/elastic/elasticsearch.git",
                         config_store.config["source"]["remote.repo.url"])

        self.assertTrue("build" in config_store.config)
        self.assertEqual("/tests/usr/bin/gradle",
                         config_store.config["build"]["gradle.bin"])

        self.assertTrue("runtime" in config_store.config)
        self.assertEqual("/tests/java9/home",
                         config_store.config["runtime"]["java.home"])

        self.assertTrue("benchmarks" in config_store.config)
        self.assertEqual(
            "${node:root.dir}/data",
            config_store.config["benchmarks"]["local.dataset.cache"])

        self.assertTrue("reporting" in config_store.config)
        self.assertEqual("in-memory",
                         config_store.config["reporting"]["datastore.type"])
        self.assertEqual("",
                         config_store.config["reporting"]["datastore.host"])
        self.assertEqual("",
                         config_store.config["reporting"]["datastore.port"])
        self.assertEqual("",
                         config_store.config["reporting"]["datastore.secure"])
        self.assertEqual("",
                         config_store.config["reporting"]["datastore.user"])
        self.assertEqual(
            "", config_store.config["reporting"]["datastore.password"])

        self.assertTrue("tracks" in config_store.config)
        self.assertEqual("https://github.com/elastic/rally-tracks",
                         config_store.config["tracks"]["default.url"])

        self.assertTrue("teams" in config_store.config)
        self.assertEqual("https://github.com/elastic/rally-teams",
                         config_store.config["teams"]["default.url"])

        self.assertTrue("defaults" in config_store.config)
        self.assertEqual(
            "False",
            config_store.config["defaults"]["preserve_benchmark_candidate"])

        self.assertTrue("distributions" in config_store.config)
        self.assertEqual(
            "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-{{VERSION}}.tar.gz",
            config_store.config["distributions"]["release.1.url"])
        self.assertEqual(
            "https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/"
            "{{VERSION}}/elasticsearch-{{VERSION}}.tar.gz",
            config_store.config["distributions"]["release.2.url"])
        self.assertEqual(
            "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz",
            config_store.config["distributions"]["release.url"])
        self.assertEqual("true",
                         config_store.config["distributions"]["release.cache"])
Esempio n. 12
0
    def test_create_simple_config(self, guess_install_location,
                                  guess_java_home, is_ea_release,
                                  working_copy):
        guess_install_location.side_effect = [
            "/tests/usr/bin/git", "/tests/usr/bin/gradle"
        ]
        guess_java_home.return_value = "/tests/java10/home"
        is_ea_release.return_value = False
        # Rally checks in the parent and sibling directories whether there is an ES working copy. We don't want this detection logic
        # to succeed spuriously (e.g. on developer machines).
        working_copy.return_value = False
        mock_input = MockInput([""])

        f = config.ConfigFactory(i=mock_input, sec_i=mock_input, o=null_output)

        config_store = InMemoryConfigStore("test")
        f.create_config(config_store)
        self.assertIsNotNone(config_store.config)

        for section, _ in config_store.config.items():
            for k, v in config_store.config[section].items():
                print("%s::%s: %s" % (section, k, v))

        self.assertTrue("meta" in config_store.config)
        self.assertEqual("14", config_store.config["meta"]["config.version"])

        self.assertTrue("system" in config_store.config)
        self.assertEqual("local", config_store.config["system"]["env.name"])

        self.assertTrue("node" in config_store.config)
        self.assertEqual(
            io.normalize_path(os.path.abspath("./in-memory/benchmarks")),
            config_store.config["node"]["root.dir"])
        self.assertEqual(
            io.normalize_path(os.path.abspath("./in-memory/benchmarks/src")),
            config_store.config["node"]["src.root.dir"])

        self.assertTrue("source" in config_store.config)
        self.assertEqual("https://github.com/elastic/elasticsearch.git",
                         config_store.config["source"]["remote.repo.url"])
        self.assertEqual(
            "elasticsearch",
            config_store.config["source"]["elasticsearch.src.subdir"])

        self.assertTrue("build" in config_store.config)
        self.assertEqual("/tests/usr/bin/gradle",
                         config_store.config["build"]["gradle.bin"])

        self.assertTrue("runtime" in config_store.config)
        self.assertEqual("/tests/java10/home",
                         config_store.config["runtime"]["java.home"])
        self.assertEqual("/tests/java10/home",
                         config_store.config["runtime"]["java10.home"])

        self.assertTrue("benchmarks" in config_store.config)
        self.assertEqual(
            "${node:root.dir}/data",
            config_store.config["benchmarks"]["local.dataset.cache"])

        self.assertTrue("reporting" in config_store.config)
        self.assertEqual("in-memory",
                         config_store.config["reporting"]["datastore.type"])
        self.assertEqual("",
                         config_store.config["reporting"]["datastore.host"])
        self.assertEqual("",
                         config_store.config["reporting"]["datastore.port"])
        self.assertEqual("",
                         config_store.config["reporting"]["datastore.secure"])
        self.assertEqual("",
                         config_store.config["reporting"]["datastore.user"])
        self.assertEqual(
            "", config_store.config["reporting"]["datastore.password"])

        self.assertTrue("tracks" in config_store.config)
        self.assertEqual("https://github.com/elastic/rally-tracks",
                         config_store.config["tracks"]["default.url"])

        self.assertTrue("teams" in config_store.config)
        self.assertEqual("https://github.com/elastic/rally-teams",
                         config_store.config["teams"]["default.url"])

        self.assertTrue("defaults" in config_store.config)
        self.assertEqual(
            "False",
            config_store.config["defaults"]["preserve_benchmark_candidate"])

        self.assertTrue("distributions" in config_store.config)
        self.assertEqual(
            "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-{{VERSION}}.tar.gz",
            config_store.config["distributions"]["release.1.url"])
        self.assertEqual(
            "https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/"
            "{{VERSION}}/elasticsearch-{{VERSION}}.tar.gz",
            config_store.config["distributions"]["release.2.url"])
        self.assertEqual(
            "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz",
            config_store.config["distributions"]["release.url"])
        self.assertEqual("true",
                         config_store.config["distributions"]["release.cache"])
Esempio n. 13
0
    def test_create_advanced_config(self, guess_install_location,
                                    guess_java_home):
        guess_install_location.side_effect = [
            "/tests/usr/bin/git", "/tests/usr/bin/gradle"
        ]
        guess_java_home.return_value = "/tests/java8/home"

        f = config.ConfigFactory(
            i=MockInput([
                # benchmark root directory
                "/var/data/rally",
                # src dir
                "/Projects/elasticsearch/src",
                # env
                "unittest-env",
                # data_store_host
                "localhost",
                # data_store_port
                "9200",
                # data_store_secure
                "Yes",
                # data_store_user
                "user",
                # preserve benchmark candidate
                "y"
            ]),
            sec_i=MockInput(["pw"]),
            o=null_output)

        config_store = InMemoryConfigStore("test")
        f.create_config(config_store, advanced_config=True)

        self.assertIsNotNone(config_store.config)
        self.assertTrue("meta" in config_store.config)
        self.assertEqual("8", config_store.config["meta"]["config.version"])
        self.assertTrue("system" in config_store.config)
        self.assertEqual("unittest-env",
                         config_store.config["system"]["env.name"])
        self.assertTrue("node" in config_store.config)
        self.assertEqual("/var/data/rally",
                         config_store.config["node"]["root.dir"])
        self.assertTrue("source" in config_store.config)
        self.assertTrue("build" in config_store.config)
        self.assertEqual("/tests/usr/bin/gradle",
                         config_store.config["build"]["gradle.bin"])
        self.assertTrue("runtime" in config_store.config)
        self.assertEqual("/tests/java8/home",
                         config_store.config["runtime"]["java8.home"])
        self.assertTrue("benchmarks" in config_store.config)
        self.assertTrue("reporting" in config_store.config)
        self.assertEqual("elasticsearch",
                         config_store.config["reporting"]["datastore.type"])
        self.assertEqual("localhost",
                         config_store.config["reporting"]["datastore.host"])
        self.assertEqual("9200",
                         config_store.config["reporting"]["datastore.port"])
        self.assertEqual("True",
                         config_store.config["reporting"]["datastore.secure"])
        self.assertEqual("user",
                         config_store.config["reporting"]["datastore.user"])
        self.assertEqual(
            "pw", config_store.config["reporting"]["datastore.password"])
        self.assertTrue("tracks" in config_store.config)
        self.assertTrue("defaults" in config_store.config)
        self.assertEqual(
            "True",
            config_store.config["defaults"]["preserve_benchmark_candidate"])