コード例 #1
0
ファイル: provisioner_test.py プロジェクト: stu-elastic/rally
    def test_invokes_hook_no_java_home(self):
        installer = provisioner.ElasticsearchInstaller(
            car=team.Car(names="defaults",
                         root_path="/tmp",
                         config_paths="/tmp/templates",
                         variables={"data_paths": "/tmp/some/data-path-dir"}),
            java_home=None,
            node_name="rally-node-0",
            all_node_ips=["10.17.22.22", "10.17.22.23"],
            all_node_names=["rally-node-0", "rally-node-1"],
            ip="10.17.22.23",
            http_port=9200,
            node_root_dir="~/.rally/benchmarks/races/unittest",
            hook_handler_class=NoopHookHandler)

        self.assertEqual(0, len(installer.hook_handler.hook_calls))
        installer.invoke_install_hook(team.BootstrapPhase.post_install,
                                      {"foo": "bar"})
        self.assertEqual(1, len(installer.hook_handler.hook_calls))
        self.assertEqual(
            {"foo": "bar"},
            installer.hook_handler.hook_calls["post_install"]["variables"])
        self.assertEqual(
            {"env": {}},
            installer.hook_handler.hook_calls["post_install"]["kwargs"])
コード例 #2
0
    def test_prepare_user_provided_data_path(self, mock_rm, mock_ensure_dir,
                                             mock_decompress):
        installer = provisioner.ElasticsearchInstaller(
            car=team.Car(name="defaults",
                         config_paths="/tmp",
                         variables={"data_paths": "/tmp/some/data-path-dir"}),
            node_name="rally-node-0",
            all_node_ips=["10.17.22.22", "10.17.22.23"],
            ip="10.17.22.23",
            http_port=9200,
            node_root_dir="~/.rally/benchmarks/races/unittest")

        installer.install("/data/builds/distributions")
        self.assertEqual(installer.es_home_path,
                         "/install/elasticsearch-5.0.0-SNAPSHOT")

        self.assertEqual(
            {
                "cluster_name": "rally-benchmark",
                "node_name": "rally-node-0",
                "data_paths": ["/tmp/some/data-path-dir"],
                "log_path": "~/.rally/benchmarks/races/unittest/logs/server",
                "node_ip": "10.17.22.23",
                "network_host": "10.17.22.23",
                "http_port": "9200-9300",
                "transport_port": "9300-9400",
                "all_node_ips": "[\"10.17.22.22\",\"10.17.22.23\"]",
                "minimum_master_nodes": 2,
                "node_count_per_host": 1,
                "install_root_path": "/install/elasticsearch-5.0.0-SNAPSHOT"
            }, installer.variables)

        self.assertEqual(installer.data_paths, ["/tmp/some/data-path-dir"])
