puppetlabs / puppetlabs/puppetlabs-stdlib

stdlib::deferrable_epp fails in spec test for windows nodes

Open
#1,455 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
349
Forks
573
Avg merge
3d 3h
Merged PRs (30d)
1

Description

Describe the Bug

When unit testing the following class:

class deferred_test {
  $response = { 'response_string' => Deferred('deferred_test::api')}

  $response_result = stdlib::deferrable_epp('deferred_test/api_response.epp', $response)

  echo { 'API debug':
    message => $response_result,
  }
}

The following test fails only for windows targets:

# frozen_string_literal: true

require 'spec_helper'

describe 'deferred_test' do
  on_supported_os.each do |os, os_facts|
    context "on #{os}" do
      let(:node) { "#{os_facts[:os]['name'].downcase}-#{os_facts[:os]['release']['major'].delete('.')}.corp.com" }
      let(:facts) { os_facts }

      it { is_expected.to compile.with_all_deps }
      it { is_expected.to contain_echo('API debug').with_message("the response was '{\"response\":\"i did a thing\"}'\n") }
    end
  end
end

It's worth mentioning that the manifest behaves as expected during an agent run.

Expected Behavior

Unit tests to work against windows nodes

Steps to Reproduce

Steps to reproduce the behavior:

  1. git clone git@github.com:garrettrowell/deferred_test.git
  2. cd deferred_test
  3. pdk test unit -v

Environment

  • stdlib version: 9.7.0
  • PDK version: 3.4.0
  • rspec-puppet version: 5.0.0
  • Test ran on Mac

Additional Context

I've put together a sample module to demonstrate this behavior: https://github.com/garrettrowell/deferred_test

I'm not sure if this is an issue with stdlib, rspec, or the file puppet function.

Output from pdk test unit -v

pdk (INFO): Using Ruby 3.2.5
pdk (INFO): Using Puppet 8.10.0
[✔] Preparing to run the unit tests.
/opt/puppetlabs/pdk/private/ruby/3.2.5/bin/ruby -I/Users/garrett.rowell/.pdk/cache/ruby/3.2.0/gems/rspec-core-3.13.5/lib:/Users/garrett.rowell/.pdk/cache/ruby/3.2.0/gems/rspec-support-3.13.4/lib /Users/garrett.rowell/.pdk/cache/ruby/3.2.0/gems/rspec-core-3.13.5/exe/rspec --pattern spec/\{aliases,classes,defines,functions,hosts,integration,plans,tasks,type_aliases,types,unit\}/\*\*/\*_spec.rb --format documentation
No facts were found in the FacterDB for Facter v4.10.0 on {"os.name"=>"CentOS", "os.release.full"=>"/^9/", "os.hardware"=>"x86_64"}, using v4.9.0 instead
No facts were found in the FacterDB for Facter v4.10.0 on {"os.name"=>"OracleLinux", "os.release.full"=>"/^7/", "os.hardware"=>"x86_64"}, using v4.2.2 instead
No facts were found in the FacterDB for Facter v4.10.0 on {"os.name"=>"Scientific", "os.release.full"=>"/^7/", "os.hardware"=>"x86_64"}, using v4.2.2 instead
No facts were found in the FacterDB for Facter v4.10.0 on {"os.name"=>"Rocky", "os.release.full"=>"/^8/", "os.hardware"=>"x86_64"}, using v4.9.0 instead
No facts were found in the FacterDB for Facter v4.10.0 on {"os.name"=>"AlmaLinux", "os.release.full"=>"/^8/", "os.hardware"=>"x86_64"}, using v4.9.0 instead
No facts were found in the FacterDB for Facter v4.10.0 on {"os.name"=>"Ubuntu", "os.release.full"=>"/^18\\.04/", "os.hardware"=>"x86_64"}, using v4.5.0 instead
No facts were found in the FacterDB for Facter v4.10.0 on {"os.name"=>"windows", "os.release.full"=>"\"2019\"", "os.hardware"=>"x86_64"}, using v4.7.0 instead
No facts were found in the FacterDB for Facter v4.10.0 on {"os.name"=>"windows", "os.release.full"=>"\"2022\"", "os.hardware"=>"x86_64"}, using v4.7.0 instead
No facts were found in the FacterDB for Facter v4.10.0 on {"os.name"=>"windows", "os.release.full"=>"\"10\"", "os.hardware"=>"x86_64"}, using v4.7.0 instead
No facts were found in the FacterDB for Facter v4.10.0 on {"os.name"=>"windows", "os.release.full"=>"\"11\"", "os.hardware"=>"x86_64"}, using v4.7.0 instead
Run options: exclude {:bolt=>true}

