Skip to content

Changes to test scripts for docker install #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/install_latest_docker_in_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ echo \

# Install Docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
66 changes: 43 additions & 23 deletions testing/tests/api_tests/cluster/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,32 @@ def convertJsonFileToString(file_path):
@pytest.fixture(autouse=True)
def suppress_insecure_request_warning():
warnings.simplefilter("ignore", urllib3.exceptions.InsecureRequestWarning)


def test_host_search(es_host, es_port, username, password):

url = f"https://{es_host}:{es_port}/.ds-metrics-system.cpu-default-*/_search"
body = load_json_schema(f"{current_script_dir}/queries/hostsearch.json")
response = make_request(url, username, password, body=body)
#body = load_json_schema(f"{current_script_dir}/queries/hostsearch.json")
#response = make_request(url, username, password, body=body)
response = make_request(url, username, password)

assert response.status_code == 200, f"Expected 200, got {response.status_code}"
data = json.loads(response.text)

#assert "winlog" in data ["winlogbeat-imported"]["mappings"]["properties"]

# Getting the value of Root Key
for key in data:
rootKey = key


assert (data[rootKey]["total"]["value"] > 0)
assert ".ds-metrics-system.cpu-default" in data[rootKey]["hits"][0]["_index"]
assert ".ds-metrics-system.cpu-default" in data[rootKey]["hits"][0]["_index"]
assert (data[rootKey]["hits"][0]["_source"]["agent"]["name"] == "ubuntu-vm")
assert (data[rootKey]["hits"][0]["_source"]["agent"]["version"] == "8.15.3")
#assert (data[rootKey]["hits"][0]["_source"]["agent"]["name"] == "ubuntu-vm")
assert (data[rootKey]["hits"][0]["_source"]["agent"]["version"] == "8.15.5")
assert (data[rootKey]["hits"][0]["_source"]["data_stream"]["dataset"] == "system.cpu")
assert (data[rootKey]["hits"][0]["_source"]["ecs"]["version"] == "8.0.0")
assert (data[rootKey]["hits"][0]["_source"]["elastic_agent"]["version"] == "8.15.3")
assert (data[rootKey]["hits"][0]["_source"]["elastic_agent"]["version"] == "8.15.5")
assert (data[rootKey]["hits"][0]["_source"]["event"]["dataset"] == "system.cpu")
assert (data[rootKey]["hits"][0]["_source"]["host"]["hostname"] == "ubuntu-vm")
#assert (data[rootKey]["hits"][0]["_source"]["host"]["hostname"] == "ubuntu-vm")
assert (data[rootKey]["hits"][0]["_source"]["metricset"]["name"] == "cpu")
assert (data[rootKey]["hits"][0]["_source"]["service"]["type"] == "system")
assert "system" in data[rootKey]["hits"][0]["_source"]
Expand All @@ -68,14 +67,26 @@ def test_logs_mapping(es_host, es_port, username, password):
assert ".ds-logs-elastic_agent.endpoint_security-default-" in response.text
assert ".ds-logs-elastic_agent-default-" in response.text
assert ".ds-logs-elastic_agent.filebeat-default-" in response.text
assert ".ds-logs-system.auth-default-" in response.text
assert ".ds-logs-endpoint.events.network-default-" in response.text
assert ".ds-logs-system.syslog-default-" in response.text
#assert ".ds-logs-system.auth-default-" in response.text

#assert ".ds-logs-endpoint.events.network-default-" in response.text

#assert ".ds-logs-system.syslog-default-" in response.text
assert ".ds-logs-elastic_agent.fleet_server-default-" in response.text
assert ".ds-logs-endpoint.events.file-default-" in response.text
assert ".ds-logs-endpoint.events.process-default-" in response.text
assert ".ds-logs-elastic_agent.metricbeat-default-" in response.text

assert ".ds-logs-endpoint.events.network-default-" in response.text

#assert ".ds-logs-endpoint.events.library-default-" in response.text
assert ".ds-logs-system.application-default-" in response.text
assert ".ds-logs-system.system-default-" in response.text
#assert ".ds-logs-endpoint.events.api-default-" in response.text
assert ".ds-logs-system.security-default-" in response.text
#assert ".ds-logs-endpoint.events.security-default-" in response.text
assert ".ds-logs-endpoint.events.registry-default-" in response.text

def test_logs_settings(es_host, es_port, username, password):

url = f"https://{es_host}:{es_port}/logs-*/_settings"
Expand All @@ -88,10 +99,18 @@ def test_logs_settings(es_host, es_port, username, password):
assert ".ds-logs-endpoint.events.file-default-" in response.text
assert ".ds-logs-elastic_agent.endpoint_security-default-" in response.text
assert ".ds-logs-elastic_agent-default-" in response.text
assert ".ds-logs-system.syslog-default-" in response.text
#assert ".ds-logs-system.syslog-default-" in response.text
assert ".ds-logs-elastic_agent.filebeat-default-" in response.text
assert ".ds-logs-system.auth-default-" in response.text
#assert ".ds-logs-system.auth-default-" in response.text
assert ".ds-logs-endpoint.events.network-default-" in response.text

