From 43282f1d9bb3eb65bca23de583bf3f5c922c9d11 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Wed, 13 Dec 2023 15:38:31 -0800 Subject: [PATCH 01/18] fix tests for py3; --- base/redhat-8/install.sh | 2 +- tests/executor.py | 8 +- tests/test_single_splunk_image.py | 119 +++++++++++++++--------------- 3 files changed, 63 insertions(+), 66 deletions(-) diff --git a/base/redhat-8/install.sh b/base/redhat-8/install.sh index b9bf7ac0..03640082 100755 --- a/base/redhat-8/install.sh +++ b/base/redhat-8/install.sh @@ -78,7 +78,7 @@ microdnf remove -y make gcc openssl-devel bzip2-devel findutils glib2-devel glib microdnf clean all # Install busybox direct from the multiarch since EPEL isn't available yet for redhat8 -BUSYBOX_URL=${BUSYBOX_URL:=https://busybox.net/downloads/binaries/1.35.0-`arch`-linux-musl/busybox} +BUSYBOX_URL=${BUSYBOX_URL:=https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox} wget -O /bin/busybox ${BUSYBOX_URL} chmod +x /bin/busybox diff --git a/tests/executor.py b/tests/executor.py index c6026adc..1d8f0c14 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -19,9 +19,7 @@ from string import ascii_lowercase # Code to suppress insecure https warnings import urllib3 -from urllib3.exceptions import InsecureRequestWarning, SubjectAltNameWarning -urllib3.disable_warnings(InsecureRequestWarning) -urllib3.disable_warnings(SubjectAltNameWarning) +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # Define variables @@ -101,9 +99,9 @@ def get_container_logs(self, container_id): stream = self.client.logs(container_id, stream=True) output = "" for char in stream: - if "Ansible playbook complete" in char: + if "Ansible playbook complete" in char.decode(): break - output += char + output += char.decode() return output def cleanup_files(self, files): diff --git a/tests/test_single_splunk_image.py b/tests/test_single_splunk_image.py index 0743fe1f..6bc5fae5 100644 --- a/tests/test_single_splunk_image.py +++ b/tests/test_single_splunk_image.py @@ -16,9 +16,8 @@ from docker.types import Mount # Code to suppress insecure https warnings import urllib3 -from urllib3.exceptions import InsecureRequestWarning, SubjectAltNameWarning +from urllib3.exceptions import InsecureRequestWarning urllib3.disable_warnings(InsecureRequestWarning) -urllib3.disable_warnings(SubjectAltNameWarning) global PLATFORM @@ -82,7 +81,7 @@ def test_splunk_ulimit(self): # If the container is still running, we should be able to exec inside # Check that nproc limits are unlimited exec_command = self.client.exec_create(cid, "sudo -u splunk bash -c 'ulimit -u'") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "unlimited" in std_out except Exception as e: self.logger.error(e) @@ -131,11 +130,11 @@ def test_splunk_entrypoint_no_provision(self): # If the container is still running, we should be able to exec inside # Check that the git SHA exists in /opt/ansible exec_command = self.client.exec_create(cid, "cat /opt/ansible/version.txt") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert len(std_out.strip()) == 40 # Check that the wrapper-example directory does not exist exec_command = self.client.exec_create(cid, "ls /opt/ansible/") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "wrapper-example" not in std_out assert "docs" not in std_out except Exception as e: @@ -156,7 +155,7 @@ def test_splunk_uid_gid(self): # If the container is still running, we should be able to exec inside # Check that the git SHA exists in /opt/ansible exec_command = self.client.exec_create(cid, "id", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "uid=41812" in std_out assert "gid=41812" in std_out except Exception as e: @@ -330,7 +329,7 @@ def test_adhoc_1so_splunk_launch_conf(self): assert status == 200 # Check splunk-launch.conf exec_command = self.client.exec_create(cid, r'cat /opt/splunk/etc/splunk-launch.conf', user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "OPTIMISTIC_ABOUT_FILE_LOCKING=1" in std_out assert "HELLO=WORLD" in std_out except Exception as e: @@ -437,7 +436,7 @@ def test_adhoc_1so_reflexive_forwarding(self): assert status == 200 # Check the decrypted pass4SymmKey exec_command = self.client.exec_create(cid, "ls /opt/splunk/etc/system/local/", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "outputs.conf" not in std_out except Exception as e: self.logger.error(e) @@ -472,10 +471,10 @@ def test_adhoc_1so_splunk_pass4symmkey(self): assert status == 200 # Check the decrypted pass4SymmKey exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/system/local/server.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() pass4SymmKey = re.search(r'\[general\].*?pass4SymmKey = (.*?)\n', std_out, flags=re.MULTILINE|re.DOTALL).group(1).strip() exec_command = self.client.exec_create(cid, "/opt/splunk/bin/splunk show-decrypted --value '{}'".format(pass4SymmKey), user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "wubbalubbadubdub" in std_out except Exception as e: self.logger.error(e) @@ -510,7 +509,7 @@ def test_adhoc_1so_splunk_secret_env(self): assert status == 200 # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/auth/splunk.secret", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "wubbalubbadubdub" in std_out except Exception as e: self.logger.error(e) @@ -579,11 +578,11 @@ def test_adhoc_1so_preplaybook_with_sudo(self): assert status == 200 # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /tmp/i-am", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "batman" in std_out # Check file owner exec_command = self.client.exec_create(cid, r'stat -c \'%U\' /tmp/i-am') - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "root" in std_out except Exception as e: self.logger.error(e) @@ -620,11 +619,11 @@ def test_adhoc_1so_postplaybook(self): assert status == 200 # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /tmp/i-am", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "batman" in std_out # Check file owner exec_command = self.client.exec_create(cid, r'stat -c \'%U\' /tmp/i-am') - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "splunk" in std_out except Exception as e: self.logger.error(e) @@ -661,11 +660,11 @@ def test_adhoc_1so_postplaybook_with_sudo(self): assert status == 200 # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /tmp/i-am", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "batman" in std_out # Check file owner exec_command = self.client.exec_create(cid, r'stat -c \'%U\' /tmp/i-am') - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "root" in std_out except Exception as e: self.logger.error(e) @@ -821,7 +820,7 @@ def test_adhoc_1so_run_as_root(self): assert status == 200 # Check that root owns the splunkd process exec_command = self.client.exec_create(cid, "ps -u root", user="root") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "entrypoint.sh" in std_out assert "splunkd" in std_out except Exception as e: @@ -865,7 +864,7 @@ def test_adhoc_1so_declarative_password(self): self.client.exec_start(exec_command) # Execute ansible exec_command = self.client.exec_create(cid, "/sbin/entrypoint.sh start-and-exit") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() # Check splunk with the initial password assert self.check_splunkd("admin", "thisisarealpassword123", name=splunk_container_name) # Mutate the password so that ansible changes it on the next run @@ -921,7 +920,7 @@ def test_adhoc_1uf_declarative_password(self): self.client.exec_start(exec_command) # Execute ansible exec_command = self.client.exec_create(cid, "/sbin/entrypoint.sh start-and-exit") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() # Check splunk with the initial password assert self.check_splunkd("admin", "thisisarealpassword123", name=splunk_container_name) # Mutate the password so that ansible changes it on the next run @@ -968,12 +967,12 @@ def test_adhoc_1so_hec_idempotence(self): assert self.check_splunkd("admin", self.password, name=splunk_container_name) # Check that HEC endpoint is up - by default, the image will enable HEC exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/apps/splunk_httpinput/local/inputs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert std_out == '''[http] disabled = 0 ''' exec_command = self.client.exec_create(cid, "netstat -tuln", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN" in std_out # Create a new /tmp/defaults/default.yml to change desired HEC settings exec_command = self.client.exec_create(cid, "mkdir -p /tmp/defaults", user="splunk") @@ -998,7 +997,7 @@ def test_adhoc_1so_hec_idempotence(self): assert self.check_splunkd("admin", self.password, name=splunk_container_name) # Check the new HEC settings exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/apps/splunk_httpinput/local/inputs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert '''[http] disabled = 0 enableSSL = 0 @@ -1007,7 +1006,7 @@ def test_adhoc_1so_hec_idempotence(self): disabled = 0 token = hihihi''' in std_out exec_command = self.client.exec_create(cid, "netstat -tuln", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN" in std_out # Check HEC hec_port = self.client.port(cid, 9999)[0]["HostPort"] @@ -1034,7 +1033,7 @@ def test_adhoc_1so_hec_idempotence(self): assert self.check_splunkd("admin", self.password, name=splunk_container_name) # Check the new HEC settings exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/apps/splunk_httpinput/local/inputs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert '''[http] disabled = 0 enableSSL = 1 @@ -1043,7 +1042,7 @@ def test_adhoc_1so_hec_idempotence(self): disabled = 0 token = byebyebye''' in std_out exec_command = self.client.exec_create(cid, "netstat -tuln", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN" in std_out # Check HEC hec_port = self.client.port(cid, 8088)[0]["HostPort"] @@ -1068,7 +1067,7 @@ def test_adhoc_1so_hec_idempotence(self): assert self.check_splunkd("admin", self.password, name=splunk_container_name) # Check the new HEC settings exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/apps/splunk_httpinput/local/inputs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() # NOTE: The previous configuration still applies - we just deleted the former token assert '''[http] disabled = 0 @@ -1076,7 +1075,7 @@ def test_adhoc_1so_hec_idempotence(self): port = 8088''' in std_out assert "[http://splunk_hec_token]" not in std_out exec_command = self.client.exec_create(cid, "netstat -tuln", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN" in std_out # Disable HEC entirely exec_command = self.client.exec_create(cid, '''bash -c 'cat > /tmp/defaults/default.yml << EOL @@ -1095,11 +1094,11 @@ def test_adhoc_1so_hec_idempotence(self): assert self.check_splunkd("admin", self.password, name=splunk_container_name) # Check the new HEC settings exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/apps/splunk_httpinput/local/inputs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert '''[http] disabled = 1''' in std_out exec_command = self.client.exec_create(cid, "netstat -tuln", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN" not in std_out except Exception as e: self.logger.error(e) @@ -1184,7 +1183,7 @@ def test_adhoc_1so_splunkd_no_ssl(self): assert self.check_splunkd("admin", p, name=splunk_container_name, scheme="http") # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/system/local/server.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "enableSplunkdSSL = false" in std_out # Check splunkd using the custom certs mgmt_port = self.client.port(cid, 8089)[0]["HostPort"] @@ -1273,7 +1272,7 @@ def test_compose_1so_java_oracle(self): assert self.check_splunkd("admin", self.password) # Check if java is installed exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "java version \"1.8.0" in std_out # Restart the container and make sure java is still installed self.client.restart("{}_so1_1".format(self.project_name)) @@ -1283,7 +1282,7 @@ def test_compose_1so_java_oracle(self): assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) assert self.check_splunkd("admin", self.password) exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "java version \"1.8.0" in std_out def test_compose_1so_java_openjdk8(self): @@ -1309,7 +1308,7 @@ def test_compose_1so_java_openjdk8(self): assert self.check_splunkd("admin", self.password) # Check if java is installed exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "openjdk version \"1.8.0" in std_out # Restart the container and make sure java is still installed self.client.restart("{}_so1_1".format(self.project_name)) @@ -1319,7 +1318,7 @@ def test_compose_1so_java_openjdk8(self): assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) assert self.check_splunkd("admin", self.password) exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "openjdk version \"1.8.0" in std_out @@ -1346,7 +1345,7 @@ def test_compose_1so_java_openjdk11(self): assert self.check_splunkd("admin", self.password) # Check if java is installed exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "openjdk version \"11.0.2" in std_out # Restart the container and make sure java is still installed self.client.restart("{}_so1_1".format(self.project_name)) @@ -1356,7 +1355,7 @@ def test_compose_1so_java_openjdk11(self): assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) assert self.check_splunkd("admin", self.password) exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "openjdk version \"11.0.2" in std_out def test_compose_1so_enable_service(self): @@ -1384,11 +1383,11 @@ def test_compose_1so_enable_service(self): # Check if service is registered if 'debian' in PLATFORM: exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "sudo service splunk status") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "splunkd is running" in std_out else: exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "stat /etc/init.d/splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out def test_adhoc_1so_hec_custom_cert(self): @@ -1445,7 +1444,7 @@ def test_adhoc_1so_hec_custom_cert(self): assert self.check_splunkd("admin", password, name=splunk_container_name) # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/apps/splunk_httpinput/local/inputs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "[http://splunk_hec_token]" in std_out assert "serverCert = /tmp/defaults/cert.pem" in std_out assert "sslPassword = " in std_out @@ -1521,7 +1520,7 @@ def test_adhoc_1so_splunktcp_ssl(self): assert self.check_splunkd("admin", password, name=splunk_container_name) # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/system/local/inputs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "[splunktcp-ssl:9997]" in std_out assert "serverCert = /tmp/defaults/cert.pem" in std_out except Exception as e: @@ -1589,7 +1588,7 @@ def test_adhoc_1so_splunkd_custom_ssl(self): assert self.check_splunkd("admin", password, name=splunk_container_name) # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/system/local/server.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "sslRootCAPath = /tmp/defaults/ca.pem" in std_out assert "serverCert = /tmp/defaults/cert.pem" in std_out # Check splunkd using the custom certs @@ -1704,11 +1703,11 @@ def test_adhoc_1so_preplaybook(self): assert status == 200 # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /tmp/i-am", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "batman" in std_out # Check file owner exec_command = self.client.exec_create(cid, r'stat -c \'%U\' /tmp/i-am') - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "splunk" in std_out except Exception as e: self.logger.error(e) @@ -1810,7 +1809,7 @@ def test_adhoc_1so_custom_conf(self): assert status == 200 # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunk/etc/users/admin/user-prefs/local/user-prefs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "[general]" in std_out assert "default_namespace = appboilerplate" in std_out assert "search_syntax_highlighting = dark" in std_out @@ -1921,11 +1920,11 @@ def test_uf_entrypoint_no_provision(self): # If the container is still running, we should be able to exec inside # Check that the git SHA exists in /opt/ansible exec_command = self.client.exec_create(cid, "cat /opt/ansible/version.txt") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert len(std_out.strip()) == 40 # Check that the wrapper-example directory does not exist exec_command = self.client.exec_create(cid, "ls /opt/ansible/") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "wrapper-example" not in std_out assert "docs" not in std_out except Exception as e: @@ -1947,7 +1946,7 @@ def test_uf_uid_gid(self): # If the container is still running, we should be able to exec inside # Check that the git SHA exists in /opt/ansible exec_command = self.client.exec_create(cid, "id", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "uid=41812" in std_out assert "gid=41812" in std_out except Exception as e: @@ -2012,7 +2011,7 @@ def test_adhoc_1uf_splunktcp_ssl(self): assert self.check_splunkd("admin", password, name=splunk_container_name) # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunkforwarder/etc/system/local/inputs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "[splunktcp-ssl:9997]" in std_out assert "serverCert = /tmp/defaults/cert.pem" in std_out except Exception as e: @@ -2078,7 +2077,7 @@ def test_adhoc_1uf_splunkd_custom_ssl(self): assert self.wait_for_containers(1, name=splunk_container_name) # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunkforwarder/etc/system/local/server.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "sslRootCAPath = /tmp/defaults/ca.pem" in std_out assert "serverCert = /tmp/defaults/cert.pem" in std_out # Check splunkd using the custom certs @@ -2152,7 +2151,7 @@ def test_adhoc_1uf_hec_custom_cert(self): assert self.check_splunkd("admin", password, name=splunk_container_name) # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunkforwarder/etc/apps/splunk_httpinput/local/inputs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "[http://splunk_hec_token]" in std_out assert "serverCert = /tmp/defaults/cert.pem" in std_out assert "sslPassword = " in std_out @@ -2198,11 +2197,11 @@ def test_compose_1uf_enable_service(self): # Check if service is registered if 'debian' in PLATFORM: exec_command = self.client.exec_create("{}_uf1_1".format(self.project_name), "sudo service splunk status") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "splunkd is running" in std_out else: exec_command = self.client.exec_create("{}_uf1_1".format(self.project_name), "stat /etc/init.d/splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out def test_adhoc_1uf_splunkd_no_ssl(self): @@ -2246,7 +2245,7 @@ def test_adhoc_1uf_splunkd_no_ssl(self): assert self.check_splunkd("admin", p, name=splunk_container_name, scheme="http") # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunkforwarder/etc/system/local/server.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "enableSplunkdSSL = false" in std_out # Check splunkd using the custom certs mgmt_port = self.client.port(cid, 8089)[0]["HostPort"] @@ -2538,10 +2537,10 @@ def test_adhoc_1uf_splunk_pass4symmkey(self): assert status == 200 # Check the decrypted pass4SymmKey exec_command = self.client.exec_create(cid, "cat /opt/splunkforwarder/etc/system/local/server.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() pass4SymmKey = re.search(r'\[general\].*?pass4SymmKey = (.*?)\n', std_out, flags=re.MULTILINE|re.DOTALL).group(1).strip() exec_command = self.client.exec_create(cid, "/opt/splunkforwarder/bin/splunk show-decrypted --value '{}'".format(pass4SymmKey), user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "wubbalubbadubdub" in std_out except Exception as e: self.logger.error(e) @@ -2576,7 +2575,7 @@ def test_adhoc_1uf_splunk_secret_env(self): assert status == 200 # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunkforwarder/etc/auth/splunk.secret", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "wubbalubbadubdub" in std_out except Exception as e: self.logger.error(e) @@ -2652,7 +2651,7 @@ def test_uf_ulimit(self): # If the container is still running, we should be able to exec inside # Check that nproc limits are unlimited exec_command = self.client.exec_create(cid, "sudo -u splunk bash -c 'ulimit -u'") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "unlimited" in std_out except Exception as e: self.logger.error(e) @@ -2706,7 +2705,7 @@ def test_adhoc_1uf_custom_conf(self): assert status == 200 # Check if the created file exists exec_command = self.client.exec_create(cid, "cat /opt/splunkforwarder/etc/users/admin/user-prefs/local/user-prefs.conf", user="splunk") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "[general]" in std_out assert "default_namespace = appboilerplate" in std_out assert "search_syntax_highlighting = dark" in std_out @@ -2749,7 +2748,7 @@ def test_adhoc_1uf_run_as_root(self): assert status == 200 # Check that root owns the splunkd process exec_command = self.client.exec_create(cid, "ps -u root", user="root") - std_out = self.client.exec_start(exec_command) + std_out = self.client.exec_start(exec_command).decode() assert "entrypoint.sh" in std_out assert "splunkd" in std_out except Exception as e: From 6c15e244383c3a971d39211411110e0e4f23c192 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Fri, 15 Dec 2023 13:36:44 -0800 Subject: [PATCH 02/18] updated docker compose syntax; --- tests/executor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/executor.py b/tests/executor.py index 1d8f0c14..61a6c931 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -221,7 +221,7 @@ def _run_splunk_query(self, container_id, query, username="admin", password="pas def compose_up(self, defaults_url=None, apps_url=None): container_count = self.get_number_of_containers(os.path.join(self.SCENARIOS_DIR, self.compose_file_name)) - command = "docker-compose -p {} -f test_scenarios/{} up -d".format(self.project_name, self.compose_file_name) + command = "docker compose -p {} -f test_scenarios/{} up -d".format(self.project_name, self.compose_file_name) out, err, rc = self._run_command(command, defaults_url, apps_url) return container_count, rc From d3a1e058bde5fa663003120d8f4915d8ddb64b41 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Mon, 18 Dec 2023 14:11:52 -0800 Subject: [PATCH 03/18] debug: docker compose tests fail; --- tests/executor.py | 16 ++++ tests/test_single_splunk_image.py | 149 ++++++++++++++++-------------- 2 files changed, 96 insertions(+), 69 deletions(-) diff --git a/tests/executor.py b/tests/executor.py index 61a6c931..b11397f9 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -128,6 +128,7 @@ def wait_for_containers(self, count, label=None, name=None, timeout=500): ''' NOTE: This helper method can only be used for `compose up` scenarios where self.project_name is defined ''' + print(f"now WAITING for CONTAINERS to be UP") start = time.time() end = start # Wait @@ -148,15 +149,25 @@ def wait_for_containers(self, count, label=None, name=None, timeout=500): output = self.client.logs(container["Id"], tail=5) if "unable to" in output or "denied" in output or "splunkd.pid file is unreadable" in output: self.logger.error("Container {} did not start properly, last log line: {}".format(container["Names"][0], output)) + print(f"SCRIPT FAILS TO CREATE CONTAINER") + sys.exit(1) elif "Ansible playbook complete" in output: + print(f"ANSIBLE EXEC COMPLETE") self.logger.info("Container {} is ready".format(container["Names"][0])) healthy_count += 1 + else: + print(f"IN ELSE WHICH WAS NOT EXPECTED:") + print("-------- START LOG ----------") + print(output) + print("-------- END LOG ----------") else: + print("ALL GOOD ELSE") self.logger.info("Container {} is ready".format(container["Names"][0])) healthy_count += 1 if healthy_count == count: self.logger.info("All containers ready to proceed") break + print(f"continue for loop without break") time.sleep(5) end = time.time() return True @@ -222,7 +233,12 @@ def _run_splunk_query(self, container_id, query, username="admin", password="pas def compose_up(self, defaults_url=None, apps_url=None): container_count = self.get_number_of_containers(os.path.join(self.SCENARIOS_DIR, self.compose_file_name)) command = "docker compose -p {} -f test_scenarios/{} up -d".format(self.project_name, self.compose_file_name) + print(f"LOOK AT THIS COMMAND") + print(command) + import sys + sys.exit(1) out, err, rc = self._run_command(command, defaults_url, apps_url) + print("COMPLETED DOCKER COMPOSE") return container_count, rc def extract_json(self, container_name): diff --git a/tests/test_single_splunk_image.py b/tests/test_single_splunk_image.py index 6bc5fae5..3970616c 100644 --- a/tests/test_single_splunk_image.py +++ b/tests/test_single_splunk_image.py @@ -60,7 +60,7 @@ def teardown_method(self, method): pass self.compose_file_name, self.project_name, self.DIR = None, None, None - def test_splunk_entrypoint_help(self): + def untest_splunk_entrypoint_help(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="help") self.client.start(cid.get("Id")) @@ -69,7 +69,7 @@ def test_splunk_entrypoint_help(self): assert "SPLUNK_HOME - home directory where Splunk gets installed (default: /opt/splunk)" in output assert "Examples:" in output - def test_splunk_ulimit(self): + def untest_splunk_ulimit(self): cid = None try: # Run container @@ -90,7 +90,7 @@ def test_splunk_ulimit(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_splunk_entrypoint_create_defaults(self): + def untest_splunk_entrypoint_create_defaults(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="create-defaults") self.client.start(cid.get("Id")) @@ -100,7 +100,7 @@ def test_splunk_entrypoint_create_defaults(self): assert "password: " in output assert "secret: " in output - def test_splunk_entrypoint_start_no_password(self): + def untest_splunk_entrypoint_start_no_password(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="start", environment={"SPLUNK_START_ARGS": "nothing"}) @@ -109,7 +109,7 @@ def test_splunk_entrypoint_start_no_password(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "WARNING: No password ENV var." in output - def test_splunk_entrypoint_start_no_accept_license(self): + def untest_splunk_entrypoint_start_no_accept_license(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="start", environment={"SPLUNK_PASSWORD": "something", "SPLUNK_START_ARGS": "nothing"}) @@ -118,7 +118,7 @@ def test_splunk_entrypoint_start_no_accept_license(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "License not accepted, please ensure the environment variable SPLUNK_START_ARGS contains the '--accept-license' flag" in output - def test_splunk_entrypoint_no_provision(self): + def untest_splunk_entrypoint_no_provision(self): cid = None try: # Run container @@ -143,7 +143,7 @@ def test_splunk_entrypoint_no_provision(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_splunk_uid_gid(self): + def untest_splunk_uid_gid(self): cid = None try: # Run container @@ -171,16 +171,27 @@ def test_compose_1so_trial(self): container_count, rc = self.compose_up() # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) + print(f"ALL CONTAINERS ARE UP") # Check ansible inventory json + print(f"EXTRACT JSON") log_json = self.extract_json("{}_so1_1".format(self.project_name)) + print(f"DONE EXTRACT JSON") + print(f"START: CHECK COMMON KEYS") self.check_common_keys(log_json, "so") + print(f"DONE: CHECK COMMON KEYS") # Check container logs + print(f"START: GET CONTAINER LOGS") output = self.get_container_logs("{}_so1_1".format(self.project_name)) + print(f"DONE: GET CONTAINER LOGS") + print(f"START: CHECK ANSIBLE OUTPUT") self.check_ansible(output) + print(f"DONE: CHECL AANISBLE OUTPUT") # Check Splunkd on all the containers + print(f"START: CHECK SPLUNKD") assert self.check_splunkd("admin", self.password) + print(f"DONE: CHECK SPLUNKD") - def test_compose_1so_custombuild(self): + def untest_compose_1so_custombuild(self): # Standup deployment self.compose_file_name = "1so_custombuild.yaml" self.project_name = self.generate_random_string() @@ -196,7 +207,7 @@ def test_compose_1so_custombuild(self): # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) - def test_compose_1so_namedvolumes(self): + def untest_compose_1so_namedvolumes(self): # TODO: We can do a lot better in this test - ex. check that data is persisted after restarts # Standup deployment self.compose_file_name = "1so_namedvolumes.yaml" @@ -214,7 +225,7 @@ def test_compose_1so_namedvolumes(self): # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) - def test_compose_1so_before_start_cmd(self): + def untest_compose_1so_before_start_cmd(self): # Check that SPLUNK_BEFORE_START_CMD works for splunk image # Standup deployment self.compose_file_name = "1so_before_start_cmd.yaml" @@ -235,7 +246,7 @@ def test_compose_1so_before_start_cmd(self): assert self.check_splunkd("admin2", "changemepls") assert self.check_splunkd("admin3", "changemepls") - def test_compose_1so_splunk_add(self): + def untest_compose_1so_splunk_add(self): # Check that SPLUNK_ADD works for splunk image (role=standalone) # Standup deployment self.compose_file_name = "1so_splunk_add_user.yaml" @@ -255,7 +266,7 @@ def test_compose_1so_splunk_add(self): # Check Splunkd using the new users assert self.check_splunkd("newman", "changemepls") - def test_adhoc_1so_using_default_yml(self): + def untest_adhoc_1so_using_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) # Generate default.yml @@ -303,7 +314,7 @@ def test_adhoc_1so_using_default_yml(self): except OSError: pass - def test_adhoc_1so_splunk_launch_conf(self): + def untest_adhoc_1so_splunk_launch_conf(self): # Create a splunk container cid = None try: @@ -339,7 +350,7 @@ def test_adhoc_1so_splunk_launch_conf(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_change_tailed_files(self): + def untest_adhoc_1so_change_tailed_files(self): # Create a splunk container cid = None try: @@ -375,7 +386,7 @@ def test_adhoc_1so_change_tailed_files(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_password_from_file(self): + def untest_adhoc_1so_password_from_file(self): # Create a splunk container cid = None # From fixtures/pwfile @@ -409,7 +420,7 @@ def test_adhoc_1so_password_from_file(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_reflexive_forwarding(self): + def untest_adhoc_1so_reflexive_forwarding(self): # Create a splunk container cid = None try: @@ -445,7 +456,7 @@ def test_adhoc_1so_reflexive_forwarding(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_splunk_pass4symmkey(self): + def untest_adhoc_1so_splunk_pass4symmkey(self): # Create a splunk container cid = None try: @@ -483,7 +494,7 @@ def test_adhoc_1so_splunk_pass4symmkey(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_splunk_secret_env(self): + def untest_adhoc_1so_splunk_secret_env(self): # Create a splunk container cid = None try: @@ -518,7 +529,7 @@ def test_adhoc_1so_splunk_secret_env(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_compose_1so_hec(self): + def untest_compose_1so_hec(self): # Standup deployment self.compose_file_name = "1so_hec.yaml" self.project_name = self.generate_random_string() @@ -550,7 +561,7 @@ def test_compose_1so_hec(self): status, content = self.handle_request_retry("POST", url, kwargs) assert status == 200 - def test_adhoc_1so_preplaybook_with_sudo(self): + def untest_adhoc_1so_preplaybook_with_sudo(self): # Create a splunk container cid = None try: @@ -591,7 +602,7 @@ def test_adhoc_1so_preplaybook_with_sudo(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_postplaybook(self): + def untest_adhoc_1so_postplaybook(self): # Create a splunk container cid = None try: @@ -632,7 +643,7 @@ def test_adhoc_1so_postplaybook(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_postplaybook_with_sudo(self): + def untest_adhoc_1so_postplaybook_with_sudo(self): # Create a splunk container cid = None try: @@ -673,7 +684,7 @@ def test_adhoc_1so_postplaybook_with_sudo(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_apps_location_in_default_yml(self): + def untest_adhoc_1so_apps_location_in_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) DIR_EXAMPLE_APP = os.path.join(self.DIR, "splunk_app_example") @@ -736,7 +747,7 @@ def test_adhoc_1so_apps_location_in_default_yml(self): except OSError: pass - def test_adhoc_1so_bind_mount_apps(self): + def untest_adhoc_1so_bind_mount_apps(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -793,7 +804,7 @@ def test_adhoc_1so_bind_mount_apps(self): except OSError: pass - def test_adhoc_1so_run_as_root(self): + def untest_adhoc_1so_run_as_root(self): # Create a splunk container cid = None try: @@ -830,7 +841,7 @@ def test_adhoc_1so_run_as_root(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_declarative_password(self): + def untest_adhoc_1so_declarative_password(self): """ This test is intended to check how the container gets provisioned with declarative passwords """ @@ -886,7 +897,7 @@ def test_adhoc_1so_declarative_password(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1uf_declarative_password(self): + def untest_adhoc_1uf_declarative_password(self): """ This test is intended to check how the container gets provisioned with declarative passwords """ @@ -942,7 +953,7 @@ def test_adhoc_1uf_declarative_password(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_hec_idempotence(self): + def untest_adhoc_1so_hec_idempotence(self): """ This test is intended to check how the container gets provisioned with changing splunk.hec.* parameters """ @@ -1107,7 +1118,7 @@ def test_adhoc_1so_hec_idempotence(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_hec_ssl_disabled(self): + def untest_adhoc_1so_hec_ssl_disabled(self): # Create the container cid = None try: @@ -1142,7 +1153,7 @@ def test_adhoc_1so_hec_ssl_disabled(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_splunkd_no_ssl(self): + def untest_adhoc_1so_splunkd_no_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1202,7 +1213,7 @@ def test_adhoc_1so_splunkd_no_ssl(self): except OSError: pass - def test_adhoc_1so_web_ssl(self): + def untest_adhoc_1so_web_ssl(self): # Create the container splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1249,7 +1260,7 @@ def test_adhoc_1so_web_ssl(self): except OSError: pass - def test_compose_1so_java_oracle(self): + def untest_compose_1so_java_oracle(self): # Standup deployment self.compose_file_name = "1so_java_oracle.yaml" self.project_name = self.generate_random_string() @@ -1285,7 +1296,7 @@ def test_compose_1so_java_oracle(self): std_out = self.client.exec_start(exec_command).decode() assert "java version \"1.8.0" in std_out - def test_compose_1so_java_openjdk8(self): + def untest_compose_1so_java_openjdk8(self): # Standup deployment self.compose_file_name = "1so_java_openjdk8.yaml" self.project_name = self.generate_random_string() @@ -1322,7 +1333,7 @@ def test_compose_1so_java_openjdk8(self): assert "openjdk version \"1.8.0" in std_out - def test_compose_1so_java_openjdk11(self): + def untest_compose_1so_java_openjdk11(self): # Standup deployment self.compose_file_name = "1so_java_openjdk11.yaml" self.project_name = self.generate_random_string() @@ -1358,7 +1369,7 @@ def test_compose_1so_java_openjdk11(self): std_out = self.client.exec_start(exec_command).decode() assert "openjdk version \"11.0.2" in std_out - def test_compose_1so_enable_service(self): + def untest_compose_1so_enable_service(self): # Standup deployment self.compose_file_name = "1so_enable_service.yaml" self.project_name = self.generate_random_string() @@ -1390,7 +1401,7 @@ def test_compose_1so_enable_service(self): std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out - def test_adhoc_1so_hec_custom_cert(self): + def untest_adhoc_1so_hec_custom_cert(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1465,7 +1476,7 @@ def test_adhoc_1so_hec_custom_cert(self): except OSError: pass - def test_adhoc_1so_splunktcp_ssl(self): + def untest_adhoc_1so_splunktcp_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1534,7 +1545,7 @@ def test_adhoc_1so_splunktcp_ssl(self): except OSError: pass - def test_adhoc_1so_splunkd_custom_ssl(self): + def untest_adhoc_1so_splunkd_custom_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1608,7 +1619,7 @@ def test_adhoc_1so_splunkd_custom_ssl(self): except OSError: pass - def test_adhoc_1so_upgrade(self): + def untest_adhoc_1so_upgrade(self): # Pull the old image for line in self.client.pull("splunk/splunk:{}".format(OLD_SPLUNK_VERSION), stream=True, decode=True): continue @@ -1675,7 +1686,7 @@ def test_adhoc_1so_upgrade(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1so_preplaybook(self): + def untest_adhoc_1so_preplaybook(self): # Create a splunk container cid = None try: @@ -1716,7 +1727,7 @@ def test_adhoc_1so_preplaybook(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_compose_1so_apps(self): + def untest_compose_1so_apps(self): self.project_name = self.generate_random_string() # Tar the app before spinning up the scenario with tarfile.open(os.path.join(self.FIXTURES_DIR, "{}.tgz".format(self.project_name)), "w:gz") as tar: @@ -1764,7 +1775,7 @@ def test_compose_1so_apps(self): except OSError: pass - def test_adhoc_1so_custom_conf(self): + def untest_adhoc_1so_custom_conf(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) os.mkdir(self.DIR) @@ -1825,7 +1836,7 @@ def test_adhoc_1so_custom_conf(self): except OSError: pass - def test_compose_1uf_apps(self): + def untest_compose_1uf_apps(self): self.project_name = self.generate_random_string() # Tar the app before spinning up the scenario with tarfile.open(os.path.join(self.FIXTURES_DIR, "{}.tgz".format(self.project_name)), "w:gz") as tar: @@ -1873,7 +1884,7 @@ def test_compose_1uf_apps(self): except OSError: pass - def test_uf_entrypoint_help(self): + def untest_uf_entrypoint_help(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="help") self.client.start(cid.get("Id")) @@ -1881,7 +1892,7 @@ def test_uf_entrypoint_help(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "SPLUNK_CMD - 'any splunk command' - execute any splunk commands separated by commas" in output - def test_uf_entrypoint_create_defaults(self): + def untest_uf_entrypoint_create_defaults(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="create-defaults") self.client.start(cid.get("Id")) @@ -1890,7 +1901,7 @@ def test_uf_entrypoint_create_defaults(self): assert "home: /opt/splunk" in output assert "password: " in output - def test_uf_entrypoint_start_no_password(self): + def untest_uf_entrypoint_start_no_password(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="start", environment={"SPLUNK_START_ARGS": "nothing"}) @@ -1899,7 +1910,7 @@ def test_uf_entrypoint_start_no_password(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "WARNING: No password ENV var." in output - def test_uf_entrypoint_start_no_accept_license(self): + def untest_uf_entrypoint_start_no_accept_license(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="start", environment={"SPLUNK_PASSWORD": "something", "SPLUNK_START_ARGS": "nothing"}) @@ -1908,7 +1919,7 @@ def test_uf_entrypoint_start_no_accept_license(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "License not accepted, please ensure the environment variable SPLUNK_START_ARGS contains the '--accept-license' flag" in output - def test_uf_entrypoint_no_provision(self): + def untest_uf_entrypoint_no_provision(self): cid = None try: # Run container @@ -1934,7 +1945,7 @@ def test_uf_entrypoint_no_provision(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_uf_uid_gid(self): + def untest_uf_uid_gid(self): cid = None try: # Run container @@ -1956,7 +1967,7 @@ def test_uf_uid_gid(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1uf_splunktcp_ssl(self): + def untest_adhoc_1uf_splunktcp_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2025,7 +2036,7 @@ def test_adhoc_1uf_splunktcp_ssl(self): except OSError: pass - def test_adhoc_1uf_splunkd_custom_ssl(self): + def untest_adhoc_1uf_splunkd_custom_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2097,7 +2108,7 @@ def test_adhoc_1uf_splunkd_custom_ssl(self): except OSError: pass - def test_adhoc_1uf_hec_custom_cert(self): + def untest_adhoc_1uf_hec_custom_cert(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2172,7 +2183,7 @@ def test_adhoc_1uf_hec_custom_cert(self): except OSError: pass - def test_compose_1uf_enable_service(self): + def untest_compose_1uf_enable_service(self): # Standup deployment self.compose_file_name = "1uf_enable_service.yaml" self.project_name = self.generate_random_string() @@ -2204,7 +2215,7 @@ def test_compose_1uf_enable_service(self): std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out - def test_adhoc_1uf_splunkd_no_ssl(self): + def untest_adhoc_1uf_splunkd_no_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2264,7 +2275,7 @@ def test_adhoc_1uf_splunkd_no_ssl(self): except OSError: pass - def test_compose_1uf_before_start_cmd(self): + def untest_compose_1uf_before_start_cmd(self): # Check that SPLUNK_BEFORE_START_CMD works for splunkforwarder image # Standup deployment self.compose_file_name = "1uf_before_start_cmd.yaml" @@ -2284,7 +2295,7 @@ def test_compose_1uf_before_start_cmd(self): # Check Splunkd using the new users assert self.check_splunkd("normalplebe", "newpassword") - def test_compose_1uf_splunk_add(self): + def untest_compose_1uf_splunk_add(self): # Check that SPLUNK_ADD works for splunkforwarder image # Standup deployment self.compose_file_name = "1uf_splunk_add_user.yaml" @@ -2305,7 +2316,7 @@ def test_compose_1uf_splunk_add(self): assert self.check_splunkd("elaine", "changemepls") assert self.check_splunkd("kramer", "changemepls") - def test_compose_1uf_splunk_cmd(self): + def untest_compose_1uf_splunk_cmd(self): # Check that SPLUNK_ADD works for splunkforwarder image # Standup deployment self.compose_file_name = "1uf_splunk_cmd.yaml" @@ -2326,7 +2337,7 @@ def test_compose_1uf_splunk_cmd(self): assert self.check_splunkd("jerry", "changemepls") assert self.check_splunkd("george", "changemepls") - def test_adhoc_1uf_using_default_yml(self): + def untest_adhoc_1uf_using_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) # Generate default.yml @@ -2374,7 +2385,7 @@ def test_adhoc_1uf_using_default_yml(self): except OSError: pass - def test_adhoc_1uf_hec_ssl_disabled(self): + def untest_adhoc_1uf_hec_ssl_disabled(self): # Create the container cid = None try: @@ -2409,7 +2420,7 @@ def test_adhoc_1uf_hec_ssl_disabled(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1uf_change_tailed_files(self): + def untest_adhoc_1uf_change_tailed_files(self): # Create a splunk container cid = None try: @@ -2445,7 +2456,7 @@ def test_adhoc_1uf_change_tailed_files(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1uf_password_from_file(self): + def untest_adhoc_1uf_password_from_file(self): # Create a splunk container cid = None # From fixtures/pwfile @@ -2479,7 +2490,7 @@ def test_adhoc_1uf_password_from_file(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_compose_1uf_hec(self): + def untest_compose_1uf_hec(self): # Standup deployment self.compose_file_name = "1uf_hec.yaml" self.project_name = self.generate_random_string() @@ -2511,7 +2522,7 @@ def test_compose_1uf_hec(self): status, content = self.handle_request_retry("POST", url, kwargs) assert status == 200 - def test_adhoc_1uf_splunk_pass4symmkey(self): + def untest_adhoc_1uf_splunk_pass4symmkey(self): # Create a splunk container cid = None try: @@ -2549,7 +2560,7 @@ def test_adhoc_1uf_splunk_pass4symmkey(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1uf_splunk_secret_env(self): + def untest_adhoc_1uf_splunk_secret_env(self): # Create a uf container cid = None try: @@ -2584,7 +2595,7 @@ def test_adhoc_1uf_splunk_secret_env(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1uf_bind_mount_apps(self): + def untest_adhoc_1uf_bind_mount_apps(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.project_name = self.generate_random_string() @@ -2639,7 +2650,7 @@ def test_adhoc_1uf_bind_mount_apps(self): except OSError: pass - def test_uf_ulimit(self): + def untest_uf_ulimit(self): cid = None try: # Run container @@ -2660,7 +2671,7 @@ def test_uf_ulimit(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_adhoc_1uf_custom_conf(self): + def untest_adhoc_1uf_custom_conf(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) os.mkdir(self.DIR) @@ -2721,7 +2732,7 @@ def test_adhoc_1uf_custom_conf(self): except OSError: pass - def test_adhoc_1uf_run_as_root(self): + def untest_adhoc_1uf_run_as_root(self): # Create a uf container cid = None try: @@ -2758,7 +2769,7 @@ def test_adhoc_1uf_run_as_root(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_compose_1hf_splunk_add(self): + def untest_compose_1hf_splunk_add(self): # Check that SPLUNK_ADD works for splunk image (role=heavy forwarder) # Standup deployment self.compose_file_name = "1hf_splunk_add_user.yaml" From cb2437e0c42b900f4d928b39d62941fe25591516 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Mon, 18 Dec 2023 14:22:11 -0800 Subject: [PATCH 04/18] remove debug sys exit; --- tests/executor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/executor.py b/tests/executor.py index b11397f9..e6a1c850 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -235,10 +235,11 @@ def compose_up(self, defaults_url=None, apps_url=None): command = "docker compose -p {} -f test_scenarios/{} up -d".format(self.project_name, self.compose_file_name) print(f"LOOK AT THIS COMMAND") print(command) - import sys - sys.exit(1) out, err, rc = self._run_command(command, defaults_url, apps_url) print("COMPLETED DOCKER COMPOSE") + print(f"check RC for docker compose: {rc}; check err for docker-compose: {err}") + print("check output for docker-compose") + print(out) return container_count, rc def extract_json(self, container_name): From c41f90238eec64e9f08f34a6051798d12b056c30 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Mon, 18 Dec 2023 14:37:48 -0800 Subject: [PATCH 05/18] debug: file handler; --- tests/executor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/executor.py b/tests/executor.py index e6a1c850..9744624c 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -28,7 +28,7 @@ # Setup logging LOGGER = logging.getLogger("docker-splunk") LOGGER.setLevel(logging.INFO) -file_handler = logging.handlers.RotatingFileHandler(os.path.join(FILE_DIR, "..", "test-results", "docker_splunk_test_python{}.log".format(sys.version_info[0])), maxBytes=25000000) +file_handler = logging.handlers.RotatingFileHandler("/builds/core-ee/docker-images/docker_splunk_tests.log", maxBytes=25000000) formatter = logging.Formatter('%(asctime)s %(levelname)s [%(name)s] [%(process)d] %(message)s') file_handler.setFormatter(formatter) LOGGER.addHandler(file_handler) From e6009cd9514378a50a54d90019b1b7731f4e0ad0 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Mon, 18 Dec 2023 15:02:15 -0800 Subject: [PATCH 06/18] add logs; --- tests/executor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/executor.py b/tests/executor.py index 9744624c..bbc32dec 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -285,16 +285,22 @@ def _run_command(self, command, defaults_url=None, apps_url=None): env["SPLUNK_DEFAULTS_URL"] = defaults_url if apps_url: env["SPLUNK_APPS_URL"] = apps_url + self.logger.info("execute command") proc = subprocess.Popen(sh, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) + self.logger.info("PROC created") lines = [] err_lines = [] for line in iter(proc.stdout.readline, ''): lines.append(line) for line in iter(proc.stderr.readline, ''): err_lines.append(line) + self.logger.info("PROC close stdout") proc.stdout.close() + self.logger.info("PROC close stdout") proc.stderr.close() + self.logger.info("PROC WAIT") proc.wait() + self.logger.info("Done with proc") out = "".join(lines) self.logger.info("STDOUT: %s" % out) err = "".join(err_lines) From 9ff2fb03f77358537ae246a6a3a35c37607e8093 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Mon, 18 Dec 2023 15:28:49 -0800 Subject: [PATCH 07/18] add logs; --- tests/executor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/executor.py b/tests/executor.py index bbc32dec..f6141421 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -290,9 +290,13 @@ def _run_command(self, command, defaults_url=None, apps_url=None): self.logger.info("PROC created") lines = [] err_lines = [] + self.logger.info("START RECORDING STDOUT") for line in iter(proc.stdout.readline, ''): + self.logger.info(line) lines.append(line) + self.logger.info("START RECORDING STDERR") for line in iter(proc.stderr.readline, ''): + self.logger.info(line) err_lines.append(line) self.logger.info("PROC close stdout") proc.stdout.close() From 3e29bd40bf0fc799a098cd3d31194c6cf4504676 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Mon, 18 Dec 2023 17:21:45 -0800 Subject: [PATCH 08/18] attempt os system exec; --- tests/executor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/executor.py b/tests/executor.py index f6141421..7f9fe418 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -285,7 +285,9 @@ def _run_command(self, command, defaults_url=None, apps_url=None): env["SPLUNK_DEFAULTS_URL"] = defaults_url if apps_url: env["SPLUNK_APPS_URL"] = apps_url - self.logger.info("execute command") + self.logger.info(f"os.system attempt - {command}") + os.system(command) + self.logger.info("execute command vis subprocess;") proc = subprocess.Popen(sh, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) self.logger.info("PROC created") lines = [] From 0e25a689868cc04acaae47234fcb938705450cbc Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Tue, 19 Dec 2023 12:38:53 -0800 Subject: [PATCH 09/18] add text flag to return stdout and stderr as string; --- tests/executor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/executor.py b/tests/executor.py index 7f9fe418..2ca11477 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -288,7 +288,7 @@ def _run_command(self, command, defaults_url=None, apps_url=None): self.logger.info(f"os.system attempt - {command}") os.system(command) self.logger.info("execute command vis subprocess;") - proc = subprocess.Popen(sh, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) + proc = subprocess.Popen(sh, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, text=True) self.logger.info("PROC created") lines = [] err_lines = [] From eba777e886ed25a418398560a6bb3f072defc484 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Tue, 19 Dec 2023 12:39:37 -0800 Subject: [PATCH 10/18] skip: debug os system action --- tests/executor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/executor.py b/tests/executor.py index 2ca11477..ac5b5139 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -285,8 +285,8 @@ def _run_command(self, command, defaults_url=None, apps_url=None): env["SPLUNK_DEFAULTS_URL"] = defaults_url if apps_url: env["SPLUNK_APPS_URL"] = apps_url - self.logger.info(f"os.system attempt - {command}") - os.system(command) + self.logger.info(f"os.system attempt - {command}; SKIPPED") + #os.system(command) self.logger.info("execute command vis subprocess;") proc = subprocess.Popen(sh, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, text=True) self.logger.info("PROC created") From 913bbf0880d11a51a7e7f13c03940b92d7aadab8 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Tue, 19 Dec 2023 13:28:18 -0800 Subject: [PATCH 11/18] replace docker-compose references with docker compose --- tests/executor.py | 6 +++--- tests/test_distributed_splunk_image.py | 6 +++--- tests/test_single_splunk_image.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/executor.py b/tests/executor.py index ac5b5139..dfbb342f 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -114,7 +114,7 @@ def cleanup_files(self, files): raise e def _clean_docker_env(self): - # Remove anything spun up by docker-compose + # Remove anything spun up by docker compose containers = self.client.containers(filters={"label": "com.docker.compose.project={}".format(self.project_name)}) for container in containers: self.client.remove_container(container["Id"], v=True, force=True) @@ -237,8 +237,8 @@ def compose_up(self, defaults_url=None, apps_url=None): print(command) out, err, rc = self._run_command(command, defaults_url, apps_url) print("COMPLETED DOCKER COMPOSE") - print(f"check RC for docker compose: {rc}; check err for docker-compose: {err}") - print("check output for docker-compose") + print(f"check RC for docker compose: {rc}; check err for docker compose: {err}") + print("check output for docker compose") print(out) return container_count, rc diff --git a/tests/test_distributed_splunk_image.py b/tests/test_distributed_splunk_image.py index 2284f2a6..7d077558 100644 --- a/tests/test_distributed_splunk_image.py +++ b/tests/test_distributed_splunk_image.py @@ -49,9 +49,9 @@ def setup_method(self, method): def teardown_method(self, method): if self.compose_file_name and self.project_name: if self.DIR: - command = "docker-compose -p {} -f {} down --volumes --remove-orphans".format(self.project_name, os.path.join(self.DIR, self.compose_file_name)) + command = "docker compose -p {} -f {} down --volumes --remove-orphans".format(self.project_name, os.path.join(self.DIR, self.compose_file_name)) else: - command = "docker-compose -p {} -f test_scenarios/{} down --volumes --remove-orphans".format(self.project_name, self.compose_file_name) + command = "docker compose -p {} -f test_scenarios/{} down --volumes --remove-orphans".format(self.project_name, self.compose_file_name) out, err, rc = self._run_command(command) self._clean_docker_env() if self.DIR: @@ -1104,4 +1104,4 @@ def test_compose_3idx1cm_splunktcp_ssl(self): os.path.join(self.DEFAULTS_DIR, "cert.pem"), os.path.join(self.DEFAULTS_DIR, "{}.yml".format(self.project_name)) ] - self.cleanup_files(files) \ No newline at end of file + self.cleanup_files(files) diff --git a/tests/test_single_splunk_image.py b/tests/test_single_splunk_image.py index 3970616c..d459baaa 100644 --- a/tests/test_single_splunk_image.py +++ b/tests/test_single_splunk_image.py @@ -48,9 +48,9 @@ def setup_method(self, method): def teardown_method(self, method): if self.compose_file_name and self.project_name: if self.DIR: - command = "docker-compose -p {} -f {} down --volumes --remove-orphans".format(self.project_name, os.path.join(self.DIR, self.compose_file_name)) + command = "docker compose -p {} -f {} down --volumes --remove-orphans".format(self.project_name, os.path.join(self.DIR, self.compose_file_name)) else: - command = "docker-compose -p {} -f test_scenarios/{} down --volumes --remove-orphans".format(self.project_name, self.compose_file_name) + command = "docker compose -p {} -f test_scenarios/{} down --volumes --remove-orphans".format(self.project_name, self.compose_file_name) out, err, rc = self._run_command(command) self._clean_docker_env() if self.DIR: From 3f09ee59ebb99c5b3582d7be011ac8f2f4289b0a Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Tue, 19 Dec 2023 13:45:14 -0800 Subject: [PATCH 12/18] decode byte to str; --- tests/executor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/executor.py b/tests/executor.py index dfbb342f..fadd02d5 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -146,7 +146,8 @@ def wait_for_containers(self, count, label=None, name=None, timeout=500): for container in containers: # The healthcheck on our Splunk image is not reliable - resorting to checking logs if container.get("Labels", {}).get("maintainer") == "support@splunk.com": - output = self.client.logs(container["Id"], tail=5) + output = self.client.logs(container["Id"], tail=5).decode() + self.logger.info(f"DEBUG: Check the tupe of output - {type(output)}") if "unable to" in output or "denied" in output or "splunkd.pid file is unreadable" in output: self.logger.error("Container {} did not start properly, last log line: {}".format(container["Names"][0], output)) print(f"SCRIPT FAILS TO CREATE CONTAINER") From 48e626d0bb519497528e4e211338b7cfec05b2be Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Wed, 20 Dec 2023 09:06:14 -0800 Subject: [PATCH 13/18] debug test failure; --- tests/executor.py | 23 +++++++---------------- tests/requirements.txt | 2 -- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/tests/executor.py b/tests/executor.py index fadd02d5..010a57aa 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -28,7 +28,7 @@ # Setup logging LOGGER = logging.getLogger("docker-splunk") LOGGER.setLevel(logging.INFO) -file_handler = logging.handlers.RotatingFileHandler("/builds/core-ee/docker-images/docker_splunk_tests.log", maxBytes=25000000) +file_handler = logging.handlers.RotatingFileHandler("./docker_splunk_tests.log", maxBytes=25000000) formatter = logging.Formatter('%(asctime)s %(levelname)s [%(name)s] [%(process)d] %(message)s') file_handler.setFormatter(formatter) LOGGER.addHandler(file_handler) @@ -128,7 +128,6 @@ def wait_for_containers(self, count, label=None, name=None, timeout=500): ''' NOTE: This helper method can only be used for `compose up` scenarios where self.project_name is defined ''' - print(f"now WAITING for CONTAINERS to be UP") start = time.time() end = start # Wait @@ -153,22 +152,14 @@ def wait_for_containers(self, count, label=None, name=None, timeout=500): print(f"SCRIPT FAILS TO CREATE CONTAINER") sys.exit(1) elif "Ansible playbook complete" in output: - print(f"ANSIBLE EXEC COMPLETE") self.logger.info("Container {} is ready".format(container["Names"][0])) healthy_count += 1 - else: - print(f"IN ELSE WHICH WAS NOT EXPECTED:") - print("-------- START LOG ----------") - print(output) - print("-------- END LOG ----------") else: - print("ALL GOOD ELSE") self.logger.info("Container {} is ready".format(container["Names"][0])) healthy_count += 1 if healthy_count == count: self.logger.info("All containers ready to proceed") break - print(f"continue for loop without break") time.sleep(5) end = time.time() return True @@ -234,19 +225,19 @@ def _run_splunk_query(self, container_id, query, username="admin", password="pas def compose_up(self, defaults_url=None, apps_url=None): container_count = self.get_number_of_containers(os.path.join(self.SCENARIOS_DIR, self.compose_file_name)) command = "docker compose -p {} -f test_scenarios/{} up -d".format(self.project_name, self.compose_file_name) - print(f"LOOK AT THIS COMMAND") - print(command) out, err, rc = self._run_command(command, defaults_url, apps_url) - print("COMPLETED DOCKER COMPOSE") - print(f"check RC for docker compose: {rc}; check err for docker compose: {err}") - print("check output for docker compose") - print(out) return container_count, rc def extract_json(self, container_name): retries = 15 for i in range(retries): + print("DEBUG: EXTRACT JSON") + import time + print("sleeping now for 10; check if docker container exists") + self.logger.info("sleeping now for 10; check if docker container exists") + time.sleep(20) exec_command = self.client.exec_create(container_name, "cat /opt/container_artifact/ansible_inventory.json") + print(f"collect exec command: {exec_command}") json_data = self.client.exec_start(exec_command) if "No such file or directory" in json_data: time.sleep(5) diff --git a/tests/requirements.txt b/tests/requirements.txt index 0fff1856..12f53a21 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -2,8 +2,6 @@ pytest==4.4.0 pyrsistent==0.16.1 requests docker -PyYAML -docker-compose pyasn1 junit-xml pytest-xdist From b252b808b36b184698255ef794355b1a5a26a29e Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Wed, 20 Dec 2023 11:41:46 -0800 Subject: [PATCH 14/18] debug test failures; --- tests/executor.py | 11 +-- tests/test_distributed_splunk_image.py | 6 +- tests/test_single_splunk_image.py | 96 +++++++++++++------------- 3 files changed, 58 insertions(+), 55 deletions(-) diff --git a/tests/executor.py b/tests/executor.py index 010a57aa..8050d8d1 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -235,10 +235,13 @@ def extract_json(self, container_name): import time print("sleeping now for 10; check if docker container exists") self.logger.info("sleeping now for 10; check if docker container exists") - time.sleep(20) + os.system("echo '----------- START -----------'") + os.system("docker ps -a") + os.system(f"docker logs {container_name}") + os.system("echo '----------- END -----------'") exec_command = self.client.exec_create(container_name, "cat /opt/container_artifact/ansible_inventory.json") print(f"collect exec command: {exec_command}") - json_data = self.client.exec_start(exec_command) + json_data = self.client.exec_start(exec_command).decode() if "No such file or directory" in json_data: time.sleep(5) else: @@ -287,10 +290,10 @@ def _run_command(self, command, defaults_url=None, apps_url=None): self.logger.info("START RECORDING STDOUT") for line in iter(proc.stdout.readline, ''): self.logger.info(line) - lines.append(line) + lines.append(f"out: {line}") self.logger.info("START RECORDING STDERR") for line in iter(proc.stderr.readline, ''): - self.logger.info(line) + self.logger.info(f"err: {line}") err_lines.append(line) self.logger.info("PROC close stdout") proc.stdout.close() diff --git a/tests/test_distributed_splunk_image.py b/tests/test_distributed_splunk_image.py index 7d077558..ad5eaf44 100644 --- a/tests/test_distributed_splunk_image.py +++ b/tests/test_distributed_splunk_image.py @@ -241,7 +241,7 @@ def test_compose_1uf1so(self): raise e # Search results won't return the correct results immediately :( time.sleep(30) - search_providers, distinct_hosts = self.search_internal_distinct_hosts("{}_so1_1".format(self.project_name), password=self.password) + search_providers, distinct_hosts = self.search_internal_distinct_hosts("{}-so1-1".format(self.project_name), password=self.password) assert len(search_providers) == 1 assert search_providers[0] == "so1" assert distinct_hosts == 2 @@ -842,7 +842,7 @@ def test_compose_1deployment1so(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Get container logs - container_mapping = {"{}_so1_1".format(self.project_name): "so", "{}_depserver1_1".format(self.project_name): "deployment_server"} + container_mapping = {"{}-so1-1".format(self.project_name): "so", "{}_depserver1_1".format(self.project_name): "deployment_server"} for container in container_mapping: # Check ansible version & configs ansible_logs = self.get_container_logs(container) @@ -929,7 +929,7 @@ def test_compose_1deployment1uf(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Get container logs - container_mapping = {"{}_uf1_1".format(self.project_name): "uf", "{}_depserver1_1".format(self.project_name): "deployment_server"} + container_mapping = {"{}-uf1-1".format(self.project_name): "uf", "{}_depserver1_1".format(self.project_name): "deployment_server"} for container in container_mapping: # Check ansible version & configs ansible_logs = self.get_container_logs(container) diff --git a/tests/test_single_splunk_image.py b/tests/test_single_splunk_image.py index d459baaa..d11fb230 100644 --- a/tests/test_single_splunk_image.py +++ b/tests/test_single_splunk_image.py @@ -51,7 +51,7 @@ def teardown_method(self, method): command = "docker compose -p {} -f {} down --volumes --remove-orphans".format(self.project_name, os.path.join(self.DIR, self.compose_file_name)) else: command = "docker compose -p {} -f test_scenarios/{} down --volumes --remove-orphans".format(self.project_name, self.compose_file_name) - out, err, rc = self._run_command(command) + #out, err, rc = self._run_command(command) self._clean_docker_env() if self.DIR: try: @@ -174,14 +174,14 @@ def test_compose_1so_trial(self): print(f"ALL CONTAINERS ARE UP") # Check ansible inventory json print(f"EXTRACT JSON") - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) print(f"DONE EXTRACT JSON") print(f"START: CHECK COMMON KEYS") self.check_common_keys(log_json, "so") print(f"DONE: CHECK COMMON KEYS") # Check container logs print(f"START: GET CONTAINER LOGS") - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) print(f"DONE: GET CONTAINER LOGS") print(f"START: CHECK ANSIBLE OUTPUT") self.check_ansible(output) @@ -199,10 +199,10 @@ def untest_compose_1so_custombuild(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) self.check_common_keys(log_json, "so") # Check container logs - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) @@ -217,10 +217,10 @@ def untest_compose_1so_namedvolumes(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) self.check_common_keys(log_json, "so") # Check container logs - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) @@ -235,10 +235,10 @@ def untest_compose_1so_before_start_cmd(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) self.check_common_keys(log_json, "so") # Check container logs - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) @@ -256,10 +256,10 @@ def untest_compose_1so_splunk_add(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) self.check_common_keys(log_json, "so") # Check container logs - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) @@ -538,7 +538,7 @@ def untest_compose_1so_hec(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) self.check_common_keys(log_json, "so") try: # token "abcd1234" is hard-coded within the 1so_hec.yaml compose @@ -547,7 +547,7 @@ def untest_compose_1so_hec(self): self.logger.error(e) raise e # Check container logs - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) @@ -1269,7 +1269,7 @@ def untest_compose_1so_java_oracle(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) self.check_common_keys(log_json, "so") try: assert log_json["all"]["vars"]["java_version"] == "oracle:8" @@ -1277,22 +1277,22 @@ def untest_compose_1so_java_oracle(self): self.logger.error(e) raise e # Check container logs - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) # Check if java is installed - exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") + exec_command = self.client.exec_create("{}-so1-1".format(self.project_name), "java -version") std_out = self.client.exec_start(exec_command).decode() assert "java version \"1.8.0" in std_out # Restart the container and make sure java is still installed - self.client.restart("{}_so1_1".format(self.project_name)) + self.client.restart("{}-so1-1".format(self.project_name)) # After restart, a container's logs are preserved. So, sleep in order for the self.wait_for_containers() # to avoid seeing the prior entrypoint's "Ansible playbook complete" string time.sleep(15) assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) assert self.check_splunkd("admin", self.password) - exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") + exec_command = self.client.exec_create("{}-so1-1".format(self.project_name), "java -version") std_out = self.client.exec_start(exec_command).decode() assert "java version \"1.8.0" in std_out @@ -1305,7 +1305,7 @@ def untest_compose_1so_java_openjdk8(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) self.check_common_keys(log_json, "so") try: assert log_json["all"]["vars"]["java_version"] == "openjdk:8" @@ -1313,22 +1313,22 @@ def untest_compose_1so_java_openjdk8(self): self.logger.error(e) raise e # Check container logs - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) # Check if java is installed - exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") + exec_command = self.client.exec_create("{}-so1-1".format(self.project_name), "java -version") std_out = self.client.exec_start(exec_command).decode() assert "openjdk version \"1.8.0" in std_out # Restart the container and make sure java is still installed - self.client.restart("{}_so1_1".format(self.project_name)) + self.client.restart("{}-so1-1".format(self.project_name)) # After restart, a container's logs are preserved. So, sleep in order for the self.wait_for_containers() # to avoid seeing the prior entrypoint's "Ansible playbook complete" string time.sleep(15) assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) assert self.check_splunkd("admin", self.password) - exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") + exec_command = self.client.exec_create("{}-so1-1".format(self.project_name), "java -version") std_out = self.client.exec_start(exec_command).decode() assert "openjdk version \"1.8.0" in std_out @@ -1342,7 +1342,7 @@ def untest_compose_1so_java_openjdk11(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) self.check_common_keys(log_json, "so") try: assert log_json["all"]["vars"]["java_version"] == "openjdk:11" @@ -1350,22 +1350,22 @@ def untest_compose_1so_java_openjdk11(self): self.logger.error(e) raise e # Check container logs - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) # Check if java is installed - exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") + exec_command = self.client.exec_create("{}-so1-1".format(self.project_name), "java -version") std_out = self.client.exec_start(exec_command).decode() assert "openjdk version \"11.0.2" in std_out # Restart the container and make sure java is still installed - self.client.restart("{}_so1_1".format(self.project_name)) + self.client.restart("{}-so1-1".format(self.project_name)) # After restart, a container's logs are preserved. So, sleep in order for the self.wait_for_containers() # to avoid seeing the prior entrypoint's "Ansible playbook complete" string time.sleep(15) assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) assert self.check_splunkd("admin", self.password) - exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "java -version") + exec_command = self.client.exec_create("{}-so1-1".format(self.project_name), "java -version") std_out = self.client.exec_start(exec_command).decode() assert "openjdk version \"11.0.2" in std_out @@ -1378,7 +1378,7 @@ def untest_compose_1so_enable_service(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) self.check_common_keys(log_json, "so") try: # enable_service is set in the compose file @@ -1387,17 +1387,17 @@ def untest_compose_1so_enable_service(self): self.logger.error(e) raise e # Check container logs - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) # Check if service is registered if 'debian' in PLATFORM: - exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "sudo service splunk status") + exec_command = self.client.exec_create("{}-so1-1".format(self.project_name), "sudo service splunk status") std_out = self.client.exec_start(exec_command).decode() assert "splunkd is running" in std_out else: - exec_command = self.client.exec_create("{}_so1_1".format(self.project_name), "stat /etc/init.d/splunk") + exec_command = self.client.exec_create("{}-so1-1".format(self.project_name), "stat /etc/init.d/splunk") std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out @@ -1739,7 +1739,7 @@ def untest_compose_1so_apps(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_so1_1".format(self.project_name)) + log_json = self.extract_json("{}-so1-1".format(self.project_name)) self.check_common_keys(log_json, "so") try: assert log_json["all"]["vars"]["splunk"]["apps_location"][0] == "http://appserver/{}.tgz".format(self.project_name) @@ -1752,7 +1752,7 @@ def untest_compose_1so_apps(self): self.logger.error(e) raise e # Check container logs - output = self.get_container_logs("{}_so1_1".format(self.project_name)) + output = self.get_container_logs("{}-so1-1".format(self.project_name)) self.check_ansible(output) # Check to make sure the app got installed containers = self.client.containers(filters={"label": "com.docker.compose.project={}".format(self.project_name)}) @@ -1848,7 +1848,7 @@ def untest_compose_1uf_apps(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_uf1_1".format(self.project_name)) + log_json = self.extract_json("{}-uf1-1".format(self.project_name)) self.check_common_keys(log_json, "uf") try: assert log_json["all"]["vars"]["splunk"]["apps_location"][0] == "http://appserver/{}.tgz".format(self.project_name) @@ -1861,7 +1861,7 @@ def untest_compose_1uf_apps(self): self.logger.error(e) raise e # Check container logs - output = self.get_container_logs("{}_uf1_1".format(self.project_name)) + output = self.get_container_logs("{}-uf1-1".format(self.project_name)) self.check_ansible(output) # Check to make sure the app got installed containers = self.client.containers(filters={"label": "com.docker.compose.project={}".format(self.project_name)}) @@ -2192,7 +2192,7 @@ def untest_compose_1uf_enable_service(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_uf1_1".format(self.project_name)) + log_json = self.extract_json("{}-uf1-1".format(self.project_name)) self.check_common_keys(log_json, "uf") try: # enable_service is set in the compose file @@ -2201,17 +2201,17 @@ def untest_compose_1uf_enable_service(self): self.logger.error(e) raise e # Check container logs - output = self.get_container_logs("{}_uf1_1".format(self.project_name)) + output = self.get_container_logs("{}-uf1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) # Check if service is registered if 'debian' in PLATFORM: - exec_command = self.client.exec_create("{}_uf1_1".format(self.project_name), "sudo service splunk status") + exec_command = self.client.exec_create("{}-uf1-1".format(self.project_name), "sudo service splunk status") std_out = self.client.exec_start(exec_command).decode() assert "splunkd is running" in std_out else: - exec_command = self.client.exec_create("{}_uf1_1".format(self.project_name), "stat /etc/init.d/splunk") + exec_command = self.client.exec_create("{}-uf1-1".format(self.project_name), "stat /etc/init.d/splunk") std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out @@ -2285,10 +2285,10 @@ def untest_compose_1uf_before_start_cmd(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_uf1_1".format(self.project_name)) + log_json = self.extract_json("{}-uf1-1".format(self.project_name)) self.check_common_keys(log_json, "uf") # Check container logs - output = self.get_container_logs("{}_uf1_1".format(self.project_name)) + output = self.get_container_logs("{}-uf1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) @@ -2305,10 +2305,10 @@ def untest_compose_1uf_splunk_add(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_uf1_1".format(self.project_name)) + log_json = self.extract_json("{}-uf1-1".format(self.project_name)) self.check_common_keys(log_json, "uf") # Check container logs - output = self.get_container_logs("{}_uf1_1".format(self.project_name)) + output = self.get_container_logs("{}-uf1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) @@ -2326,10 +2326,10 @@ def untest_compose_1uf_splunk_cmd(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_uf1_1".format(self.project_name)) + log_json = self.extract_json("{}-uf1-1".format(self.project_name)) self.check_common_keys(log_json, "uf") # Check container logs - output = self.get_container_logs("{}_uf1_1".format(self.project_name)) + output = self.get_container_logs("{}-uf1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) @@ -2499,7 +2499,7 @@ def untest_compose_1uf_hec(self): # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) # Check ansible inventory json - log_json = self.extract_json("{}_uf1_1".format(self.project_name)) + log_json = self.extract_json("{}-uf1-1".format(self.project_name)) self.check_common_keys(log_json, "uf") try: # token "abcd1234" is hard-coded within the 1so_hec.yaml compose @@ -2508,7 +2508,7 @@ def untest_compose_1uf_hec(self): self.logger.error(e) raise e # Check container logs - output = self.get_container_logs("{}_uf1_1".format(self.project_name)) + output = self.get_container_logs("{}-uf1-1".format(self.project_name)) self.check_ansible(output) # Check Splunkd on all the containers assert self.check_splunkd("admin", self.password) From 5ee72a9139fa4cde451314801bfc6b91d3a5948e Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Wed, 20 Dec 2023 12:57:11 -0800 Subject: [PATCH 15/18] debug: revert requirements change; --- tests/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/requirements.txt b/tests/requirements.txt index 12f53a21..0fff1856 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -2,6 +2,8 @@ pytest==4.4.0 pyrsistent==0.16.1 requests docker +PyYAML +docker-compose pyasn1 junit-xml pytest-xdist From db2c68cf1ff3afa38e2297fb141cb173b9254053 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Wed, 10 Jan 2024 09:05:43 -0800 Subject: [PATCH 16/18] skip compose tests; --- tests/test_single_splunk_image.py | 106 +++++++++++++++--------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/tests/test_single_splunk_image.py b/tests/test_single_splunk_image.py index d11fb230..4e2cb65d 100644 --- a/tests/test_single_splunk_image.py +++ b/tests/test_single_splunk_image.py @@ -60,7 +60,7 @@ def teardown_method(self, method): pass self.compose_file_name, self.project_name, self.DIR = None, None, None - def untest_splunk_entrypoint_help(self): + def test_splunk_entrypoint_help(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="help") self.client.start(cid.get("Id")) @@ -69,7 +69,7 @@ def untest_splunk_entrypoint_help(self): assert "SPLUNK_HOME - home directory where Splunk gets installed (default: /opt/splunk)" in output assert "Examples:" in output - def untest_splunk_ulimit(self): + def test_splunk_ulimit(self): cid = None try: # Run container @@ -90,7 +90,7 @@ def untest_splunk_ulimit(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_splunk_entrypoint_create_defaults(self): + def test_splunk_entrypoint_create_defaults(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="create-defaults") self.client.start(cid.get("Id")) @@ -100,7 +100,7 @@ def untest_splunk_entrypoint_create_defaults(self): assert "password: " in output assert "secret: " in output - def untest_splunk_entrypoint_start_no_password(self): + def test_splunk_entrypoint_start_no_password(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="start", environment={"SPLUNK_START_ARGS": "nothing"}) @@ -109,7 +109,7 @@ def untest_splunk_entrypoint_start_no_password(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "WARNING: No password ENV var." in output - def untest_splunk_entrypoint_start_no_accept_license(self): + def test_splunk_entrypoint_start_no_accept_license(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="start", environment={"SPLUNK_PASSWORD": "something", "SPLUNK_START_ARGS": "nothing"}) @@ -118,7 +118,7 @@ def untest_splunk_entrypoint_start_no_accept_license(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "License not accepted, please ensure the environment variable SPLUNK_START_ARGS contains the '--accept-license' flag" in output - def untest_splunk_entrypoint_no_provision(self): + def test_splunk_entrypoint_no_provision(self): cid = None try: # Run container @@ -143,7 +143,7 @@ def untest_splunk_entrypoint_no_provision(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_splunk_uid_gid(self): + def test_splunk_uid_gid(self): cid = None try: # Run container @@ -164,7 +164,7 @@ def untest_splunk_uid_gid(self): if cid: self.client.remove_container(cid, v=True, force=True) - def test_compose_1so_trial(self): + def untest_compose_1so_trial(self): # Standup deployment self.compose_file_name = "1so_trial.yaml" self.project_name = self.generate_random_string() @@ -266,7 +266,7 @@ def untest_compose_1so_splunk_add(self): # Check Splunkd using the new users assert self.check_splunkd("newman", "changemepls") - def untest_adhoc_1so_using_default_yml(self): + def test_adhoc_1so_using_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) # Generate default.yml @@ -314,7 +314,7 @@ def untest_adhoc_1so_using_default_yml(self): except OSError: pass - def untest_adhoc_1so_splunk_launch_conf(self): + def test_adhoc_1so_splunk_launch_conf(self): # Create a splunk container cid = None try: @@ -350,7 +350,7 @@ def untest_adhoc_1so_splunk_launch_conf(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_change_tailed_files(self): + def test_adhoc_1so_change_tailed_files(self): # Create a splunk container cid = None try: @@ -386,7 +386,7 @@ def untest_adhoc_1so_change_tailed_files(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_password_from_file(self): + def test_adhoc_1so_password_from_file(self): # Create a splunk container cid = None # From fixtures/pwfile @@ -420,7 +420,7 @@ def untest_adhoc_1so_password_from_file(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_reflexive_forwarding(self): + def test_adhoc_1so_reflexive_forwarding(self): # Create a splunk container cid = None try: @@ -456,7 +456,7 @@ def untest_adhoc_1so_reflexive_forwarding(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_splunk_pass4symmkey(self): + def test_adhoc_1so_splunk_pass4symmkey(self): # Create a splunk container cid = None try: @@ -494,7 +494,7 @@ def untest_adhoc_1so_splunk_pass4symmkey(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_splunk_secret_env(self): + def test_adhoc_1so_splunk_secret_env(self): # Create a splunk container cid = None try: @@ -561,7 +561,7 @@ def untest_compose_1so_hec(self): status, content = self.handle_request_retry("POST", url, kwargs) assert status == 200 - def untest_adhoc_1so_preplaybook_with_sudo(self): + def test_adhoc_1so_preplaybook_with_sudo(self): # Create a splunk container cid = None try: @@ -602,7 +602,7 @@ def untest_adhoc_1so_preplaybook_with_sudo(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_postplaybook(self): + def test_adhoc_1so_postplaybook(self): # Create a splunk container cid = None try: @@ -643,7 +643,7 @@ def untest_adhoc_1so_postplaybook(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_postplaybook_with_sudo(self): + def test_adhoc_1so_postplaybook_with_sudo(self): # Create a splunk container cid = None try: @@ -684,7 +684,7 @@ def untest_adhoc_1so_postplaybook_with_sudo(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_apps_location_in_default_yml(self): + def test_adhoc_1so_apps_location_in_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) DIR_EXAMPLE_APP = os.path.join(self.DIR, "splunk_app_example") @@ -747,7 +747,7 @@ def untest_adhoc_1so_apps_location_in_default_yml(self): except OSError: pass - def untest_adhoc_1so_bind_mount_apps(self): + def test_adhoc_1so_bind_mount_apps(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -804,7 +804,7 @@ def untest_adhoc_1so_bind_mount_apps(self): except OSError: pass - def untest_adhoc_1so_run_as_root(self): + def test_adhoc_1so_run_as_root(self): # Create a splunk container cid = None try: @@ -841,7 +841,7 @@ def untest_adhoc_1so_run_as_root(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_declarative_password(self): + def test_adhoc_1so_declarative_password(self): """ This test is intended to check how the container gets provisioned with declarative passwords """ @@ -897,7 +897,7 @@ def untest_adhoc_1so_declarative_password(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1uf_declarative_password(self): + def test_adhoc_1uf_declarative_password(self): """ This test is intended to check how the container gets provisioned with declarative passwords """ @@ -953,7 +953,7 @@ def untest_adhoc_1uf_declarative_password(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_hec_idempotence(self): + def test_adhoc_1so_hec_idempotence(self): """ This test is intended to check how the container gets provisioned with changing splunk.hec.* parameters """ @@ -1118,7 +1118,7 @@ def untest_adhoc_1so_hec_idempotence(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_hec_ssl_disabled(self): + def test_adhoc_1so_hec_ssl_disabled(self): # Create the container cid = None try: @@ -1153,7 +1153,7 @@ def untest_adhoc_1so_hec_ssl_disabled(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_splunkd_no_ssl(self): + def test_adhoc_1so_splunkd_no_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1213,7 +1213,7 @@ def untest_adhoc_1so_splunkd_no_ssl(self): except OSError: pass - def untest_adhoc_1so_web_ssl(self): + def test_adhoc_1so_web_ssl(self): # Create the container splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1401,7 +1401,7 @@ def untest_compose_1so_enable_service(self): std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out - def untest_adhoc_1so_hec_custom_cert(self): + def test_adhoc_1so_hec_custom_cert(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1476,7 +1476,7 @@ def untest_adhoc_1so_hec_custom_cert(self): except OSError: pass - def untest_adhoc_1so_splunktcp_ssl(self): + def test_adhoc_1so_splunktcp_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1545,7 +1545,7 @@ def untest_adhoc_1so_splunktcp_ssl(self): except OSError: pass - def untest_adhoc_1so_splunkd_custom_ssl(self): + def test_adhoc_1so_splunkd_custom_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1619,7 +1619,7 @@ def untest_adhoc_1so_splunkd_custom_ssl(self): except OSError: pass - def untest_adhoc_1so_upgrade(self): + def test_adhoc_1so_upgrade(self): # Pull the old image for line in self.client.pull("splunk/splunk:{}".format(OLD_SPLUNK_VERSION), stream=True, decode=True): continue @@ -1686,7 +1686,7 @@ def untest_adhoc_1so_upgrade(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1so_preplaybook(self): + def test_adhoc_1so_preplaybook(self): # Create a splunk container cid = None try: @@ -1775,7 +1775,7 @@ def untest_compose_1so_apps(self): except OSError: pass - def untest_adhoc_1so_custom_conf(self): + def test_adhoc_1so_custom_conf(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) os.mkdir(self.DIR) @@ -1884,7 +1884,7 @@ def untest_compose_1uf_apps(self): except OSError: pass - def untest_uf_entrypoint_help(self): + def test_uf_entrypoint_help(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="help") self.client.start(cid.get("Id")) @@ -1892,7 +1892,7 @@ def untest_uf_entrypoint_help(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "SPLUNK_CMD - 'any splunk command' - execute any splunk commands separated by commas" in output - def untest_uf_entrypoint_create_defaults(self): + def test_uf_entrypoint_create_defaults(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="create-defaults") self.client.start(cid.get("Id")) @@ -1901,7 +1901,7 @@ def untest_uf_entrypoint_create_defaults(self): assert "home: /opt/splunk" in output assert "password: " in output - def untest_uf_entrypoint_start_no_password(self): + def test_uf_entrypoint_start_no_password(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="start", environment={"SPLUNK_START_ARGS": "nothing"}) @@ -1910,7 +1910,7 @@ def untest_uf_entrypoint_start_no_password(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "WARNING: No password ENV var." in output - def untest_uf_entrypoint_start_no_accept_license(self): + def test_uf_entrypoint_start_no_accept_license(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="start", environment={"SPLUNK_PASSWORD": "something", "SPLUNK_START_ARGS": "nothing"}) @@ -1919,7 +1919,7 @@ def untest_uf_entrypoint_start_no_accept_license(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "License not accepted, please ensure the environment variable SPLUNK_START_ARGS contains the '--accept-license' flag" in output - def untest_uf_entrypoint_no_provision(self): + def test_uf_entrypoint_no_provision(self): cid = None try: # Run container @@ -1945,7 +1945,7 @@ def untest_uf_entrypoint_no_provision(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_uf_uid_gid(self): + def test_uf_uid_gid(self): cid = None try: # Run container @@ -1967,7 +1967,7 @@ def untest_uf_uid_gid(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1uf_splunktcp_ssl(self): + def test_adhoc_1uf_splunktcp_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2036,7 +2036,7 @@ def untest_adhoc_1uf_splunktcp_ssl(self): except OSError: pass - def untest_adhoc_1uf_splunkd_custom_ssl(self): + def test_adhoc_1uf_splunkd_custom_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2108,7 +2108,7 @@ def untest_adhoc_1uf_splunkd_custom_ssl(self): except OSError: pass - def untest_adhoc_1uf_hec_custom_cert(self): + def test_adhoc_1uf_hec_custom_cert(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2215,7 +2215,7 @@ def untest_compose_1uf_enable_service(self): std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out - def untest_adhoc_1uf_splunkd_no_ssl(self): + def test_adhoc_1uf_splunkd_no_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2337,7 +2337,7 @@ def untest_compose_1uf_splunk_cmd(self): assert self.check_splunkd("jerry", "changemepls") assert self.check_splunkd("george", "changemepls") - def untest_adhoc_1uf_using_default_yml(self): + def test_adhoc_1uf_using_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) # Generate default.yml @@ -2385,7 +2385,7 @@ def untest_adhoc_1uf_using_default_yml(self): except OSError: pass - def untest_adhoc_1uf_hec_ssl_disabled(self): + def test_adhoc_1uf_hec_ssl_disabled(self): # Create the container cid = None try: @@ -2420,7 +2420,7 @@ def untest_adhoc_1uf_hec_ssl_disabled(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1uf_change_tailed_files(self): + def test_adhoc_1uf_change_tailed_files(self): # Create a splunk container cid = None try: @@ -2456,7 +2456,7 @@ def untest_adhoc_1uf_change_tailed_files(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1uf_password_from_file(self): + def test_adhoc_1uf_password_from_file(self): # Create a splunk container cid = None # From fixtures/pwfile @@ -2522,7 +2522,7 @@ def untest_compose_1uf_hec(self): status, content = self.handle_request_retry("POST", url, kwargs) assert status == 200 - def untest_adhoc_1uf_splunk_pass4symmkey(self): + def test_adhoc_1uf_splunk_pass4symmkey(self): # Create a splunk container cid = None try: @@ -2560,7 +2560,7 @@ def untest_adhoc_1uf_splunk_pass4symmkey(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1uf_splunk_secret_env(self): + def test_adhoc_1uf_splunk_secret_env(self): # Create a uf container cid = None try: @@ -2595,7 +2595,7 @@ def untest_adhoc_1uf_splunk_secret_env(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1uf_bind_mount_apps(self): + def test_adhoc_1uf_bind_mount_apps(self): # Generate default.yml splunk_container_name = self.generate_random_string() self.project_name = self.generate_random_string() @@ -2650,7 +2650,7 @@ def untest_adhoc_1uf_bind_mount_apps(self): except OSError: pass - def untest_uf_ulimit(self): + def test_uf_ulimit(self): cid = None try: # Run container @@ -2671,7 +2671,7 @@ def untest_uf_ulimit(self): if cid: self.client.remove_container(cid, v=True, force=True) - def untest_adhoc_1uf_custom_conf(self): + def test_adhoc_1uf_custom_conf(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) os.mkdir(self.DIR) @@ -2732,7 +2732,7 @@ def untest_adhoc_1uf_custom_conf(self): except OSError: pass - def untest_adhoc_1uf_run_as_root(self): + def test_adhoc_1uf_run_as_root(self): # Create a uf container cid = None try: From 3ca39d659e8f2ecc1845e585278f41e031baf322 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Tue, 5 Mar 2024 13:57:45 -0800 Subject: [PATCH 17/18] add product for tests; --- tests/conftest.py | 19 ++++++ tests/test_single_splunk_image.py | 104 ++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index e2e57e39..56167376 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,5 +4,24 @@ import pytest +def pytest_configure(config): + # register your new marker to avoid warnings + config.addinivalue_line( + "markers", + "product: specify a test key" + ) + +def pytest_collection_modifyitems(config, items): + filter = config.getoption("--product") + if filter: + new_items = [] + for item in items: + mark = item.get_closest_marker("key") + if mark and mark.args and mark.args[0] == filter: + # collect all items that have a key marker with that value + new_items.append(item) + items[:] = new_items + def pytest_addoption(parser): parser.addoption("--platform", default="debian-9", action="store", help="Define which platform of images to run tests again (default: debian-9)") + parser.addoption("--product", default="all", action="store", help="Define which tests to run. Values can be splunk, uf, or all (default: all - Splunk and UF)") diff --git a/tests/test_single_splunk_image.py b/tests/test_single_splunk_image.py index 4e2cb65d..3fa64295 100644 --- a/tests/test_single_splunk_image.py +++ b/tests/test_single_splunk_image.py @@ -60,6 +60,8 @@ def teardown_method(self, method): pass self.compose_file_name, self.project_name, self.DIR = None, None, None + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_splunk_entrypoint_help(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="help") @@ -69,6 +71,8 @@ def test_splunk_entrypoint_help(self): assert "SPLUNK_HOME - home directory where Splunk gets installed (default: /opt/splunk)" in output assert "Examples:" in output + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_splunk_ulimit(self): cid = None try: @@ -90,6 +94,8 @@ def test_splunk_ulimit(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_splunk_entrypoint_create_defaults(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="create-defaults") @@ -100,6 +106,8 @@ def test_splunk_entrypoint_create_defaults(self): assert "password: " in output assert "secret: " in output + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_splunk_entrypoint_start_no_password(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="start", @@ -109,6 +117,8 @@ def test_splunk_entrypoint_start_no_password(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "WARNING: No password ENV var." in output + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_splunk_entrypoint_start_no_accept_license(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="start", @@ -118,6 +128,8 @@ def test_splunk_entrypoint_start_no_accept_license(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "License not accepted, please ensure the environment variable SPLUNK_START_ARGS contains the '--accept-license' flag" in output + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_splunk_entrypoint_no_provision(self): cid = None try: @@ -143,6 +155,8 @@ def test_splunk_entrypoint_no_provision(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_splunk_uid_gid(self): cid = None try: @@ -266,6 +280,8 @@ def untest_compose_1so_splunk_add(self): # Check Splunkd using the new users assert self.check_splunkd("newman", "changemepls") + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_using_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -314,6 +330,8 @@ def test_adhoc_1so_using_default_yml(self): except OSError: pass + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_splunk_launch_conf(self): # Create a splunk container cid = None @@ -350,6 +368,8 @@ def test_adhoc_1so_splunk_launch_conf(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_change_tailed_files(self): # Create a splunk container cid = None @@ -386,6 +406,8 @@ def test_adhoc_1so_change_tailed_files(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_password_from_file(self): # Create a splunk container cid = None @@ -420,6 +442,8 @@ def test_adhoc_1so_password_from_file(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_reflexive_forwarding(self): # Create a splunk container cid = None @@ -456,6 +480,8 @@ def test_adhoc_1so_reflexive_forwarding(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_splunk_pass4symmkey(self): # Create a splunk container cid = None @@ -494,6 +520,8 @@ def test_adhoc_1so_splunk_pass4symmkey(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_splunk_secret_env(self): # Create a splunk container cid = None @@ -561,6 +589,8 @@ def untest_compose_1so_hec(self): status, content = self.handle_request_retry("POST", url, kwargs) assert status == 200 + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_preplaybook_with_sudo(self): # Create a splunk container cid = None @@ -602,6 +632,8 @@ def test_adhoc_1so_preplaybook_with_sudo(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_postplaybook(self): # Create a splunk container cid = None @@ -643,6 +675,8 @@ def test_adhoc_1so_postplaybook(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_postplaybook_with_sudo(self): # Create a splunk container cid = None @@ -684,6 +718,8 @@ def test_adhoc_1so_postplaybook_with_sudo(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_apps_location_in_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -747,6 +783,8 @@ def test_adhoc_1so_apps_location_in_default_yml(self): except OSError: pass + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_bind_mount_apps(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -804,6 +842,8 @@ def test_adhoc_1so_bind_mount_apps(self): except OSError: pass + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_run_as_root(self): # Create a splunk container cid = None @@ -841,6 +881,8 @@ def test_adhoc_1so_run_as_root(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_declarative_password(self): """ This test is intended to check how the container gets provisioned with declarative passwords @@ -897,6 +939,8 @@ def test_adhoc_1so_declarative_password(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_declarative_password(self): """ This test is intended to check how the container gets provisioned with declarative passwords @@ -953,6 +997,8 @@ def test_adhoc_1uf_declarative_password(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_hec_idempotence(self): """ This test is intended to check how the container gets provisioned with changing splunk.hec.* parameters @@ -1118,6 +1164,8 @@ def test_adhoc_1so_hec_idempotence(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_hec_ssl_disabled(self): # Create the container cid = None @@ -1153,6 +1201,8 @@ def test_adhoc_1so_hec_ssl_disabled(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_splunkd_no_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -1213,6 +1263,8 @@ def test_adhoc_1so_splunkd_no_ssl(self): except OSError: pass + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_web_ssl(self): # Create the container splunk_container_name = self.generate_random_string() @@ -1401,6 +1453,8 @@ def untest_compose_1so_enable_service(self): std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_hec_custom_cert(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -1476,6 +1530,8 @@ def test_adhoc_1so_hec_custom_cert(self): except OSError: pass + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_splunktcp_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -1545,6 +1601,8 @@ def test_adhoc_1so_splunktcp_ssl(self): except OSError: pass + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_splunkd_custom_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -1619,6 +1677,8 @@ def test_adhoc_1so_splunkd_custom_ssl(self): except OSError: pass + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_upgrade(self): # Pull the old image for line in self.client.pull("splunk/splunk:{}".format(OLD_SPLUNK_VERSION), stream=True, decode=True): @@ -1686,6 +1746,8 @@ def test_adhoc_1so_upgrade(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_preplaybook(self): # Create a splunk container cid = None @@ -1775,6 +1837,8 @@ def untest_compose_1so_apps(self): except OSError: pass + @pytest.mark.product("splunk") + @pytest.mark.product("all") def test_adhoc_1so_custom_conf(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1884,6 +1948,8 @@ def untest_compose_1uf_apps(self): except OSError: pass + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_uf_entrypoint_help(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="help") @@ -1892,6 +1958,8 @@ def test_uf_entrypoint_help(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "SPLUNK_CMD - 'any splunk command' - execute any splunk commands separated by commas" in output + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_uf_entrypoint_create_defaults(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="create-defaults") @@ -1901,6 +1969,8 @@ def test_uf_entrypoint_create_defaults(self): assert "home: /opt/splunk" in output assert "password: " in output + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_uf_entrypoint_start_no_password(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="start", @@ -1910,6 +1980,8 @@ def test_uf_entrypoint_start_no_password(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "WARNING: No password ENV var." in output + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_uf_entrypoint_start_no_accept_license(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="start", @@ -1919,6 +1991,8 @@ def test_uf_entrypoint_start_no_accept_license(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "License not accepted, please ensure the environment variable SPLUNK_START_ARGS contains the '--accept-license' flag" in output + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_uf_entrypoint_no_provision(self): cid = None try: @@ -1945,6 +2019,8 @@ def test_uf_entrypoint_no_provision(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_uf_uid_gid(self): cid = None try: @@ -1967,6 +2043,8 @@ def test_uf_uid_gid(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_splunktcp_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -2036,6 +2114,8 @@ def test_adhoc_1uf_splunktcp_ssl(self): except OSError: pass + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_splunkd_custom_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -2108,6 +2188,8 @@ def test_adhoc_1uf_splunkd_custom_ssl(self): except OSError: pass + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_hec_custom_cert(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -2215,6 +2297,8 @@ def untest_compose_1uf_enable_service(self): std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_splunkd_no_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -2337,6 +2421,8 @@ def untest_compose_1uf_splunk_cmd(self): assert self.check_splunkd("jerry", "changemepls") assert self.check_splunkd("george", "changemepls") + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_using_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2385,6 +2471,8 @@ def test_adhoc_1uf_using_default_yml(self): except OSError: pass + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_hec_ssl_disabled(self): # Create the container cid = None @@ -2420,6 +2508,8 @@ def test_adhoc_1uf_hec_ssl_disabled(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_change_tailed_files(self): # Create a splunk container cid = None @@ -2456,6 +2546,8 @@ def test_adhoc_1uf_change_tailed_files(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_password_from_file(self): # Create a splunk container cid = None @@ -2522,6 +2614,8 @@ def untest_compose_1uf_hec(self): status, content = self.handle_request_retry("POST", url, kwargs) assert status == 200 + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_splunk_pass4symmkey(self): # Create a splunk container cid = None @@ -2560,6 +2654,8 @@ def test_adhoc_1uf_splunk_pass4symmkey(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_splunk_secret_env(self): # Create a uf container cid = None @@ -2595,6 +2691,8 @@ def test_adhoc_1uf_splunk_secret_env(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_bind_mount_apps(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -2650,6 +2748,8 @@ def test_adhoc_1uf_bind_mount_apps(self): except OSError: pass + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_uf_ulimit(self): cid = None try: @@ -2671,6 +2771,8 @@ def test_uf_ulimit(self): if cid: self.client.remove_container(cid, v=True, force=True) + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_custom_conf(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2732,6 +2834,8 @@ def test_adhoc_1uf_custom_conf(self): except OSError: pass + @pytest.mark.product("uf") + @pytest.mark.product("all") def test_adhoc_1uf_run_as_root(self): # Create a uf container cid = None From b503965e5a0a73138f9b886ccc18114421e67474 Mon Sep 17 00:00:00 2001 From: Aditya Pingle Date: Tue, 5 Mar 2024 15:26:53 -0800 Subject: [PATCH 18/18] add marker for product --- tests/conftest.py | 34 ++--- tests/executor.py | 14 +- tests/test_single_splunk_image.py | 230 +++++++++++++++--------------- 3 files changed, 139 insertions(+), 139 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 56167376..4be6ab31 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,24 +4,24 @@ import pytest -def pytest_configure(config): - # register your new marker to avoid warnings - config.addinivalue_line( - "markers", - "product: specify a test key" - ) +#def pytest_configure(config): +# # register your new marker to avoid warnings +# config.addinivalue_line( +# "markers", +# "product: specify a test key" +# ) -def pytest_collection_modifyitems(config, items): - filter = config.getoption("--product") - if filter: - new_items = [] - for item in items: - mark = item.get_closest_marker("key") - if mark and mark.args and mark.args[0] == filter: - # collect all items that have a key marker with that value - new_items.append(item) - items[:] = new_items +#def pytest_collection_modifyitems(config, items): +# filter = config.getoption("--product") +# if filter: +# new_items = [] +# for item in items: +# mark = item.get_closest_marker("key") +# if mark and mark.args and mark.args[0] == filter: +# # collect all items that have a key marker with that value +# new_items.append(item) +# items[:] = new_items def pytest_addoption(parser): parser.addoption("--platform", default="debian-9", action="store", help="Define which platform of images to run tests again (default: debian-9)") - parser.addoption("--product", default="all", action="store", help="Define which tests to run. Values can be splunk, uf, or all (default: all - Splunk and UF)") +# parser.addoption("--product", default="all", action="store", help="Define which tests to run. Values can be splunk, uf, or all (default: all - Splunk and UF)") diff --git a/tests/executor.py b/tests/executor.py index 8050d8d1..7f315ced 100644 --- a/tests/executor.py +++ b/tests/executor.py @@ -146,10 +146,10 @@ def wait_for_containers(self, count, label=None, name=None, timeout=500): # The healthcheck on our Splunk image is not reliable - resorting to checking logs if container.get("Labels", {}).get("maintainer") == "support@splunk.com": output = self.client.logs(container["Id"], tail=5).decode() - self.logger.info(f"DEBUG: Check the tupe of output - {type(output)}") + self.logger.info("DEBUG: Check the tupe of output - {}".format(type(output))) if "unable to" in output or "denied" in output or "splunkd.pid file is unreadable" in output: self.logger.error("Container {} did not start properly, last log line: {}".format(container["Names"][0], output)) - print(f"SCRIPT FAILS TO CREATE CONTAINER") + print("SCRIPT FAILS TO CREATE CONTAINER") sys.exit(1) elif "Ansible playbook complete" in output: self.logger.info("Container {} is ready".format(container["Names"][0])) @@ -237,10 +237,10 @@ def extract_json(self, container_name): self.logger.info("sleeping now for 10; check if docker container exists") os.system("echo '----------- START -----------'") os.system("docker ps -a") - os.system(f"docker logs {container_name}") + os.system("docker logs {}".format(container_name)) os.system("echo '----------- END -----------'") exec_command = self.client.exec_create(container_name, "cat /opt/container_artifact/ansible_inventory.json") - print(f"collect exec command: {exec_command}") + print("collect exec command: {}".format(exec_command)) json_data = self.client.exec_start(exec_command).decode() if "No such file or directory" in json_data: time.sleep(5) @@ -280,7 +280,7 @@ def _run_command(self, command, defaults_url=None, apps_url=None): env["SPLUNK_DEFAULTS_URL"] = defaults_url if apps_url: env["SPLUNK_APPS_URL"] = apps_url - self.logger.info(f"os.system attempt - {command}; SKIPPED") + self.logger.info("os.system attempt - {}; SKIPPED".format(command)) #os.system(command) self.logger.info("execute command vis subprocess;") proc = subprocess.Popen(sh, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, text=True) @@ -290,10 +290,10 @@ def _run_command(self, command, defaults_url=None, apps_url=None): self.logger.info("START RECORDING STDOUT") for line in iter(proc.stdout.readline, ''): self.logger.info(line) - lines.append(f"out: {line}") + lines.append("out: {}".format(line)) self.logger.info("START RECORDING STDERR") for line in iter(proc.stderr.readline, ''): - self.logger.info(f"err: {line}") + self.logger.info("err: {}".format(line)) err_lines.append(line) self.logger.info("PROC close stdout") proc.stdout.close() diff --git a/tests/test_single_splunk_image.py b/tests/test_single_splunk_image.py index 3fa64295..6ece0ef8 100644 --- a/tests/test_single_splunk_image.py +++ b/tests/test_single_splunk_image.py @@ -60,8 +60,8 @@ def teardown_method(self, method): pass self.compose_file_name, self.project_name, self.DIR = None, None, None - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_splunk_entrypoint_help(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="help") @@ -71,8 +71,8 @@ def test_splunk_entrypoint_help(self): assert "SPLUNK_HOME - home directory where Splunk gets installed (default: /opt/splunk)" in output assert "Examples:" in output - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_splunk_ulimit(self): cid = None try: @@ -94,8 +94,8 @@ def test_splunk_ulimit(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_splunk_entrypoint_create_defaults(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="create-defaults") @@ -106,8 +106,8 @@ def test_splunk_entrypoint_create_defaults(self): assert "password: " in output assert "secret: " in output - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_splunk_entrypoint_start_no_password(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="start", @@ -117,8 +117,8 @@ def test_splunk_entrypoint_start_no_password(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "WARNING: No password ENV var." in output - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_splunk_entrypoint_start_no_accept_license(self): # Run container cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="start", @@ -128,8 +128,8 @@ def test_splunk_entrypoint_start_no_accept_license(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "License not accepted, please ensure the environment variable SPLUNK_START_ARGS contains the '--accept-license' flag" in output - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_splunk_entrypoint_no_provision(self): cid = None try: @@ -155,8 +155,8 @@ def test_splunk_entrypoint_no_provision(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_splunk_uid_gid(self): cid = None try: @@ -185,25 +185,25 @@ def untest_compose_1so_trial(self): container_count, rc = self.compose_up() # Wait for containers to come up assert self.wait_for_containers(container_count, label="com.docker.compose.project={}".format(self.project_name)) - print(f"ALL CONTAINERS ARE UP") + print("ALL CONTAINERS ARE UP") # Check ansible inventory json - print(f"EXTRACT JSON") + print("EXTRACT JSON") log_json = self.extract_json("{}-so1-1".format(self.project_name)) - print(f"DONE EXTRACT JSON") - print(f"START: CHECK COMMON KEYS") + print("DONE EXTRACT JSON") + print("START: CHECK COMMON KEYS") self.check_common_keys(log_json, "so") - print(f"DONE: CHECK COMMON KEYS") + print("DONE: CHECK COMMON KEYS") # Check container logs - print(f"START: GET CONTAINER LOGS") + print("START: GET CONTAINER LOGS") output = self.get_container_logs("{}-so1-1".format(self.project_name)) - print(f"DONE: GET CONTAINER LOGS") - print(f"START: CHECK ANSIBLE OUTPUT") + print("DONE: GET CONTAINER LOGS") + print("START: CHECK ANSIBLE OUTPUT") self.check_ansible(output) - print(f"DONE: CHECL AANISBLE OUTPUT") + print("DONE: CHECL AANISBLE OUTPUT") # Check Splunkd on all the containers - print(f"START: CHECK SPLUNKD") + print("START: CHECK SPLUNKD") assert self.check_splunkd("admin", self.password) - print(f"DONE: CHECK SPLUNKD") + print("DONE: CHECK SPLUNKD") def untest_compose_1so_custombuild(self): # Standup deployment @@ -280,8 +280,8 @@ def untest_compose_1so_splunk_add(self): # Check Splunkd using the new users assert self.check_splunkd("newman", "changemepls") - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_using_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -330,8 +330,8 @@ def test_adhoc_1so_using_default_yml(self): except OSError: pass - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_splunk_launch_conf(self): # Create a splunk container cid = None @@ -368,8 +368,8 @@ def test_adhoc_1so_splunk_launch_conf(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_change_tailed_files(self): # Create a splunk container cid = None @@ -406,8 +406,8 @@ def test_adhoc_1so_change_tailed_files(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_password_from_file(self): # Create a splunk container cid = None @@ -442,8 +442,8 @@ def test_adhoc_1so_password_from_file(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_reflexive_forwarding(self): # Create a splunk container cid = None @@ -480,8 +480,8 @@ def test_adhoc_1so_reflexive_forwarding(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_splunk_pass4symmkey(self): # Create a splunk container cid = None @@ -520,8 +520,8 @@ def test_adhoc_1so_splunk_pass4symmkey(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_splunk_secret_env(self): # Create a splunk container cid = None @@ -589,8 +589,8 @@ def untest_compose_1so_hec(self): status, content = self.handle_request_retry("POST", url, kwargs) assert status == 200 - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_preplaybook_with_sudo(self): # Create a splunk container cid = None @@ -632,8 +632,8 @@ def test_adhoc_1so_preplaybook_with_sudo(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_postplaybook(self): # Create a splunk container cid = None @@ -675,8 +675,8 @@ def test_adhoc_1so_postplaybook(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_postplaybook_with_sudo(self): # Create a splunk container cid = None @@ -718,8 +718,8 @@ def test_adhoc_1so_postplaybook_with_sudo(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_apps_location_in_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -783,8 +783,8 @@ def test_adhoc_1so_apps_location_in_default_yml(self): except OSError: pass - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_bind_mount_apps(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -842,8 +842,8 @@ def test_adhoc_1so_bind_mount_apps(self): except OSError: pass - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_run_as_root(self): # Create a splunk container cid = None @@ -881,8 +881,8 @@ def test_adhoc_1so_run_as_root(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_declarative_password(self): """ This test is intended to check how the container gets provisioned with declarative passwords @@ -939,8 +939,8 @@ def test_adhoc_1so_declarative_password(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_declarative_password(self): """ This test is intended to check how the container gets provisioned with declarative passwords @@ -997,8 +997,8 @@ def test_adhoc_1uf_declarative_password(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_hec_idempotence(self): """ This test is intended to check how the container gets provisioned with changing splunk.hec.* parameters @@ -1164,8 +1164,8 @@ def test_adhoc_1so_hec_idempotence(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_hec_ssl_disabled(self): # Create the container cid = None @@ -1201,8 +1201,8 @@ def test_adhoc_1so_hec_ssl_disabled(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_splunkd_no_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -1263,8 +1263,8 @@ def test_adhoc_1so_splunkd_no_ssl(self): except OSError: pass - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_web_ssl(self): # Create the container splunk_container_name = self.generate_random_string() @@ -1453,8 +1453,8 @@ def untest_compose_1so_enable_service(self): std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_hec_custom_cert(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -1530,8 +1530,8 @@ def test_adhoc_1so_hec_custom_cert(self): except OSError: pass - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_splunktcp_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -1601,8 +1601,8 @@ def test_adhoc_1so_splunktcp_ssl(self): except OSError: pass - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_splunkd_custom_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -1677,8 +1677,8 @@ def test_adhoc_1so_splunkd_custom_ssl(self): except OSError: pass - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_upgrade(self): # Pull the old image for line in self.client.pull("splunk/splunk:{}".format(OLD_SPLUNK_VERSION), stream=True, decode=True): @@ -1746,8 +1746,8 @@ def test_adhoc_1so_upgrade(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_preplaybook(self): # Create a splunk container cid = None @@ -1837,8 +1837,8 @@ def untest_compose_1so_apps(self): except OSError: pass - @pytest.mark.product("splunk") - @pytest.mark.product("all") + @pytest.mark.splunk + @pytest.mark.all def test_adhoc_1so_custom_conf(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -1948,8 +1948,8 @@ def untest_compose_1uf_apps(self): except OSError: pass - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_uf_entrypoint_help(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="help") @@ -1958,8 +1958,8 @@ def test_uf_entrypoint_help(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "SPLUNK_CMD - 'any splunk command' - execute any splunk commands separated by commas" in output - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_uf_entrypoint_create_defaults(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="create-defaults") @@ -1969,8 +1969,8 @@ def test_uf_entrypoint_create_defaults(self): assert "home: /opt/splunk" in output assert "password: " in output - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_uf_entrypoint_start_no_password(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="start", @@ -1980,8 +1980,8 @@ def test_uf_entrypoint_start_no_password(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "WARNING: No password ENV var." in output - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_uf_entrypoint_start_no_accept_license(self): # Run container cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="start", @@ -1991,8 +1991,8 @@ def test_uf_entrypoint_start_no_accept_license(self): self.client.remove_container(cid.get("Id"), v=True, force=True) assert "License not accepted, please ensure the environment variable SPLUNK_START_ARGS contains the '--accept-license' flag" in output - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_uf_entrypoint_no_provision(self): cid = None try: @@ -2019,8 +2019,8 @@ def test_uf_entrypoint_no_provision(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_uf_uid_gid(self): cid = None try: @@ -2043,8 +2043,8 @@ def test_uf_uid_gid(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_splunktcp_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -2114,8 +2114,8 @@ def test_adhoc_1uf_splunktcp_ssl(self): except OSError: pass - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_splunkd_custom_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -2188,8 +2188,8 @@ def test_adhoc_1uf_splunkd_custom_ssl(self): except OSError: pass - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_hec_custom_cert(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -2297,8 +2297,8 @@ def untest_compose_1uf_enable_service(self): std_out = self.client.exec_start(exec_command).decode() assert "/etc/init.d/splunk" in std_out - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_splunkd_no_ssl(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -2421,8 +2421,8 @@ def untest_compose_1uf_splunk_cmd(self): assert self.check_splunkd("jerry", "changemepls") assert self.check_splunkd("george", "changemepls") - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_using_default_yml(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2471,8 +2471,8 @@ def test_adhoc_1uf_using_default_yml(self): except OSError: pass - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_hec_ssl_disabled(self): # Create the container cid = None @@ -2508,8 +2508,8 @@ def test_adhoc_1uf_hec_ssl_disabled(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_change_tailed_files(self): # Create a splunk container cid = None @@ -2546,8 +2546,8 @@ def test_adhoc_1uf_change_tailed_files(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_password_from_file(self): # Create a splunk container cid = None @@ -2614,8 +2614,8 @@ def untest_compose_1uf_hec(self): status, content = self.handle_request_retry("POST", url, kwargs) assert status == 200 - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_splunk_pass4symmkey(self): # Create a splunk container cid = None @@ -2654,8 +2654,8 @@ def test_adhoc_1uf_splunk_pass4symmkey(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_splunk_secret_env(self): # Create a uf container cid = None @@ -2691,8 +2691,8 @@ def test_adhoc_1uf_splunk_secret_env(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_bind_mount_apps(self): # Generate default.yml splunk_container_name = self.generate_random_string() @@ -2748,8 +2748,8 @@ def test_adhoc_1uf_bind_mount_apps(self): except OSError: pass - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_uf_ulimit(self): cid = None try: @@ -2771,8 +2771,8 @@ def test_uf_ulimit(self): if cid: self.client.remove_container(cid, v=True, force=True) - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_custom_conf(self): splunk_container_name = self.generate_random_string() self.DIR = os.path.join(self.FIXTURES_DIR, splunk_container_name) @@ -2834,8 +2834,8 @@ def test_adhoc_1uf_custom_conf(self): except OSError: pass - @pytest.mark.product("uf") - @pytest.mark.product("all") + @pytest.mark.uf + @pytest.mark.all def test_adhoc_1uf_run_as_root(self): # Create a uf container cid = None