diff --git a/.github/workflows/chef-test.yml b/.github/workflows/chef-test.yml index adead1705a..89c13de282 100644 --- a/.github/workflows/chef-test.yml +++ b/.github/workflows/chef-test.yml @@ -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: | diff --git a/deployments/chef/kitchen.windows.yml b/deployments/chef/kitchen.windows.yml index c5aac55d6f..a1c95d267f 100644 --- a/deployments/chef/kitchen.windows.yml +++ b/deployments/chef/kitchen.windows.yml @@ -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 @@ -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: @@ -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: @@ -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: @@ -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 diff --git a/deployments/chef/kitchen.yml b/deployments/chef/kitchen.yml index 343efc7104..2be53600ab 100644 --- a/deployments/chef/kitchen.yml +++ b/deployments/chef/kitchen.yml @@ -15,7 +15,7 @@ provisioner: multiple_converge: 2 verifier: - root_path: /opt/verifier + name: inspec platforms: - name: amazonlinux-2 diff --git a/deployments/chef/test/integration/custom_vars/serverspec/custom_vars_spec.rb b/deployments/chef/test/integration/custom_vars/inspec/custom_vars_spec.rb similarity index 63% rename from deployments/chef/test/integration/custom_vars/serverspec/custom_vars_spec.rb rename to deployments/chef/test/integration/custom_vars/inspec/custom_vars_spec.rb index fb594c3233..40f2cf64eb 100644 --- a/deployments/chef/test/integration/custom_vars/serverspec/custom_vars_spec.rb +++ b/deployments/chef/test/integration/custom_vars/inspec/custom_vars_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - splunk_access_token = 'testing123' splunk_realm = 'test' splunk_api_url = 'https://fake-splunk-api.com' @@ -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 } diff --git a/deployments/chef/test/integration/custom_vars/serverspec/spec_helper.rb b/deployments/chef/test/integration/custom_vars/serverspec/spec_helper.rb deleted file mode 100644 index 590c2fa95f..0000000000 --- a/deployments/chef/test/integration/custom_vars/serverspec/spec_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'serverspec' -set :backend, :exec diff --git a/deployments/chef/test/integration/default/serverspec/default_spec.rb b/deployments/chef/test/integration/default/inspec/default_spec.rb similarity index 62% rename from deployments/chef/test/integration/default/serverspec/default_spec.rb rename to deployments/chef/test/integration/default/inspec/default_spec.rb index c3c9705b4b..36712d719b 100644 --- a/deployments/chef/test/integration/default/serverspec/default_spec.rb +++ b/deployments/chef/test/integration/default/inspec/default_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - splunk_access_token = 'testing123' splunk_realm = 'test' splunk_api_url = "https://api.#{splunk_realm}.signalfx.com" @@ -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 } diff --git a/deployments/chef/test/integration/default/serverspec/spec_helper.rb b/deployments/chef/test/integration/default/serverspec/spec_helper.rb deleted file mode 100644 index 590c2fa95f..0000000000 --- a/deployments/chef/test/integration/default/serverspec/spec_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'serverspec' -set :backend, :exec diff --git a/deployments/chef/test/integration/with_custom_dotnet_instrumentation/serverspec/with_custom_dotnet_instrumentation_spec.rb b/deployments/chef/test/integration/with_custom_dotnet_instrumentation/inspec/with_custom_dotnet_instrumentation_spec.rb similarity index 63% rename from deployments/chef/test/integration/with_custom_dotnet_instrumentation/serverspec/with_custom_dotnet_instrumentation_spec.rb rename to deployments/chef/test/integration/with_custom_dotnet_instrumentation/inspec/with_custom_dotnet_instrumentation_spec.rb index f30e5ddc8b..78623b1c3d 100644 --- a/deployments/chef/test/integration/with_custom_dotnet_instrumentation/serverspec/with_custom_dotnet_instrumentation_spec.rb +++ b/deployments/chef/test/integration/with_custom_dotnet_instrumentation/inspec/with_custom_dotnet_instrumentation_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - describe service('splunk-otel-collector') do it { should be_enabled } it { should be_running } @@ -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 diff --git a/deployments/chef/test/integration/with_default_dotnet_instrumentation/serverspec/with_default_dotnet_instrumentation_spec.rb b/deployments/chef/test/integration/with_default_dotnet_instrumentation/inspec/with_default_dotnet_instrumentation_spec.rb similarity index 64% rename from deployments/chef/test/integration/with_default_dotnet_instrumentation/serverspec/with_default_dotnet_instrumentation_spec.rb rename to deployments/chef/test/integration/with_default_dotnet_instrumentation/inspec/with_default_dotnet_instrumentation_spec.rb index f7b8a80b14..f397907bc0 100644 --- a/deployments/chef/test/integration/with_default_dotnet_instrumentation/serverspec/with_default_dotnet_instrumentation_spec.rb +++ b/deployments/chef/test/integration/with_default_dotnet_instrumentation/inspec/with_default_dotnet_instrumentation_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - describe service('splunk-otel-collector') do it { should be_enabled } it { should be_running } @@ -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 diff --git a/deployments/chef/test/integration/with_instrumentation/serverspec/with_instrumentation_spec.rb b/deployments/chef/test/integration/with_instrumentation/inspec/with_instrumentation_spec.rb similarity index 98% rename from deployments/chef/test/integration/with_instrumentation/serverspec/with_instrumentation_spec.rb rename to deployments/chef/test/integration/with_instrumentation/inspec/with_instrumentation_spec.rb index 911c97e932..5201022aff 100644 --- a/deployments/chef/test/integration/with_instrumentation/serverspec/with_instrumentation_spec.rb +++ b/deployments/chef/test/integration/with_instrumentation/inspec/with_instrumentation_spec.rb @@ -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' diff --git a/deployments/chef/test/integration/with_instrumentation/serverspec/spec_helper.rb b/deployments/chef/test/integration/with_instrumentation/serverspec/spec_helper.rb deleted file mode 100644 index 590c2fa95f..0000000000 --- a/deployments/chef/test/integration/with_instrumentation/serverspec/spec_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'serverspec' -set :backend, :exec diff --git a/deployments/chef/test/windows/Dockerfile.windows-2019 b/deployments/chef/test/windows/Dockerfile.windows-2019 index 151254456e..42de8eab2a 100644 --- a/deployments/chef/test/windows/Dockerfile.windows-2019 +++ b/deployments/chef/test/windows/Dockerfile.windows-2019 @@ -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 diff --git a/deployments/chef/test/windows/Dockerfile.windows-2022 b/deployments/chef/test/windows/Dockerfile.windows-2022 index 65f478217a..88d6b6f2e0 100644 --- a/deployments/chef/test/windows/Dockerfile.windows-2022 +++ b/deployments/chef/test/windows/Dockerfile.windows-2022 @@ -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 diff --git a/deployments/chef/test/windows/spec_helper.rb b/deployments/chef/test/windows/spec_helper.rb deleted file mode 100644 index d9a92cd21f..0000000000 --- a/deployments/chef/test/windows/spec_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'serverspec' -set :backend, :cmd -set :os, { family: 'windows' }