コード例 #3
0
ファイル: provisioner_test.py プロジェクト: tomcallahan/rally
    def test_prepare_without_plugins(self, mock_rm, mock_ensure_dir,
                                     mock_decompress):
        apply_config_calls = []

        def null_apply_config(source_root_path, target_root_path, config_vars):
            apply_config_calls.append(
                (source_root_path, target_root_path, config_vars))

        installer = provisioner.ElasticsearchInstaller(
            car=team.Car(
                name="unit-test-car",
                config_paths=["~/.rally/benchmarks/teams/default/my-car"],
                variables={"heap": "4g"}),
            node_name="rally-node-0",
            node_root_dir="~/.rally/benchmarks/races/unittest",
            all_node_ips=["10.17.22.22", "10.17.22.23"],
            ip="10.17.22.23",
            http_port=9200)

        p = provisioner.BareProvisioner(
            cluster_settings={"indices.query.bool.max_clause_count": 50000},
            es_installer=installer,
            plugin_installers=[],
            preserve=True,
            apply_config=null_apply_config)

        node_config = p.prepare(
            {"elasticsearch": "/opt/elasticsearch-5.0.0.tar.gz"})
        self.assertEqual(installer.car, node_config.car)
        self.assertEqual("/opt/elasticsearch-5.0.0", node_config.binary_path)
        self.assertEqual(["/opt/elasticsearch-5.0.0/data"],
                         node_config.data_paths)

        self.assertEqual(1, len(apply_config_calls))
        source_root_path, target_root_path, config_vars = apply_config_calls[0]

        self.assertEqual("~/.rally/benchmarks/teams/default/my-car",
                         source_root_path)
        self.assertEqual("/opt/elasticsearch-5.0.0", target_root_path)
        self.assertEqual(
            {
                "cluster_settings": {
                    "indices.query.bool.max_clause_count": 50000,
                },
                "heap": "4g",
                "cluster_name": "rally-benchmark",
                "node_name": "rally-node-0",
                "data_paths": ["/opt/elasticsearch-5.0.0/data"],
                "log_path": "~/.rally/benchmarks/races/unittest/logs/server",
                "heap_dump_path":
                "~/.rally/benchmarks/races/unittest/heapdump",
                "node_ip": "10.17.22.23",
                "network_host": "10.17.22.23",
                "http_port": "9200-9300",
                "transport_port": "9300-9400",
                "all_node_ips": "[\"10.17.22.22\",\"10.17.22.23\"]",
                "minimum_master_nodes": 2,
                "node_count_per_host": 1,
                "install_root_path": "/opt/elasticsearch-5.0.0"
            }, config_vars)
コード例 #4
0
    def test_prepare_default_data_paths(self, mock_rm, mock_ensure_dir, mock_decompress):
        installer = provisioner.ElasticsearchInstaller(car=team.Car(names="defaults",
                                                                    root_path=None,
                                                                    config_paths="/tmp"),
                                                       java_home="/usr/local/javas/java8",
                                                       node_name="rally-node-0",
                                                       all_node_ips=["10.17.22.22", "10.17.22.23"],
                                                       all_node_names=["rally-node-0", "rally-node-1"],
                                                       ip="10.17.22.23",
                                                       http_port=9200,
                                                       node_root_dir=HOME_DIR + "/.rally/benchmarks/races/unittest")

        installer.install("/data/builds/distributions")
        self.assertEqual(installer.es_home_path, "/install/elasticsearch-5.0.0-SNAPSHOT")

        self.assertEqual({
            "cluster_name": "rally-benchmark",
            "node_name": "rally-node-0",
            "data_paths": ["/install/elasticsearch-5.0.0-SNAPSHOT/data"],
            "log_path": HOME_DIR + "/.rally/benchmarks/races/unittest/logs/server",
            "heap_dump_path": HOME_DIR + "/.rally/benchmarks/races/unittest/heapdump",
            "node_ip": "10.17.22.23",
            "network_host": "10.17.22.23",
            "http_port": "9200-9300",
            "transport_port": "9300-9400",
            "all_node_ips": "[\"10.17.22.22\",\"10.17.22.23\"]",
            "all_node_names": "[\"rally-node-0\",\"rally-node-1\"]",
            "minimum_master_nodes": 2,
            "install_root_path": "/install/elasticsearch-5.0.0-SNAPSHOT"
        }, installer.variables)

        self.assertEqual(installer.data_paths, ["/install/elasticsearch-5.0.0-SNAPSHOT/data"])
コード例 #5
0
ファイル: provisioner_test.py プロジェクト: ynuosoft/rally
    def test_invokes_hook_with_java_home(self):
        installer = provisioner.ElasticsearchInstaller(
            car=team.Car(
                names="defaults",
                root_path="/tmp",
                config_paths="/tmp/templates",
                variables={
                    "data_paths": "/tmp/some/data-path-dir",
                },
            ),
            java_home="/usr/local/javas/java8",
            node_name="rally-node-0",
            all_node_ips=["10.17.22.22", "10.17.22.23"],
            all_node_names=["rally-node-0", "rally-node-1"],
            ip="10.17.22.23",
            http_port=9200,
            node_root_dir="~/.rally/benchmarks/races/unittest",
            hook_handler_class=NoopHookHandler,
        )

        assert len(installer.hook_handler.hook_calls) == 0
        installer.invoke_install_hook(team.BootstrapPhase.post_install,
                                      {"foo": "bar"})
        assert len(installer.hook_handler.hook_calls) == 1
        assert installer.hook_handler.hook_calls["post_install"][
            "variables"] == {
                "foo": "bar"
            }
        assert installer.hook_handler.hook_calls["post_install"]["kwargs"] == {
            "env": {
                "JAVA_HOME": "/usr/local/javas/java8"
            }
        }
