Skip to content

Commit

Permalink
Fix chef tests (signalfx#3628)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc-splunk authored Sep 12, 2023
1 parent 9866ce1 commit c709125
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 88 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/chef-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ jobs:
with:
version: 21.12.720

- name: gem install kitchen-docker
- name: Install kitchen-docker
run: |
$env:PATH = 'C:\opscode\chef-workstation\embedded\bin;' + $env:PATH
gem install kitchen-docker -v 2.12.0
chef env --chef-license accept
chef gem install kitchen-docker -v 2.12.0
- name: kitchen test ${{ matrix.SUITE }}-${{ matrix.DISTRO }}
run: |
Expand Down
13 changes: 7 additions & 6 deletions deployments/chef/kitchen.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ provisioner:
multiple_converge: 2
install_strategy: skip

verifier:
name: inspec

platforms:
- name: windows-2019
driver:
dockerfile: test/windows/Dockerfile.windows-2019
build_context: true
platform: windows

- name: windows-2022
driver:
dockerfile: test/windows/Dockerfile.windows-2022
Expand All @@ -39,7 +41,7 @@ suites:
verifier:
name: shell
remote_exec: true
command: rspec -Idefault/serverspec --format documentation default/serverspec/default_spec.rb
command: inspec exec default/inspec/default_spec.rb

- name: custom_vars
run_list:
Expand All @@ -60,7 +62,7 @@ suites:
verifier:
name: shell
remote_exec: true
command: rspec -Idefault/serverspec --format documentation custom_vars/serverspec/custom_vars_spec.rb
command: inspec exec custom_vars/inspec/custom_vars_spec.rb

- name: with_default_dotnet_instrumentation
run_list:
Expand All @@ -73,7 +75,7 @@ suites:
verifier:
name: shell
remote_exec: true
command: rspec -Idefault/serverspec --format documentation with_default_dotnet_instrumentation/serverspec/with_default_dotnet_instrumentation_spec.rb
command: inspec exec with_default_dotnet_instrumentation/inspec/with_default_dotnet_instrumentation_spec.rb

- name: with_custom_dotnet_instrumentation
run_list:
Expand All @@ -96,5 +98,4 @@ suites:
verifier:
name: shell
remote_exec: true
command: rspec -Idefault/serverspec --format documentation with_custom_dotnet_instrumentation/serverspec/with_custom_dotnet_instrumentation_spec.rb

command: inspec exec with_custom_dotnet_instrumentation/inspec/with_custom_dotnet_instrumentation_spec.rb
2 changes: 1 addition & 1 deletion deployments/chef/kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ provisioner:
multiple_converge: 2

verifier:
root_path: /opt/verifier
name: inspec

platforms:
- name: amazonlinux-2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'spec_helper'

splunk_access_token = 'testing123'
splunk_realm = 'test'
splunk_api_url = 'https://fake-splunk-api.com'
Expand All @@ -15,23 +13,23 @@
end

if os[:family] == 'windows'
bundle_dir = 'C:\Program Files\Splunk\OpenTelemetry Collector\agent-bundle'
bundle_dir = "#{ENV['ProgramFiles']}\\Splunk\\OpenTelemetry Collector\\agent-bundle"
collectd_dir = "#{bundle_dir}\\run\\collectd"
config_path = 'C:\ProgramData\Splunk\OpenTelemetry Collector\agent_config.yaml'
describe windows_registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do
it { should have_property_value('SPLUNK_ACCESS_TOKEN', :type_string, splunk_access_token) }
it { should have_property_value('SPLUNK_API_URL', :type_string, splunk_api_url) }
it { should have_property_value('SPLUNK_BUNDLE_DIR', :type_string, bundle_dir) }
it { should have_property_value('SPLUNK_COLLECTD_DIR', :type_string, collectd_dir) }
it { should have_property_value('SPLUNK_CONFIG', :type_string, config_path) }
it { should have_property_value('SPLUNK_HEC_TOKEN', :type_string, splunk_hec_token) }
it { should have_property_value('SPLUNK_HEC_URL', :type_string, splunk_hec_url) }
it { should have_property_value('SPLUNK_INGEST_URL', :type_string, splunk_ingest_url) }
it { should have_property_value('SPLUNK_MEMORY_TOTAL_MIB', :type_string, splunk_memory_total) }
it { should have_property_value('SPLUNK_REALM', :type_string, splunk_realm) }
it { should have_property_value('SPLUNK_TRACE_URL', :type_string, splunk_trace_url) }
it { should have_property_value('MY_CUSTOM_VAR1', :type_string, 'value1') }
it { should have_property_value('MY_CUSTOM_VAR2', :type_string, 'value2') }
config_path = "#{ENV['ProgramData']}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml"
describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do
its('SPLUNK_ACCESS_TOKEN') { should eq splunk_access_token }
its('SPLUNK_API_URL') { should eq splunk_api_url }
its('SPLUNK_BUNDLE_DIR') { should eq bundle_dir }
its('SPLUNK_COLLECTD_DIR') { should eq collectd_dir }
its('SPLUNK_CONFIG') { should eq config_path }
its('SPLUNK_HEC_TOKEN') { should eq splunk_hec_token }
its('SPLUNK_HEC_URL') { should eq splunk_hec_url }
its('SPLUNK_INGEST_URL') { should eq splunk_ingest_url }
its('SPLUNK_MEMORY_TOTAL_MIB') { should eq splunk_memory_total }
its('SPLUNK_REALM') { should eq splunk_realm }
its('SPLUNK_TRACE_URL') { should eq splunk_trace_url }
its('MY_CUSTOM_VAR1') { should eq 'value1' }
its('MY_CUSTOM_VAR2') { should eq 'value2' }
end
describe service('fluentdwinsvc') do
it { should be_enabled }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'spec_helper'

splunk_access_token = 'testing123'
splunk_realm = 'test'
splunk_api_url = "https://api.#{splunk_realm}.signalfx.com"
Expand All @@ -15,21 +13,21 @@
end

if os[:family] == 'windows'
bundle_dir = 'C:\Program Files\Splunk\OpenTelemetry Collector\agent-bundle'
bundle_dir = "#{ENV['ProgramFiles']}\\Splunk\\OpenTelemetry Collector\\agent-bundle"
collectd_dir = "#{bundle_dir}\\run\\collectd"
config_path = 'C:\ProgramData\Splunk\OpenTelemetry Collector\agent_config.yaml'
describe windows_registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do
it { should have_property_value('SPLUNK_ACCESS_TOKEN', :type_string, splunk_access_token) }
it { should have_property_value('SPLUNK_API_URL', :type_string, splunk_api_url) }
it { should have_property_value('SPLUNK_BUNDLE_DIR', :type_string, bundle_dir) }
it { should have_property_value('SPLUNK_COLLECTD_DIR', :type_string, collectd_dir) }
it { should have_property_value('SPLUNK_CONFIG', :type_string, config_path) }
it { should have_property_value('SPLUNK_HEC_TOKEN', :type_string, splunk_hec_token) }
it { should have_property_value('SPLUNK_HEC_URL', :type_string, splunk_hec_url) }
it { should have_property_value('SPLUNK_INGEST_URL', :type_string, splunk_ingest_url) }
it { should have_property_value('SPLUNK_MEMORY_TOTAL_MIB', :type_string, splunk_memory_total) }
it { should have_property_value('SPLUNK_REALM', :type_string, splunk_realm) }
it { should have_property_value('SPLUNK_TRACE_URL', :type_string, splunk_trace_url) }
config_path = "#{ENV['ProgramData']}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml"
describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do
its('SPLUNK_ACCESS_TOKEN') { should eq splunk_access_token }
its('SPLUNK_API_URL') { should eq splunk_api_url }
its('SPLUNK_BUNDLE_DIR') { should eq bundle_dir }
its('SPLUNK_COLLECTD_DIR') { should eq collectd_dir }
its('SPLUNK_CONFIG') { should eq config_path }
its('SPLUNK_HEC_TOKEN') { should eq splunk_hec_token }
its('SPLUNK_HEC_URL') { should eq splunk_hec_url }
its('SPLUNK_INGEST_URL') { should eq splunk_ingest_url }
its('SPLUNK_MEMORY_TOTAL_MIB') { should eq splunk_memory_total }
its('SPLUNK_REALM') { should eq splunk_realm }
its('SPLUNK_TRACE_URL') { should eq splunk_trace_url }
end
describe service('fluentdwinsvc') do
it { should_not be_enabled }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'spec_helper'

describe service('splunk-otel-collector') do
it { should be_enabled }
it { should be_running }
Expand All @@ -23,18 +21,18 @@
{ name: 'MY_CUSTOM_OPTION2', type: :string, data: 'value2' },
]