deferred_test
  on centos-9-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on oraclelinux-7-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on redhat-8-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on redhat-9-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on scientific-7-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on rocky-8-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on almalinux-8-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on debian-11-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on debian-12-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on ubuntu-18.04-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on ubuntu-20.04-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on ubuntu-22.04-x86_64
    is expected to compile into a catalogue without dependency cycles
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
  on windows-2019-x86_64
    is expected to compile into a catalogue without dependency cycles (FAILED - 1)
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n" (FAILED - 2)
  on windows-2022-x86_64
    is expected to compile into a catalogue without dependency cycles (FAILED - 3)
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n" (FAILED - 4)
  on windows-10-x86_64
    is expected to compile into a catalogue without dependency cycles (FAILED - 5)
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n" (FAILED - 6)
  on windows-11-x86_64
    is expected to compile into a catalogue without dependency cycles (FAILED - 7)
    is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n" (FAILED - 8)

Code coverage
  must cover at least 0% of resources


Coverage Report:

Total resources:   1
Touched resources: 1
Resource coverage: 100.00%

Failures:

  1) deferred_test on windows-2019-x86_64 is expected to compile into a catalogue without dependency cycles
     Failure/Error: it { is_expected.to compile.with_all_deps }
       error during compilation: Evaluation Error: Error while evaluating a Method call, Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp (file: /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/stdlib/functions/deferrable_epp.pp, line: 12, column: 32) on node windows-2019.corp.com
     # ./spec/classes/deferred_test_spec.rb:11:in `block (4 levels) in <top (required)>'

  2) deferred_test on windows-2019-x86_64 is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
     Failure/Error: it { is_expected.to contain_echo('API debug').with_message("the response was '{\"response\":\"i did a thing\"}'\n") }

     Puppet::PreformattedError:
       Evaluation Error: Error while evaluating a Method call, Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp (file: /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/stdlib/functions/deferrable_epp.pp, line: 12, column: 32) on node windows-2019.corp.com
     # /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
     # ./spec/classes/deferred_test_spec.rb:12:in `block (4 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # Puppet::ParseError:
     #   Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp
     #   /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'

  3) deferred_test on windows-2022-x86_64 is expected to compile into a catalogue without dependency cycles
     Failure/Error: it { is_expected.to compile.with_all_deps }
       error during compilation: Evaluation Error: Error while evaluating a Method call, Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp (file: /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/stdlib/functions/deferrable_epp.pp, line: 12, column: 32) on node windows-2022.corp.com
     # ./spec/classes/deferred_test_spec.rb:11:in `block (4 levels) in <top (required)>'

  4) deferred_test on windows-2022-x86_64 is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
     Failure/Error: it { is_expected.to contain_echo('API debug').with_message("the response was '{\"response\":\"i did a thing\"}'\n") }

     Puppet::PreformattedError:
       Evaluation Error: Error while evaluating a Method call, Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp (file: /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/stdlib/functions/deferrable_epp.pp, line: 12, column: 32) on node windows-2022.corp.com
     # /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
     # ./spec/classes/deferred_test_spec.rb:12:in `block (4 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # Puppet::ParseError:
     #   Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp
     #   /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'

  5) deferred_test on windows-10-x86_64 is expected to compile into a catalogue without dependency cycles
     Failure/Error: it { is_expected.to compile.with_all_deps }
       error during compilation: Evaluation Error: Error while evaluating a Method call, Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp (file: /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/stdlib/functions/deferrable_epp.pp, line: 12, column: 32) on node windows-10.corp.com
     # ./spec/classes/deferred_test_spec.rb:11:in `block (4 levels) in <top (required)>'

  6) deferred_test on windows-10-x86_64 is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
     Failure/Error: it { is_expected.to contain_echo('API debug').with_message("the response was '{\"response\":\"i did a thing\"}'\n") }

     Puppet::PreformattedError:
       Evaluation Error: Error while evaluating a Method call, Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp (file: /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/stdlib/functions/deferrable_epp.pp, line: 12, column: 32) on node windows-10.corp.com
     # /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
     # ./spec/classes/deferred_test_spec.rb:12:in `block (4 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # Puppet::ParseError:
     #   Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp
     #   /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'

  7) deferred_test on windows-11-x86_64 is expected to compile into a catalogue without dependency cycles
     Failure/Error: it { is_expected.to compile.with_all_deps }
       error during compilation: Evaluation Error: Error while evaluating a Method call, Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp (file: /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/stdlib/functions/deferrable_epp.pp, line: 12, column: 32) on node windows-11.corp.com
     # ./spec/classes/deferred_test_spec.rb:11:in `block (4 levels) in <top (required)>'

  8) deferred_test on windows-11-x86_64 is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
     Failure/Error: it { is_expected.to contain_echo('API debug').with_message("the response was '{\"response\":\"i did a thing\"}'\n") }

     Puppet::PreformattedError:
       Evaluation Error: Error while evaluating a Method call, Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp (file: /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/stdlib/functions/deferrable_epp.pp, line: 12, column: 32) on node windows-11.corp.com
     # /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
     # ./spec/classes/deferred_test_spec.rb:12:in `block (4 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # Puppet::ParseError:
     #   Could not find any files from /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp
     #   /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'

