def test_provisioning_with_variables(self, uuid4): uuid4.return_value = "86f42ae0-5840-4b5b-918d-41e7907cb644" node_root_dir = tempfile.gettempdir() log_dir = os.path.join(node_root_dir, "logs", "server") heap_dump_dir = os.path.join(node_root_dir, "heapdump") data_dir = os.path.join(node_root_dir, "data", "86f42ae0-5840-4b5b-918d-41e7907cb644") rally_root = os.path.normpath( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, "esrally")) c = team.Car("unit-test-car", None, "/tmp", variables={ "docker_image": "docker.elastic.co/elasticsearch/elasticsearch", "docker_mem_limit": "256m", "docker_cpu_count": 2 }) docker = provisioner.DockerProvisioner(car=c, node_name="rally-node-0", ip="10.17.22.33", http_port=39200, node_root_dir=node_root_dir, distribution_version="6.3.0", rally_root=rally_root) docker_cfg = docker._render_template_from_file( docker.docker_vars(mounts={})) self.assertEqual( """version: '2.2' services: elasticsearch1: cap_add: - IPC_LOCK image: "docker.elastic.co/elasticsearch/elasticsearch:6.3.0" labels: io.rally.description: "elasticsearch-rally" cpu_count: 2 mem_limit: 256m ports: - 39200:39200 - 9300 ulimits: memlock: soft: -1 hard: -1 volumes: - %s:/usr/share/elasticsearch/data - %s:/var/log/elasticsearch - %s:/usr/share/elasticsearch/heapdump healthcheck: test: nc -z 127.0.0.1 39200 interval: 5s timeout: 2s retries: 10""" % (data_dir, log_dir, heap_dump_dir), docker_cfg)
def test_docker_vars(self, total_memory): total_memory.return_value = convert.gb_to_bytes(64) tmp = tempfile.gettempdir() docker = provisioner.DockerProvisioner("defaults", "39200", tmp, "5.0.0", "../../") self.assertEqual({ "es_java_opts": "", "container_memory_gb": "32g", "es_data_dir": "%s/data" % tmp, "es_version": "5.0.0", "http_port": "39200" }, docker.docker_vars)
def test_docker_vars(self, total_memory): total_memory.return_value = convert.gb_to_bytes(64) tmp = tempfile.gettempdir() rally_root = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../esrally")) docker = provisioner.DockerProvisioner("defaults", {"indices.query.bool.max_clause_count": 5000}, "39200", tmp, "5.0.0", rally_root) self.assertEqual({ "es_java_opts": "", "container_memory_gb": "32g", "es_data_dir": "%s/data" % tmp, "es_version": "5.0.0", "http_port": "39200", "cluster_settings": { "indices.query.bool.max_clause_count": 5000 } }, docker.docker_vars) docker_cfg = docker._render_template_from_file(docker.docker_vars) self.assertEqual( """version: '2' services: elasticsearch1: cap_add: - IPC_LOCK environment: - discovery.zen.minimum_master_nodes=1 - bootstrap.memory_lock=true - xpack.security.enabled=false - "ES_JAVA_OPTS=" - indices.query.bool.max_clause_count=5000 image: "docker.elastic.co/elasticsearch/elasticsearch:5.0.0" mem_limit: 32g ports: - 39200:9200 - 9300 ulimits: memlock: soft: -1 hard: -1 nofile: soft: 65536 hard: 65536 volumes: - esdata1:%s/data volumes: esdata1: driver: local""" % tmp , docker_cfg )
def test_provisioning(self, uuid4, total_memory): total_memory.return_value = convert.gb_to_bytes(64) uuid4.return_value = "9dbc682e-d32a-4669-8fbe-56fb77120dd4" node_root_dir = tempfile.gettempdir() log_dir = os.path.join(node_root_dir, "logs", "server") data_dir = "%s/data/9dbc682e-d32a-4669-8fbe-56fb77120dd4" % node_root_dir rally_root = os.path.normpath( os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../esrally")) c = team.Car("unit-test-car", "/tmp", variables={"xpack.security.enabled": False}) docker = provisioner.DockerProvisioner( car=c, node_name="rally-node-0", cluster_settings={"indices.query.bool.max_clause_count": 5000}, ip="10.17.22.33", http_port=39200, node_root_dir=node_root_dir, distribution_version="5.0.0", rally_root=rally_root, preserve=False) self.assertEqual( { "cluster_name": "rally-benchmark", "node_name": "rally-node-0", "data_paths": ["/usr/share/elasticsearch/data"], "log_path": "/var/log/elasticsearch", "network_host": "0.0.0.0", "http_port": "39200-39300", "transport_port": "39300-39400", "node_count_per_host": 1, "cluster_settings": { "xpack.security.enabled": "false", "xpack.ml.enabled": "false", "xpack.monitoring.enabled": "false", "xpack.watcher.enabled": "false", "indices.query.bool.max_clause_count": 5000 }, "xpack.security.enabled": False }, docker.config_vars) self.assertEqual( { "es_data_dir": data_dir, "es_log_dir": log_dir, "es_version": "5.0.0", "http_port": 39200, "mounts": {} }, docker.docker_vars(mounts={})) docker_cfg = docker._render_template_from_file( docker.docker_vars(mounts={})) self.assertEqual( """version: '2' services: elasticsearch1: cap_add: - IPC_LOCK image: "docker.elastic.co/elasticsearch/elasticsearch:5.0.0" ports: - 39200:39200 - 9300 ulimits: memlock: soft: -1 hard: -1 volumes: - %s:/usr/share/elasticsearch/data - %s:/var/log/elasticsearch""" % (data_dir, log_dir), docker_cfg)
def test_provisioning_with_defaults(self, uuid4): uuid4.return_value = "9dbc682e-d32a-4669-8fbe-56fb77120dd4" node_root_dir = tempfile.gettempdir() log_dir = os.path.join(node_root_dir, "logs", "server") heap_dump_dir = os.path.join(node_root_dir, "heapdump") data_dir = os.path.join(node_root_dir, "data", "9dbc682e-d32a-4669-8fbe-56fb77120dd4") rally_root = os.path.normpath( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, "esrally")) c = team.Car("unit-test-car", None, "/tmp", variables={ "docker_image": "docker.elastic.co/elasticsearch/elasticsearch-oss" }) docker = provisioner.DockerProvisioner( car=c, node_name="rally-node-0", cluster_settings={"indices.query.bool.max_clause_count": 5000}, ip="10.17.22.33", http_port=39200, node_root_dir=node_root_dir, distribution_version="6.3.0", rally_root=rally_root) self.assertDictEqual( { "cluster_name": "rally-benchmark", "node_name": "rally-node-0", "install_root_path": "/usr/share/elasticsearch", "data_paths": ["/usr/share/elasticsearch/data"], "log_path": "/var/log/elasticsearch", "heap_dump_path": "/usr/share/elasticsearch/heapdump", "discovery_type": "single-node", "network_host": "0.0.0.0", "http_port": "39200", "transport_port": "39300", "cluster_settings": { "indices.query.bool.max_clause_count": 5000 }, "docker_image": "docker.elastic.co/elasticsearch/elasticsearch-oss" }, docker.config_vars) self.assertDictEqual( { "es_data_dir": data_dir, "es_log_dir": log_dir, "es_heap_dump_dir": heap_dump_dir, "es_version": "6.3.0", "docker_image": "docker.elastic.co/elasticsearch/elasticsearch-oss", "http_port": 39200, "mounts": {} }, docker.docker_vars(mounts={})) docker_cfg = docker._render_template_from_file( docker.docker_vars(mounts={})) self.assertEqual( """version: '2.2' services: elasticsearch1: cap_add: - IPC_LOCK image: "docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.0" labels: io.rally.description: "elasticsearch-rally" ports: - 39200:39200 - 9300 ulimits: memlock: soft: -1 hard: -1 volumes: - %s:/usr/share/elasticsearch/data - %s:/var/log/elasticsearch - %s:/usr/share/elasticsearch/heapdump healthcheck: test: nc -z 127.0.0.1 39200 interval: 5s timeout: 2s retries: 10""" % (data_dir, log_dir, heap_dump_dir), docker_cfg)
def test_provisioning_with_defaults(self, uuid4): uuid4.return_value = "9dbc682e-d32a-4669-8fbe-56fb77120dd4" node_ip = "10.17.22.33" node_root_dir = tempfile.gettempdir() log_dir = os.path.join(node_root_dir, "logs", "server") heap_dump_dir = os.path.join(node_root_dir, "heapdump") data_dir = os.path.join(node_root_dir, "data", "9dbc682e-d32a-4669-8fbe-56fb77120dd4") rally_root = os.path.normpath( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, "esrally")) c = team.Car( "unit-test-car", None, "/tmp", variables={ "docker_image": "docker.elastic.co/elasticsearch/elasticsearch-oss", }, ) docker = provisioner.DockerProvisioner( car=c, node_name="rally-node-0", ip=node_ip, http_port=39200, node_root_dir=node_root_dir, distribution_version="6.3.0", rally_root=rally_root, ) assert docker.config_vars == { "cluster_name": "rally-benchmark", "node_name": "rally-node-0", "install_root_path": "/usr/share/elasticsearch", "data_paths": ["/usr/share/elasticsearch/data"], "log_path": "/var/log/elasticsearch", "heap_dump_path": "/usr/share/elasticsearch/heapdump", "discovery_type": "single-node", "network_host": "0.0.0.0", "http_port": "39200", "transport_port": "39300", "cluster_settings": {}, "docker_image": "docker.elastic.co/elasticsearch/elasticsearch-oss", } assert docker.docker_vars(mounts={}) == { "es_data_dir": data_dir, "es_log_dir": log_dir, "es_heap_dump_dir": heap_dump_dir, "es_version": "6.3.0", "docker_image": "docker.elastic.co/elasticsearch/elasticsearch-oss", "http_port": 39200, "node_ip": node_ip, "mounts": {}, } docker_cfg = docker._render_template_from_file( docker.docker_vars(mounts={})) assert docker_cfg == (f'''version: '2.2' services: elasticsearch1: cap_add: - IPC_LOCK image: "docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.0" labels: io.rally.description: "elasticsearch-rally" ports: - 39200:39200 - 9300 ulimits: memlock: soft: -1 hard: -1 volumes: - {data_dir}:/usr/share/elasticsearch/data - {log_dir}:/var/log/elasticsearch - {heap_dump_dir}:/usr/share/elasticsearch/heapdump healthcheck: test: nc -z 127.0.0.1 39200 interval: 5s timeout: 2s retries: 10 networks: - rally-es networks: rally-es: driver_opts: com.docker.network.bridge.host_binding_ipv4: "{node_ip}"''')