describe windows_registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do
it { should have_property_value('SIGNALFX_DOTNET_TRACER_HOME', :type_string, "#{ENV['ProgramFiles']}\\SignalFx\\.NET Tracing\\") }
describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do
its('SIGNALFX_DOTNET_TRACER_HOME') { should cmp "#{ENV['ProgramFiles']}\\SignalFx\\.NET Tracing\\" }
env_vars.each do |item|
it { should have_property_value(item[:name], item[:type], item[:data]) }
its(item[:name]) { should eq item[:data] }
end
end

iis_env = ''
iis_env = []
env_vars.each do |item|
iis_env += "#{item[:name]}=#{item[:data]}\n"
iis_env |= [ "#{item[:name]}=#{item[:data]}" ]
end

describe windows_registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC') do
it { should have_property_value('Environment', :type_multistring, iis_env.rstrip) }
describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC') do
it { should have_property_value('Environment', :multi_string, iis_env) }
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'spec_helper'

describe service('splunk-otel-collector') do
it { should be_enabled }
it { should be_running }
Expand All @@ -21,18 +19,18 @@
{ name: 'SIGNALFX_SERVICE_NAME', type: :string, data: '' },
]

describe windows_registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do
it { should have_property_value('SIGNALFX_DOTNET_TRACER_HOME', :type_string, "#{ENV['ProgramFiles']}\\SignalFx\\.NET Tracing\\") }
describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do
its('SIGNALFX_DOTNET_TRACER_HOME') { should cmp "#{ENV['ProgramFiles']}\\SignalFx\\.NET Tracing\\" }
env_vars.each do |item|
it { should_not have_property(item[:name]) }
end
end