コード例 #6
0
ファイル: provisioner_test.py プロジェクト: yodasantu/rally
    def test_cleanup_nothing_on_preserve(self, mock_path_exists, mock_rm):
        mock_path_exists.return_value = False

        installer = provisioner.ElasticsearchInstaller(car=team.Car("defaults", None, "/tmp"),
                                                       node_name="rally-node-0",
                                                       all_node_ips={"127.0.0.1"},
                                                       ip="127.0.0.1",
                                                       http_port=9200,
                                                       node_root_dir="~/.rally/benchmarks/races/unittest")
        installer.cleanup(preserve=True)

        self.assertEqual(0, mock_path_exists.call_count)
        self.assertEqual(0, mock_rm.call_count)
コード例 #7
0
    def test_cleanup_nothing_on_preserve(self, mock_path_exists, mock_rm):
        mock_path_exists.return_value = False

        installer = provisioner.ElasticsearchInstaller(car=team.Car("defaults", "/tmp"),
                                                       node_name="rally-node-0",
                                                       all_node_ips={"127.0.0.1"},
                                                       ip="127.0.0.1",
                                                       http_port=9200,
                                                       node_root_dir="~/.rally/benchmarks/races/unittest",
                                                       data_root_paths=["/tmp/some-data-path"])
        installer.cleanup(preserve=True)

        mock_path_exists.assert_not_called()
        mock_rm.assert_not_called()
コード例 #8
0
    def test_cleanup(self, mock_path_exists, mock_rm):
        mock_path_exists.return_value = True

        installer = provisioner.ElasticsearchInstaller(car=team.Car("defaults", "/tmp"),
                                                       node_name="rally-node-0",
                                                       all_node_ips={"127.0.0.1"},
                                                       ip="127.0.0.1",
                                                       http_port=9200,
                                                       node_root_dir="~/.rally/benchmarks/races/unittest",
                                                       data_root_paths=["/tmp/some-data-path"])

        installer.data_paths = ["/tmp/some/data-path-dir"]
        installer.cleanup(preserve=True)

        expected_dir_calls = [mock.call("/tmp/some/data-path-dir"), mock.call("/rally-root/track/challenge/es-bin")]
        mock_path_exists.mock_calls = expected_dir_calls
        mock_rm.mock_calls = expected_dir_calls
コード例 #9
0
    def test_cleanup(self, mock_path_exists, mock_rm):
        mock_path_exists.return_value = True

        installer = provisioner.ElasticsearchInstaller(car=team.Car(names="defaults",
                                                                    root_path=None,
                                                                    config_paths="/tmp",
                                                                    variables={"data_paths": "/tmp/some/data-path-dir"}),
                                                       java_home="/usr/local/javas/java8",
                                                       node_name="rally-node-0",
                                                       all_node_ips={"127.0.0.1"},
                                                       ip="127.0.0.1",
                                                       http_port=9200,
                                                       node_root_dir=HOME_DIR + "/.rally/benchmarks/races/unittest")
        installer.cleanup(preserve=True)

        expected_dir_calls = [mock.call("/tmp/some/data-path-dir"), mock.call("/rally-root/track/challenge/es-bin")]
        mock_path_exists.mock_calls = expected_dir_calls
        mock_rm.mock_calls = expected_dir_calls
