Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc-splunk committed Dec 1, 2023
1 parent af4f156 commit ad691f1
Show file tree
Hide file tree
Showing 12 changed files with 350 additions and 41 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/chef-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- main
- chef-node-zc
paths:
- '.github/workflows/chef-test.yml'
- 'deployments/chef/**'
Expand Down Expand Up @@ -94,6 +95,9 @@ jobs:
with:
version: 21.12.720

- run: knife supermarket install nodejs
if: ${{ contains(matrix.SUITE, 'node') }}

- run: kitchen test ${{ matrix.SUITE }}-${{ matrix.DISTRO }}

- uses: actions/upload-artifact@v3
Expand Down
3 changes: 3 additions & 0 deletions deployments/chef/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,7 @@
default['splunk_otel_collector']['auto_instrumentation_enable_profiler_memory'] = false
default['splunk_otel_collector']['auto_instrumentation_enable_metrics'] = false
default['splunk_otel_collector']['auto_instrumentation_otlp_endpoint'] = 'http://127.0.0.1:4317'
default['splunk_otel_collector']['with_auto_instrumentation_sdks'] = %w(java)
default['splunk_otel_collector']['auto_instrumentation_nodejs_npm_command'] = 'npm install'
default['splunk_otel_collector']['auto_instrumentation_nodejs_npm_prefix'] = '--global'
end
87 changes: 85 additions & 2 deletions deployments/chef/kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,35 @@ platforms:
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: centos-7
driver:
image: dokken/centos-7
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: centos-8
driver:
image: dokken/centos-8
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: centos-9
driver:
image: dokken/centos-stream-9
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: debian-9
driver:
Expand All @@ -55,20 +63,26 @@ platforms:
pid_one_command: /bin/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: debian-10
driver:
image: dokken/debian-10
pid_one_command: /bin/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: debian-11
driver:
image: dokken/debian-11
pid_one_command: /bin/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: opensuse-12
driver:
Expand All @@ -90,48 +104,62 @@ platforms:
pid_one_command: /sbin/init
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: opensuse-15
driver:
image: dokken/opensuse-leap-15
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: oraclelinux-7
driver:
image: dokken/oraclelinux-7
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: oraclelinux-8
driver:
image: dokken/oraclelinux-8
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: ubuntu-18.04
driver:
image: dokken/ubuntu-18.04
pid_one_command: /bin/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: ubuntu-20.04
driver:
image: dokken/ubuntu-20.04
pid_one_command: /bin/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

- name: ubuntu-22.04
driver:
image: dokken/ubuntu-22.04
pid_one_command: /bin/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
env:
NODE_PATH: /usr/local/nodejs-binary-14.17.3/lib/node_modules

suites:
- name: default
Expand Down Expand Up @@ -170,14 +198,15 @@ suites:
splunk_realm: test
with_auto_instrumentation: true

- name: with_custom_preload_instrumentation
- name: with_custom_preload_java_instrumentation
run_list:
- recipe[splunk_otel_collector]
attributes:
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks: ["java"]
auto_instrumentation_ld_so_preload: "# my extra library"
auto_instrumentation_resource_attributes: deployment.environment=test
auto_instrumentation_service_name: test
Expand All @@ -188,6 +217,32 @@ suites:
auto_instrumentation_enable_metrics: true
auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317

- name: with_custom_preload_node_instrumentation
run_list:
- recipe[nodejs]
- recipe[splunk_otel_collector]
attributes:
nodejs:
install_method: binary
version: 14.17.3
binary:
append_env_path: false
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks: ["nodejs"]
auto_instrumentation_ld_so_preload: "# my extra library"
auto_instrumentation_resource_attributes: deployment.environment=test
auto_instrumentation_service_name: test
auto_instrumentation_generate_service_name: false
auto_instrumentation_disable_telemetry: true
auto_instrumentation_enable_profiler: true
auto_instrumentation_enable_profiler_memory: true
auto_instrumentation_enable_metrics: true
auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317
nodejs_manage_node: true

- name: with_default_systemd_instrumentation
run_list:
- recipe[splunk_otel_collector]
Expand All @@ -198,14 +253,41 @@ suites:
with_auto_instrumentation: true
auto_instrumentation_systemd: true

- name: with_custom_systemd_instrumentation
- name: with_custom_systemd_java_instrumentation
run_list:
- recipe[splunk_otel_collector]
attributes:
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks: ["java"]
auto_instrumentation_ld_so_preload: "# this should not be added"
auto_instrumentation_systemd: true
auto_instrumentation_resource_attributes: deployment.environment=test
auto_instrumentation_service_name: test
auto_instrumentation_generate_service_name: false
auto_instrumentation_disable_telemetry: true
auto_instrumentation_enable_profiler: true
auto_instrumentation_enable_profiler_memory: true
auto_instrumentation_enable_metrics: true
auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317

- name: with_custom_systemd_node_instrumentation
run_list:
- recipe[nodejs]
- recipe[splunk_otel_collector]
attributes:
nodejs:
install_method: binary
version: 14.17.3
binary:
append_env_path: false
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks: ["nodejs"]
auto_instrumentation_ld_so_preload: "# this should not be added"
auto_instrumentation_systemd: true
auto_instrumentation_resource_attributes: deployment.environment=test
Expand All @@ -216,3 +298,4 @@ suites:
auto_instrumentation_enable_profiler_memory: true
auto_instrumentation_enable_metrics: true
auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317
nodejs_manage_node: true
123 changes: 84 additions & 39 deletions deployments/chef/recipes/auto_instrumentation.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Cookbook:: splunk_otel_collector
# Recipe:: auto_instrumentation