iis_env = ''
iis_env = []
env_vars.each do |item|
iis_env += "#{item[:name]}=#{item[:data]}\n"
iis_env |= [ "#{item[:name]}=#{item[:data]}" ]
end

describe windows_registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC') do
it { should have_property_value('Environment', :type_multistring, iis_env.rstrip) }
describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC') do
it { should have_property_value('Environment', :multi_string, iis_env) }
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'spec_helper'

libsplunk_path = '/usr/lib/splunk-instrumentation/libsplunk.so'
java_agent_path = '/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar'
resource_attribute = 'deployment.environment=test'
Expand Down

This file was deleted.

8 changes: 0 additions & 8 deletions deployments/chef/test/windows/Dockerfile.windows-2019
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointMa

RUN choco install -y -f --no-progress chef-client --version=18.2.7

RUN $env:PATH += ';C:\opscode\chef\embedded\bin'; Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH

RUN gem install serverspec -v 2.42.0

COPY test/integration C:/test
COPY test/windows/spec_helper.rb C:/test/default/serverspec/spec_helper.rb
COPY test/windows/spec_helper.rb C:/test/custom_vars/serverspec/spec_helper.rb
COPY test/windows/spec_helper.rb C:/test/with_custom_dotnet_instrumentation/serverspec/spec_helper.rb
COPY test/windows/spec_helper.rb C:/test/with_default_dotnet_instrumentation/serverspec/spec_helper.rb

WORKDIR C:\\test
8 changes: 0 additions & 8 deletions deployments/chef/test/windows/Dockerfile.windows-2022
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointMa

RUN choco install -y -f --no-progress chef-client --version=18.2.7

RUN $env:PATH += ';C:\opscode\chef\embedded\bin'; Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH

RUN gem install serverspec -v 2.42.0

COPY test/integration C:/test
COPY test/windows/spec_helper.rb C:/test/default/serverspec/spec_helper.rb
COPY test/windows/spec_helper.rb C:/test/custom_vars/serverspec/spec_helper.rb
COPY test/windows/spec_helper.rb C:/test/with_custom_dotnet_instrumentation/serverspec/spec_helper.rb
COPY test/windows/spec_helper.rb C:/test/with_default_dotnet_instrumentation/serverspec/spec_helper.rb

WORKDIR C:\\test
3 changes: 0 additions & 3 deletions deployments/chef/test/windows/spec_helper.rb

This file was deleted.

0 comments on commit c709125

Please sign in to comment.