Skip to content

Commit

Permalink
Update tests for new libsplunk.so
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc-splunk committed Aug 28, 2023
1 parent 1d0fbb5 commit a3b57c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@

PKG_NAME = "splunk-otel-auto-instrumentation"
LIBSPLUNK_PATH = "/usr/lib/splunk-instrumentation/libsplunk.so"
DEFAULT_INSTRUMENTATION_CONF = "/usr/lib/splunk-instrumentation/instrumentation.conf"
CUSTOM_INSTRUMENTATION_CONF = TESTS_DIR / "instrumentation" / "libsplunk-test.conf"
JAVA_CONFIG_PATH = "/etc/splunk/zeroconfig_java.conf"
CUSTOM_JAVA_CONFIG_PATH = TESTS_DIR / "instrumentation" / "libsplunk-java-test.conf"
DEFAULT_SYSTEMD_CONF_PATH = "/usr/lib/splunk-instrumentation/examples/systemd/00-splunk-otel-javaagent.conf"
CUSTOM_SYSTEMD_CONF_PATH = TESTS_DIR / "instrumentation" / "systemd-test.conf"
SYSTEMD_CONF_DIR = "/usr/lib/systemd/system.conf.d"
Expand Down Expand Up @@ -132,7 +132,7 @@ def verify_tomcat_instrumentation(container, otelcol_path, test_case, source, at
"sh -c 'echo /usr/lib/splunk-instrumentation/libsplunk.so > /etc/ld.so.preload'")
if test_case == "custom":
# overwrite the default instrumentation.conf with the custom one for testing
copy_file_into_container(container, CUSTOM_INSTRUMENTATION_CONF, DEFAULT_INSTRUMENTATION_CONF)
copy_file_into_container(container, CUSTOM_JAVA_CONFIG_PATH, JAVA_CONFIG_PATH)
# start the collector and get the output stream
stream = container.exec_run(f"{otelcol_path} --config=/test/config.yaml", stream=True).output
print("Starting tomcat from a shell ...")
Expand Down Expand Up @@ -194,16 +194,12 @@ def test_tomcat_instrumentation(distro, arch, test_case, source):
run_container_cmd(container, f"chmod a+x /test/{otelcol_bin}")

install_package(container, distro, f"/test/{pkg_base}")
for path in [JAVA_AGENT_PATH, LIBSPLUNK_PATH, DEFAULT_INSTRUMENTATION_CONF, DEFAULT_SYSTEMD_CONF_PATH]:
for path in [JAVA_AGENT_PATH, LIBSPLUNK_PATH, JAVA_CONFIG_PATH, DEFAULT_SYSTEMD_CONF_PATH]:
assert container_file_exists(container, path), f"{path} not found"

if test_case == "default":
if source == "libsplunk":
# service name auto-generated by libsplunk.so
service_name = r"Str\(org-apache-catalina-startup-bootstrap\)"
else:
# service name auto-generated by java agent
service_name = r"Str\(Hello, World Application\)"
# service name auto-generated by java agent
service_name = r"Str\(Hello, World Application\)"
environment = None
profiling = None
else:
Expand Down Expand Up @@ -244,7 +240,7 @@ def test_package_uninstall(distro, arch):

verify_preload(container, "# This line should be preserved")

for path in [JAVA_AGENT_PATH, LIBSPLUNK_PATH, DEFAULT_INSTRUMENTATION_CONF, DEFAULT_SYSTEMD_CONF_PATH]:
for path in [JAVA_AGENT_PATH, LIBSPLUNK_PATH, JAVA_CONFIG_PATH, DEFAULT_SYSTEMD_CONF_PATH]:
assert container_file_exists(container, path), f"{path} not found"

# verify libsplunk.so was not automatically added to /etc/ld.so.preload
Expand All @@ -266,7 +262,7 @@ def test_package_uninstall(distro, arch):
assert container.exec_run(f"rpm -q {PKG_NAME}").exit_code != 0

# verify files were uninstalled
for path in [JAVA_AGENT_PATH, LIBSPLUNK_PATH, DEFAULT_INSTRUMENTATION_CONF, DEFAULT_SYSTEMD_CONF_PATH]:
for path in [JAVA_AGENT_PATH, LIBSPLUNK_PATH, JAVA_CONFIG_PATH, DEFAULT_SYSTEMD_CONF_PATH]:
assert not container_file_exists(container, path)

# verify libsplunk.so was removed from /etc/ld.so.preload
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
JAVA_TOOL_OPTIONS=-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar
OTEL_RESOURCE_ATTRIBUTES=deployment.environment=deployment_environment_from_libsplunk
OTEL_SERVICE_NAME=service_name_from_libsplunk
SPLUNK_METRICS_ENABLED=true
SPLUNK_PROFILER_ENABLED=true
SPLUNK_PROFILER_MEMORY_ENABLED=true

This file was deleted.

0 comments on commit a3b57c4

Please sign in to comment.