コード例 #10
0
ファイル: provisioner_test.py プロジェクト: ynuosoft/rally
    def test_prepare_user_provided_data_path(self, mock_rm, mock_ensure_dir,
                                             mock_decompress):
        installer = provisioner.ElasticsearchInstaller(
            car=team.Car(
                names="defaults",
                root_path=None,
                config_paths="/tmp",
                variables={
                    "data_paths": "/tmp/some/data-path-dir",
                },
            ),
            java_home="/usr/local/javas/java8",
            node_name="rally-node-0",
            all_node_ips=["10.17.22.22", "10.17.22.23"],
            all_node_names=["rally-node-0", "rally-node-1"],
            ip="10.17.22.23",
            http_port=9200,
            node_root_dir="~/.rally/benchmarks/races/unittest",
        )

        installer.install("/data/builds/distributions")
        assert installer.es_home_path == "/install/elasticsearch-5.0.0-SNAPSHOT"

        assert installer.variables == {
            "cluster_name": "rally-benchmark",
            "node_name": "rally-node-0",
            "data_paths": ["/tmp/some/data-path-dir"],
            "log_path": "~/.rally/benchmarks/races/unittest/logs/server",
            "heap_dump_path": "~/.rally/benchmarks/races/unittest/heapdump",
            "node_ip": "10.17.22.23",
            "network_host": "10.17.22.23",
            "http_port": "9200",
            "transport_port": "9300",
            "all_node_ips": '["10.17.22.22","10.17.22.23"]',
            "all_node_names": '["rally-node-0","rally-node-1"]',
            "minimum_master_nodes": 2,
            "install_root_path": "/install/elasticsearch-5.0.0-SNAPSHOT",
        }

        assert installer.data_paths == ["/tmp/some/data-path-dir"]
コード例 #11
0
ファイル: provisioner_test.py プロジェクト: stu-elastic/rally
    def test_prepare_distribution_ge_63_with_plugins(self, mock_rm,
                                                     mock_ensure_dir,
                                                     mock_install,
                                                     mock_decompress):
        """
        Test that plugin.mandatory is set to the meta plugin name (e.g. `x-pack`) and not
        the specific plugin name (e.g. `x-pack-security`) for Elasticsearch >=6.3.0

        See: https://github.com/elastic/elasticsearch/pull/28710
        """
        apply_config_calls = []

        def null_apply_config(source_root_path, target_root_path, config_vars):
            apply_config_calls.append(
                (source_root_path, target_root_path, config_vars))

        installer = provisioner.ElasticsearchInstaller(
            car=team.Car(names="unit-test-car",
                         root_path=None,
                         config_paths=[
                             HOME_DIR +
                             "/.rally/benchmarks/teams/default/my-car"
                         ],
                         variables={
                             "heap": "4g",
                             "runtime.jdk": "8",
                             "runtime.jdk.bundled": "true"
                         }),
            java_home="/usr/local/javas/java8",
            node_name="rally-node-0",
            node_root_dir=HOME_DIR + "/.rally/benchmarks/races/unittest",
            all_node_ips=["10.17.22.22", "10.17.22.23"],
            all_node_names=["rally-node-0", "rally-node-1"],
            ip="10.17.22.23",
            http_port=9200)

        p = provisioner.BareProvisioner(
            cluster_settings={"indices.query.bool.max_clause_count": 50000},
            es_installer=installer,
            plugin_installers=[
                provisioner.PluginInstaller(
                    BareProvisionerTests.MockRallyTeamXPackPlugin(),
                    java_home="/usr/local/javas/java8",
                    hook_handler_class=BareProvisionerTests.NoopHookHandler)
            ],
            distribution_version="6.3.0",
            apply_config=null_apply_config)

        node_config = p.prepare(
            {"elasticsearch": "/opt/elasticsearch-6.3.0.tar.gz"})
        self.assertEqual({}, node_config.car_env)
        self.assertEqual("8", node_config.car_runtime_jdks)
        self.assertEqual("/opt/elasticsearch-6.3.0", node_config.binary_path)
        self.assertEqual(["/opt/elasticsearch-6.3.0/data"],
                         node_config.data_paths)

        self.assertEqual(1, len(apply_config_calls))
        source_root_path, target_root_path, config_vars = apply_config_calls[0]

        self.assertEqual(HOME_DIR + "/.rally/benchmarks/teams/default/my-car",
                         source_root_path)
        self.assertEqual("/opt/elasticsearch-6.3.0", target_root_path)

        self.maxDiff = None

        self.assertEqual(
            {
                "cluster_settings": {
                    "indices.query.bool.max_clause_count": 50000,
                    "plugin.mandatory": ["x-pack"]
                },
                "heap": "4g",
                "runtime.jdk": "8",
                "runtime.jdk.bundled": "true",
                "cluster_name": "rally-benchmark",
                "node_name": "rally-node-0",
                "data_paths": ["/opt/elasticsearch-6.3.0/data"],
                "log_path":
                HOME_DIR + "/.rally/benchmarks/races/unittest/logs/server",
                "heap_dump_path":
                HOME_DIR + "/.rally/benchmarks/races/unittest/heapdump",
                "node_ip": "10.17.22.23",
                "network_host": "10.17.22.23",
                "http_port": "9200",
                "transport_port": "9300",
                "all_node_ips": "[\"10.17.22.22\",\"10.17.22.23\"]",
                "all_node_names": "[\"rally-node-0\",\"rally-node-1\"]",
                "minimum_master_nodes": 2,
                "install_root_path": "/opt/elasticsearch-6.3.0",
                "plugin_name": "x-pack-security",
                "xpack_security_enabled": True
            }, config_vars)