Finished in 4.95 seconds (files took 1 minute 3.07 seconds to load)
33 examples, 8 failures

Failed examples:

rspec './spec/classes/deferred_test_spec.rb[1:13:1]' # deferred_test on windows-2019-x86_64 is expected to compile into a catalogue without dependency cycles
rspec './spec/classes/deferred_test_spec.rb[1:13:2]' # deferred_test on windows-2019-x86_64 is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
rspec './spec/classes/deferred_test_spec.rb[1:14:1]' # deferred_test on windows-2022-x86_64 is expected to compile into a catalogue without dependency cycles
rspec './spec/classes/deferred_test_spec.rb[1:14:2]' # deferred_test on windows-2022-x86_64 is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
rspec './spec/classes/deferred_test_spec.rb[1:15:1]' # deferred_test on windows-10-x86_64 is expected to compile into a catalogue without dependency cycles
rspec './spec/classes/deferred_test_spec.rb[1:15:2]' # deferred_test on windows-10-x86_64 is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"
rspec './spec/classes/deferred_test_spec.rb[1:16:1]' # deferred_test on windows-11-x86_64 is expected to compile into a catalogue without dependency cycles
rspec './spec/classes/deferred_test_spec.rb[1:16:2]' # deferred_test on windows-11-x86_64 is expected to contain Echo[API debug] with message => "the response was '{\"response\":\"i did a thing\"}'\n"

/opt/puppetlabs/pdk/private/ruby/3.2.5/bin/ruby -I/Users/garrett.rowell/.pdk/cache/ruby/3.2.0/gems/rspec-core-3.13.5/lib:/Users/garrett.rowell/.pdk/cache/ruby/3.2.0/gems/rspec-support-3.13.4/lib /Users/garrett.rowell/.pdk/cache/ruby/3.2.0/gems/rspec-core-3.13.5/exe/rspec --pattern spec/\{aliases,classes,defines,functions,hosts,integration,plans,tasks,type_aliases,types,unit\}/\*\*/\*_spec.rb --format documentation failed

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with spec/classes/deferred_test_spec.rb and the failing call in spec/fixtures/modules/stdlib/functions/deferrable_epp.pp at line 12. Run pdk test unit -v and compare the Windows failures with the passing platforms; done means the Windows compile and Echo message examples pass without changing the expected agent-run behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.