ohai 'reload packages' do
plugin 'packages'
action :nothing
end
with_new_instrumentation = node['splunk_otel_collector']['auto_instrumentation_version'] == 'latest' || Gem::Version.new(node['splunk_otel_collector']['auto_instrumentation_version']) >= Gem::Version.new('0.87.0')
splunk_otel_js_path = '/usr/lib/splunk-instrumentation/splunk-otel-js.tgz'
with_systemd = node['splunk_otel_collector']['auto_instrumentation_systemd'].to_s.downcase == 'true'
with_java = node['splunk_otel_collector']['with_auto_instrumentation_sdks'].include?('java')
with_nodejs = node['splunk_otel_collector']['with_auto_instrumentation_sdks'].include?('nodejs')
npm_command = node['splunk_otel_collector']['auto_instrumentation_npm_command']
npm_prefix = node['splunk_otel_collector']['auto_instrumentation_npm_prefix']
nodejs_package = node['splunk_otel_collector']['auto_instrumentation_nodejs_package']

package 'splunk-otel-auto-instrumentation' do
action :install
Expand All @@ -16,45 +20,86 @@
&& Gem::Version.new(node['packages']['apt']['version'].split('~')[0]) >= Gem::Version.new('1.1.0')
allow_downgrade true if platform_family?('amazon', 'rhel', 'suse')
notifies :reload, 'ohai[reload packages]', :immediately
notifies :run, 'execute[Install splunk-otel-js]', :immediately
notifies :create, 'template[/etc/ld.so.preload]', :delayed
notifies :run, 'execute[reload systemd]', :delayed
end

ohai 'reload packages' do
plugin 'packages'
action :nothing
end

execute 'Install splunk-otel-js' do
command "#{npm_command} #{npm_prefix} #{splunk_otel_js_path}"
action :nothing
only_if { with_nodejs && with_new_instrumentation }
end

file '/etc/splunk/zeroconfig/java.conf' do
action :delete
only_if { with_systemd || !with_java }
end

file '/etc/splunk/zeroconfig/node.conf' do
action :delete
only_if { with_systemd || !with_nodejs }
end

file '/usr/lib/splunk-instrumentation/instrumentation.conf' do
action :delete
only_if { with_systemd || with_new_instrumentation }
end

directory '/usr/lib/systemd/system.conf.d' do
recursive true
action :nothing
end

template '/usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf' do
variables(
installed_version: lazy { node['packages']['splunk-otel-auto-instrumentation']['version'] }
)
source '00-splunk-otel-auto-instrumentation.conf.erb'
notifies :create, 'directory[/usr/lib/systemd/system.conf.d]', :before
only_if { with_systemd }
end

file '/usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf' do
action :delete
only_if { !with_systemd }
end

template '/etc/splunk/zeroconfig/java.conf' do
variables(
installed_version: lazy { node['packages']['splunk-otel-auto-instrumentation']['version'] }
)
source 'java.conf.erb'
only_if { with_java && with_new_instrumentation && !with_systemd }
end

template '/etc/splunk/zeroconfig/node.conf' do
variables(
installed_version: lazy { node['packages']['splunk-otel-auto-instrumentation']['version'] }
)
source 'node.conf.erb'
only_if { with_node && with_new_instrumentation && !with_systemd }
end

template '/usr/lib/splunk-instrumentation/instrumentation.conf' do
variables(
installed_version: lazy { node['packages']['splunk-otel-auto-instrumentation']['version'] }
)
source 'instrumentation.conf.erb'
only_if { with_java && !with_new_instrumentation && !with_systemd }
end

template '/etc/ld.so.preload' do
source 'ld.so.preload.erb'
action :nothing
end

if node['splunk_otel_collector']['auto_instrumentation_systemd'].to_s.downcase == 'true'
execute 'reload systemd' do
command 'systemctl daemon-reload'
action :nothing
end
directory '/usr/lib/systemd/system.conf.d' do
recursive true
action :create
end
template '/usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf' do
variables(
installed_version: lazy { node['packages']['splunk-otel-auto-instrumentation']['version'] }
)
source '00-splunk-otel-auto-instrumentation.conf.erb'
notifies :run, 'execute[reload systemd]', :immediately
end
else
file '/usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf' do
action :delete
end
if node['splunk_otel_collector']['auto_instrumentation_version'] == 'latest' || Gem::Version.new(node['splunk_otel_collector']['auto_instrumentation_version']) >= Gem::Version.new('0.87.0')
template '/etc/splunk/zeroconfig/java.conf' do
variables(
installed_version: lazy { node['packages']['splunk-otel-auto-instrumentation']['version'] }
)
source 'java.conf.erb'
end
else
template '/usr/lib/splunk-instrumentation/instrumentation.conf' do
variables(
installed_version: lazy { node['packages']['splunk-otel-auto-instrumentation']['version'] }
)
source 'instrumentation.conf.erb'
end
end
execute 'reload systemd' do
command 'systemctl daemon-reload'
action :nothing
end
Loading

0 comments on commit ad691f1

Please sign in to comment.