コード例 #12
0
    def test_prepare_without_plugins(self, mock_rm, mock_ensure_dir,
                                     mock_decompress):
        apply_config_calls = []

        def null_apply_config(source_root_path, target_root_path, config_vars):
            apply_config_calls.append(
                (source_root_path, target_root_path, config_vars))

        installer = provisioner.ElasticsearchInstaller(
            car=team.Car(names="unit-test-car",
                         root_path=None,
                         config_paths=[
                             HOME_DIR +
                             "/.rally/benchmarks/teams/default/my-car"
                         ],
                         variables={
                             "heap": "4g",
                             "runtime.jdk": "8",
                             "runtime.jdk.bundled": "true"
                         }),
            java_home="/usr/local/javas/java8",
            node_name="rally-node-0",
            node_root_dir=HOME_DIR + "/.rally/benchmarks/races/unittest",
            all_node_ips=["10.17.22.22", "10.17.22.23"],
            all_node_names=["rally-node-0", "rally-node-1"],
            ip="10.17.22.23",
            http_port=9200)

        p = provisioner.BareProvisioner(es_installer=installer,
                                        plugin_installers=[],
                                        apply_config=null_apply_config)

        node_config = p.prepare(
            {"elasticsearch": "/opt/elasticsearch-5.0.0.tar.gz"})
        self.assertEqual("8", node_config.car_runtime_jdks)
        self.assertEqual("/opt/elasticsearch-5.0.0", node_config.binary_path)
        self.assertEqual(["/opt/elasticsearch-5.0.0/data"],
                         node_config.data_paths)

        self.assertEqual(1, len(apply_config_calls))
        source_root_path, target_root_path, config_vars = apply_config_calls[0]

        self.assertEqual(HOME_DIR + "/.rally/benchmarks/teams/default/my-car",
                         source_root_path)
        self.assertEqual("/opt/elasticsearch-5.0.0", target_root_path)
        self.assertEqual(
            {
                "cluster_settings": {},
                "heap": "4g",
                "runtime.jdk": "8",
                "runtime.jdk.bundled": "true",
                "cluster_name": "rally-benchmark",
                "node_name": "rally-node-0",
                "data_paths": ["/opt/elasticsearch-5.0.0/data"],
                "log_path":
                HOME_DIR + "/.rally/benchmarks/races/unittest/logs/server",
                "heap_dump_path":
                HOME_DIR + "/.rally/benchmarks/races/unittest/heapdump",
                "node_ip": "10.17.22.23",
                "network_host": "10.17.22.23",
                "http_port": "9200",
                "transport_port": "9300",
                "all_node_ips": "[\"10.17.22.22\",\"10.17.22.23\"]",
                "all_node_names": "[\"rally-node-0\",\"rally-node-1\"]",
                "minimum_master_nodes": 2,
                "install_root_path": "/opt/elasticsearch-5.0.0"
            }, config_vars)