assert ".ds-logs-endpoint.events.library-default-" in response.text
assert ".ds-logs-system.system-default-" in response.text
assert ".ds-logs-system.application-default-" in response.text
assert ".ds-logs-endpoint.events.registry-default-" in response.text
#assert ".ds-logs-endpoint.events.api-default-" in response.text
assert ".ds-logs-system.security-default-" in response.text
#assert ".ds-logs-endpoint.events.security-default-" in response.text

#@pytest.mark.skip(reason="Test is currently failing on develop branch")
def test_elastic_agent_logs_search(es_host, es_port, username, password):
Expand All @@ -117,12 +136,12 @@ def test_elastic_agent_logs_search(es_host, es_port, username, password):
assert "type" in data[rootKey]["hits"][x]["_source"]["agent"]
assert "ephemeral_id" in data[rootKey]["hits"][x]["_source"]["agent"]
assert "version" in data[rootKey]["hits"][x]["_source"]["agent"]
assert data[rootKey]["hits"][x]["_source"]["agent"]["version"]=="8.15.3"
assert data[rootKey]["hits"][x]["_source"]["agent"]["version"]=="8.15.5"
assert "log" in data[rootKey]["hits"][x]["_source"]
assert "offset" in data[rootKey]["hits"][x]["_source"]["log"]
assert "id" in data[rootKey]["hits"][x]["_source"]["elastic_agent"]
assert "version" in data[rootKey]["hits"][x]["_source"]["elastic_agent"]
assert data[rootKey]["hits"][x]["_source"]["elastic_agent"]["version"]=="8.15.3"
assert data[rootKey]["hits"][x]["_source"]["elastic_agent"]["version"]=="8.15.5"
assert "snapshot" in data[rootKey]["hits"][x]["_source"]["elastic_agent"]
assert "message" in data[rootKey]["hits"][x]["_source"]
assert "file.line" in data[rootKey]["hits"][x]["_source"]["log.origin"]
Expand All @@ -145,7 +164,7 @@ def test_metrics_mapping(es_host, es_port, username, password):
response = make_request(url, username, password)

assert response.status_code == 200, f"Expected 200, got {response.status_code}"
assert ".ds-metrics-system.process.summary-default" in response.text
#assert ".ds-metrics-system.process.summary-default" in response.text
assert ".ds-metrics-system.memory-default-" in response.text
assert ".ds-metrics-elastic_agent.endpoint_security-default-" in response.text
assert ".ds-metrics-system.cpu-default-" in response.text
Expand All @@ -155,7 +174,7 @@ def test_metrics_mapping(es_host, es_port, username, password):
assert ".ds-metrics-system.diskio-default-" in response.text
assert ".ds-metrics-endpoint.policy-default-" in response.text
assert ".ds-metrics-system.socket_summary-default-" in response.text
assert ".ds-metrics-system.load-default-" in response.text
#assert ".ds-metrics-system.load-default-" in response.text
assert ".ds-metrics-fleet_server.agent_status-default-" in response.text
assert "metrics-endpoint.metadata_current_default" in response.text
assert ".ds-metrics-elastic_agent.elastic_agent-default-" in response.text
Expand All @@ -169,6 +188,7 @@ def test_metrics_mapping(es_host, es_port, username, password):
assert ".ds-metrics-system.uptime-default-" in response.text
assert ".ds-metrics-system.filesystem-default-" in response.text

assert ".ds-metrics-system.process.summary-default-" in response.text

def test_metrics_settings(es_host, es_port, username, password):

Expand All @@ -179,7 +199,7 @@ def test_metrics_settings(es_host, es_port, username, password):
assert ".ds-metrics-system.process.summary-default-" in response.text
assert ".ds-metrics-system.fsstat-default-" in response.text
assert ".ds-metrics-elastic_agent.fleet_server-default-" in response.text
assert ".ds-metrics-system.load-default-" in response.text
#assert ".ds-metrics-system.load-default-" in response.text
assert ".ds-metrics-endpoint.metrics-default-" in response.text
assert ".ds-metrics-endpoint.policy-default-" in response.text
assert ".ds-metrics-elastic_agent.filebeat-default-" in response.text
Expand Down Expand Up @@ -328,8 +348,8 @@ def test_elastic_indices(es_host, es_port, username, password):
assert ("open .ds-logs-elastic_agent.endpoint_security-default" in response.text)
assert ("open elastalert_status_status" in response.text)
assert ("open elastalert_status_past" in response.text)
assert ("open .ds-logs-system.auth-default" in response.text)
assert ("open .ds-logs-system.syslog-default" in response.text)
#assert ("open .ds-logs-system.auth-default" in response.text)
#assert ("open .ds-logs-system.syslog-default" in response.text)
assert ("open .ds-logs-endpoint.events.network-default" in response.text)
assert ("open .ds-logs-endpoint.events.file-default" in response.text)
assert ("open wazuh-alerts-4.x" in response.text)
Expand Down
Loading