diff --git a/tests/pytest.ini b/tests/pytest.ini index 2ceff1e4..58ae1463 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -1,3 +1,5 @@ [pytest] filterwarnings = ignore::urllib3.exceptions.InsecureRequestWarning +markers = + large diff --git a/tests/test_docker_splunk.py b/tests/test_docker_splunk.py index 8ddaf96d..2bad7bbe 100644 --- a/tests/test_docker_splunk.py +++ b/tests/test_docker_splunk.py @@ -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): @@ -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") @@ -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: @@ -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): @@ -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: @@ -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): @@ -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: @@ -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")