コード例 #13
0
ファイル: provisioner_test.py プロジェクト: ynuosoft/rally
    def test_prepare_distribution_lt_63_with_plugins(self, mock_rm,
                                                     mock_ensure_dir,
                                                     mock_install,
                                                     mock_decompress):
        """
        Test that plugin.mandatory is set to the specific plugin name (e.g. `x-pack-security`) and not
        the meta plugin name (e.g. `x-pack`) for Elasticsearch <6.3

        See: https://github.com/elastic/elasticsearch/pull/28710
        """
        apply_config_calls = []

        def null_apply_config(source_root_path, target_root_path, config_vars):
            apply_config_calls.append(
                (source_root_path, target_root_path, config_vars))

        installer = provisioner.ElasticsearchInstaller(
            car=team.Car(
                names="unit-test-car",
                root_path=None,
                config_paths=[
                    HOME_DIR + "/.rally/benchmarks/teams/default/my-car"
                ],
                variables={
                    "heap": "4g",
                    "runtime.jdk": "8",
                    "runtime.jdk.bundled": "true",
                },
            ),
            java_home="/usr/local/javas/java8",
            node_name="rally-node-0",
            node_root_dir=HOME_DIR + "/.rally/benchmarks/races/unittest",
            all_node_ips=["10.17.22.22", "10.17.22.23"],
            all_node_names=["rally-node-0", "rally-node-1"],
            ip="10.17.22.23",
            http_port=9200,
        )

        p = provisioner.BareProvisioner(
            es_installer=installer,
            plugin_installers=[
                provisioner.PluginInstaller(
                    self.MockRallyTeamXPackPlugin(),
                    java_home="/usr/local/javas/java8",
                    hook_handler_class=self.NoopHookHandler,
                )
            ],
            distribution_version="6.2.3",
            apply_config=null_apply_config,
        )

        node_config = p.prepare(
            {"elasticsearch": "/opt/elasticsearch-5.0.0.tar.gz"})
        assert node_config.car_runtime_jdks == "8"
        assert node_config.binary_path == "/opt/elasticsearch-5.0.0"
        assert node_config.data_paths == ["/opt/elasticsearch-5.0.0/data"]

        assert len(apply_config_calls) == 1
        source_root_path, target_root_path, config_vars = apply_config_calls[0]

        assert source_root_path == HOME_DIR + "/.rally/benchmarks/teams/default/my-car"
        assert target_root_path == "/opt/elasticsearch-5.0.0"

        self.maxDiff = None

        assert config_vars == {
            "cluster_settings": {
                "plugin.mandatory": ["x-pack-security"]
            },
            "heap": "4g",
            "runtime.jdk": "8",
            "runtime.jdk.bundled": "true",
            "cluster_name": "rally-benchmark",
            "node_name": "rally-node-0",
            "data_paths": ["/opt/elasticsearch-5.0.0/data"],
            "log_path":
            HOME_DIR + "/.rally/benchmarks/races/unittest/logs/server",
            "heap_dump_path":
            HOME_DIR + "/.rally/benchmarks/races/unittest/heapdump",
            "node_ip": "10.17.22.23",
            "network_host": "10.17.22.23",
            "http_port": "9200",
            "transport_port": "9300",
            "all_node_ips": '["10.17.22.22","10.17.22.23"]',
            "all_node_names": '["rally-node-0","rally-node-1"]',
            "minimum_master_nodes": 2,
            "install_root_path": "/opt/elasticsearch-5.0.0",
            "plugin_name": "x-pack-security",
            "xpack_security_enabled": True,
        }