diff --git a/libbeat/scripts/Makefile b/libbeat/scripts/Makefile index 84667d37e6e4..8f06dd7c10e6 100755 --- a/libbeat/scripts/Makefile +++ b/libbeat/scripts/Makefile @@ -202,7 +202,7 @@ integration-tests: prepare-tests .PHONY: integration-tests-environment integration-tests-environment: ## @testing Runs the integration inside a virtual environment. This can be run on any docker-machine (local, remote) integration-tests-environment: prepare-tests build-image - ${DOCKER_COMPOSE} run beat make integration-tests RACE_DETECTOR=$(RACE_DETECTOR) DOCKER_COMPOSE_PROJECT_NAME=${DOCKER_COMPOSE_PROJECT_NAME} || docker inspect --format "{{json .State.Health }}" $$(${DOCKER_COMPOSE} ps -q) | jq && ${DOCKER_COMPOSE} logs --tail 200 + ${DOCKER_COMPOSE} run beat make integration-tests RACE_DETECTOR=$(RACE_DETECTOR) DOCKER_COMPOSE_PROJECT_NAME=${DOCKER_COMPOSE_PROJECT_NAME} || ${DOCKER_COMPOSE} logs --tail 200 # Runs the system tests .PHONY: system-tests diff --git a/x-pack/libbeat/docker-compose.yml b/x-pack/libbeat/docker-compose.yml index 2db1055ce0db..60b1d9bc0ae9 100644 --- a/x-pack/libbeat/docker-compose.yml +++ b/x-pack/libbeat/docker-compose.yml @@ -26,7 +26,7 @@ services: file: ${ES_BEATS}/testing/environments/${TESTING_ENVIRONMENT}.yml service: elasticsearch healthcheck: - test: ["CMD-SHELL", 'python -c ''import urllib, json; response = urllib.urlopen("http://elastic:changeme@localhost:9200/_cluster/health"); data = json.loads(response.read()); exit(1) if data["status"] != "green" else exit(0);'''] + test: ["CMD-SHELL", 'python -c ''import urllib, json; response = urllib.urlopen("http://myelastic:changeme@localhost:9200/_cluster/health"); data = json.loads(response.read()); exit(1) if data["status"] != "green" else exit(0);'''] retries: 1200 interval: 5s start_period: 60s @@ -37,7 +37,8 @@ services: - "http.host=0.0.0.0" - "xpack.security.enabled=true" - "xpack.license.self_generated.type=trial" - - ELASTIC_PASSWORD=changeme + - "xpack.security.authc.realms.file.file1.order=0" + command: bash -c "bin/elasticsearch-users useradd myelastic -r superuser -p changeme | /usr/local/bin/docker-entrypoint.sh eswrapper" kibana: depends_on: @@ -46,8 +47,8 @@ services: file: ${ES_BEATS}/testing/environments/${TESTING_ENVIRONMENT}.yml service: kibana healthcheck: - test: ["CMD-SHELL", 'python -c ''import urllib, json; response = urllib.urlopen("http://elastic:changeme@localhost:5601/api/status"); data = json.loads(response.read()); exit(1) if data["status"]["overall"]["state"] != "green" else exit(0);'''] + test: ["CMD-SHELL", 'python -c ''import urllib, json; response = urllib.urlopen("http://myelastic:changeme@localhost:5601/api/status"); data = json.loads(response.read()); exit(1) if data["status"]["overall"]["state"] != "green" else exit(0);'''] retries: 1200 interval: 5s start_period: 60s - command: /usr/local/bin/kibana-docker --xpack.security.enabled=true --elasticsearch.username=elastic --elasticsearch.password=changeme + command: /usr/local/bin/kibana-docker --xpack.security.enabled=true --elasticsearch.username=myelastic --elasticsearch.password=changeme diff --git a/x-pack/libbeat/tests/system/test_management.py b/x-pack/libbeat/tests/system/test_management.py index e63c0ba3d86f..21fea6101025 100644 --- a/x-pack/libbeat/tests/system/test_management.py +++ b/x-pack/libbeat/tests/system/test_management.py @@ -12,7 +12,6 @@ INTEGRATION_TESTS = os.environ.get('INTEGRATION_TESTS', False) -KIBANA_PASSWORD = 'changeme' TIMEOUT = 5 * 60 @@ -23,7 +22,7 @@ def setUp(self): # NOTES: Theses options are linked to the specific of the docker compose environment for # CM. self.es_host = os.getenv('ES_HOST', 'localhost') + ":" + os.getenv('ES_POST', '9200') - self.es_user = "elastic" + self.es_user = "myelastic" self.es_pass = "changeme" self.es = Elasticsearch([self.get_elasticsearch_url()], verify_certs=True) @@ -41,7 +40,7 @@ def test_enroll(self): config_content = open(config_path, 'r').read() - exit_code = self.enroll(KIBANA_PASSWORD) + exit_code = self.enroll(self.es_user, self.es_pass) assert exit_code == 0 @@ -74,7 +73,7 @@ def test_enroll_bad_pw(self): config_content = open(config_path, 'r').read() - exit_code = self.enroll('wrong password') + exit_code = self.enroll("not", 'wrong password') assert exit_code == 1 @@ -95,7 +94,7 @@ def test_fetch_configs(self): # Enroll the beat config_path = os.path.join(self.working_dir, "mockbeat.yml") self.render_config_template("mockbeat", config_path) - exit_code = self.enroll(KIBANA_PASSWORD) + exit_code = self.enroll(self.es_user, self.es_pass) assert exit_code == 0 index = self.random_index() @@ -162,7 +161,7 @@ def test_configs_cache(self): # Enroll the beat config_path = os.path.join(self.working_dir, "mockbeat.yml") self.render_config_template("mockbeat", config_path) - exit_code = self.enroll(KIBANA_PASSWORD) + exit_code = self.enroll(self.es_user, self.es_pass) assert exit_code == 0 index = self.random_index() @@ -209,10 +208,10 @@ def test_configs_cache(self): self.wait_documents(index, 1) proc.check_kill_and_wait() - def enroll(self, password): + def enroll(self, user, password): return self.run_beat( extra_args=["enroll", self.get_kibana_url(), - "--password", "env:PASS", "--force"], + "--password", "env:PASS", "--username", user, "--force"], logging_args=["-v", "-d", "*"], env={ 'PASS': password, @@ -227,7 +226,7 @@ def check_kibana_status(self): url = self.get_kibana_url() + "/api/status" r = requests.get(url, headers=headers, - auth=('elastic', KIBANA_PASSWORD)) + auth=(self.es_user, self.es_pass)) print(r.text) def create_and_assing_tag(self, blocks): @@ -244,7 +243,7 @@ def create_and_assing_tag(self, blocks): } r = requests.put(url, json=data, headers=headers, - auth=('elastic', KIBANA_PASSWORD)) + auth=(self.es_user, self.es_pass)) assert r.status_code in (200, 201) # Retrieve beat ID @@ -255,7 +254,7 @@ def create_and_assing_tag(self, blocks): data = {"assignments": [{"beatId": meta["uuid"], "tag": tag_name}]} url = self.get_kibana_url() + "/api/beats/agents_tags/assignments" r = requests.post(url, json=data, headers=headers, - auth=('elastic', KIBANA_PASSWORD)) + auth=(self.es_user, self.es_pass)) assert r.status_code == 200 def get_elasticsearch_url(self):