Skip to content
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: 2 additions & 0 deletions tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[pytest]
filterwarnings =
ignore::urllib3.exceptions.InsecureRequestWarning
markers =
large
58 changes: 53 additions & 5 deletions tests/test_docker_splunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def compose_up(self):
def get_number_of_containers(self, filename):
yml = {}
with open(filename, "r") as f:
yml = yaml.load(f)
yml = yaml.load(f, Loader=yaml.Loader)
return len(yml["services"])

def wait_for_containers(self, count, label=None, name=None, timeout=300):
Expand Down Expand Up @@ -2553,10 +2553,18 @@ def test_compose_1deployment1cm(self):
exec_command = self.client.exec_create(container["Id"], "ls /opt/splunk/etc/apps/splunk_app_example/local/", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "savedsearches.conf" in std_out
assert "app.conf" in std_out
exec_command = self.client.exec_create(container["Id"], "cat /opt/splunk/etc/apps/splunk_app_example/local/app.conf", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "state = disabled" in std_out
# Check that the app exists in etc/deployment-apps
exec_command = self.client.exec_create(container["Id"], "ls /opt/splunk/etc/deployment-apps/splunk_app_example/local/", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "savedsearches.conf" not in std_out
assert "savedsearches.conf" in std_out
assert "app.conf" in std_out
exec_command = self.client.exec_create(container["Id"], "cat /opt/splunk/etc/deployment-apps/splunk_app_example/local/app.conf", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "# Autogenerated file " == std_out
if container_name == "cm1":
# Check if the created file exists
exec_command = self.client.exec_create(container["Id"], "cat /opt/splunk/etc/users/admin/user-prefs/local/user-prefs.conf", user="splunk")
Expand All @@ -2575,6 +2583,14 @@ def test_compose_1deployment1cm(self):
status, content = self.handle_request_retry("GET", url, kwargs)
assert status == 200
assert json.loads(content)["entry"][0]["content"]["version"] == "0.0.1"
exec_command = self.client.exec_create(container["Id"], "ls /opt/splunk/etc/apps/splunk_app_example/local/", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "savedsearches.conf" in std_out
assert "app.conf" in std_out
exec_command = self.client.exec_create(container["Id"], "cat /opt/splunk/etc/apps/splunk_app_example/local/app.conf", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "# Autogenerated file" in std_out
assert "state = enabled" in std_out
except Exception as e:
self.logger.error(e)
if i < RETRIES-1:
Expand Down Expand Up @@ -2632,10 +2648,18 @@ def test_compose_1deployment1so(self):
exec_command = self.client.exec_create(container["Id"], "ls /opt/splunk/etc/apps/splunk_app_example/local/", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "savedsearches.conf" in std_out
assert "app.conf" in std_out
exec_command = self.client.exec_create(container["Id"], "cat /opt/splunk/etc/apps/splunk_app_example/local/app.conf", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "state = disabled" in std_out
# Check that the app exists in etc/deployment-apps
exec_command = self.client.exec_create(container["Id"], "ls /opt/splunk/etc/deployment-apps/splunk_app_example/local/", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "savedsearches.conf" not in std_out
assert "savedsearches.conf" in std_out
assert "app.conf" in std_out
exec_command = self.client.exec_create(container["Id"], "cat /opt/splunk/etc/deployment-apps/splunk_app_example/local/app.conf", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "# Autogenerated file " == std_out
if container_name == "so1":
RETRIES = 5
for i in range(RETRIES):
Expand All @@ -2646,6 +2670,14 @@ def test_compose_1deployment1so(self):
status, content = self.handle_request_retry("GET", url, kwargs)
assert status == 200
assert json.loads(content)["entry"][0]["content"]["version"] == "0.0.1"
exec_command = self.client.exec_create(container["Id"], "ls /opt/splunk/etc/apps/splunk_app_example/local/", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "savedsearches.conf" in std_out
assert "app.conf" in std_out
exec_command = self.client.exec_create(container["Id"], "cat /opt/splunk/etc/apps/splunk_app_example/local/app.conf", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "# Autogenerated file" in std_out
assert "state = enabled" in std_out
except Exception as e:
self.logger.error(e)
if i < RETRIES-1:
Expand Down Expand Up @@ -2703,10 +2735,18 @@ def test_compose_1deployment1uf(self):
exec_command = self.client.exec_create(container["Id"], "ls /opt/splunk/etc/apps/splunk_app_example/local/", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "savedsearches.conf" in std_out
assert "app.conf" in std_out
exec_command = self.client.exec_create(container["Id"], "cat /opt/splunk/etc/apps/splunk_app_example/local/app.conf", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "state = disabled" in std_out
# Check that the app exists in etc/deployment-apps
exec_command = self.client.exec_create(container["Id"], "ls /opt/splunk/etc/deployment-apps/splunk_app_example/local/", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "savedsearches.conf" not in std_out
assert "savedsearches.conf" in std_out
assert "app.conf" in std_out
exec_command = self.client.exec_create(container["Id"], "cat /opt/splunk/etc/deployment-apps/splunk_app_example/local/app.conf", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "# Autogenerated file " == std_out
if container_name == "uf1":
RETRIES = 5
for i in range(RETRIES):
Expand All @@ -2717,6 +2757,14 @@ def test_compose_1deployment1uf(self):
status, content = self.handle_request_retry("GET", url, kwargs)
assert status == 200
assert json.loads(content)["entry"][0]["content"]["version"] == "0.0.1"
exec_command = self.client.exec_create(container["Id"], "ls /opt/splunkforwarder/etc/apps/splunk_app_example/local/", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "savedsearches.conf" in std_out
assert "app.conf" in std_out
exec_command = self.client.exec_create(container["Id"], "cat /opt/splunkforwarder/etc/apps/splunk_app_example/local/app.conf", user="splunk")
std_out = self.client.exec_start(exec_command)
assert "# Autogenerated file" in std_out
assert "state = enabled" in std_out
except Exception as e:
self.logger.error(e)
if i < RETRIES-1:
Expand Down Expand Up @@ -3349,7 +3397,7 @@ def test_compose_3idx1cm_splunktcp_ssl(self):
assert "disabled = 0" in std_out
assert "[SSL]" in std_out
assert "serverCert = /tmp/defaults/cert.pem" in std_out
assert "[sslConfig]" in std_out
assert "[sslConfig]" not in std_out
assert "rootCA = /tmp/defaults/ca.pem" in std_out
if container_name == "cm1":
exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/system/local/outputs.conf", user="splunk")
Expand Down