https://www.puppet.com/community logo
Join Slack
Powered by
# testing
  • b

    bastelfreak

    04/28/2025, 12:38 PM
    can you show the full error message?
  • y

    Yury Bushmelev

    05/08/2025, 5:40 AM
    JFYI, I spent some time asking qwen.ai about writing unit tests for facts, and it was quite reasonable. At least it was able to answer my question how to mock a
    kernel
    fact value to make my Linux-confined fact unit test to work on MacOS.
  • y

    Yury Bushmelev

    05/08/2025, 5:42 AM
    It even suggested me to use
    Facter.clear
    in
    before :each
    hook, which looks legit but I should recheck the sources/documentation regarding this šŸ¤”
  • y

    Yury Bushmelev

    05/08/2025, 5:44 AM
    ah, when asked about details, it told me that was for Facter 2.x.. so now it’s deprecated šŸ˜‚
  • w

    Wouter Mellema

    05/21/2025, 9:23 AM
    Hi! I'm trying to get the testing suite for
    puppet-nvm
    running with litmus and docker instead of beaker. After quite a few hours of trial and error, the tests finally run. However, i'm hit with the following error across all tests:
    Copy code
    nvm class running puppet code Command ". /etc/profile.d/nvm.sh && nvm ls" stdout 
          On host `localhost:52343'
          Failure/Error: its(:stdout) { should match /0.10.36/ }
          ArgumentError:
            wrong number of arguments (given 1, expected 2)
  • w

    Wouter Mellema

    05/21/2025, 9:24 AM
    What am I missing, the following code should be perfectly valid
    Copy code
    describe command('. /etc/profile.d/nvm.sh && nvm ls') do
          its(:exit_status) { should eq 0 }
          its(:stdout) { should match /0.10.36/ }
        end
  • k

    kenyon

    05/21/2025, 6:25 PM
    why use litmus? that is not maintained afaik
  • w

    Wouter Mellema

    05/23/2025, 1:57 PM
    Last commit was last week, so seems to be maintained still. Actual testing framework aside, the
    describe command
    syntax and the
    its
    syntax SHOULD be valid serverspec as described at the litmus docs. It works for things like
    describe file
    , but not for
    command
    . That's the issue I want to fix :)
  • y

    Yury Bushmelev

    05/23/2025, 2:21 PM
    Try with
    command('source /etc/profile.d/nvm.sh && nvm ls')
    .. I saw some problems with
    .
    few times in other context.. wouldn’t be surprised if it causes some issues
  • y

    Yury Bushmelev

    05/23/2025, 2:22 PM
    Also I don’t remember, but maybe
    command()
    doesn’t use shell
  • w

    Wouter Mellema

    05/23/2025, 4:55 PM
    @Yury Bushmelev With the use of
    source
    , nothing changes unfortunately. It seems that, somehow, the syntax of the test itself is wrong. There are some tests specified that run as a user, with a specific shell, but those also fail with the same error. Example included underneath
    describe command('su - foo -c "source /home/foo/.nvm/nvm.sh && nvm --version" -s /bin/bash') do
  • w

    Wouter Mellema

    05/23/2025, 4:58 PM
    Even with a simple command like
    ls /
    , it breaks the same way
    Copy code
    5) nvm::npm define install local package Command "ls /" exit_status 
         On host `localhost:52507'
         Failure/Error: its(:exit_status) { <http://is_expected.to|is_expected.to> eq 0 }
         ArgumentError:
           wrong number of arguments (given 1, expected 2)
           
         # /home/wmellema/.pdk/cache/ruby/3.2.0/gems/bolt-4.0.0/lib/bolt_spec/run.rb:52:in `run_command'
         # /home/wmellema/.pdk/cache/ruby/3.2.0/gems/serverspec-2.43.0/lib/serverspec/type/command.rb:28:in `command_result'
         # /home/wmellema/.pdk/cache/ruby/3.2.0/gems/serverspec-2.43.0/lib/serverspec/type/command.rb:18:in `exit_status'
         # ./spec/acceptance/02_nvm_npm_spec.rb:42:in `block (4 levels) in <top (required)>'
    y
    • 2
    • 5
  • j

    Jacob McGee

    06/03/2025, 5:06 PM
    @Jacob McGee has left the channel
  • y

    yachub

    06/06/2025, 7:41 PM
    Is possible to stub sensitive params when testing in a module? Iv'e tried something like
    let(:params) { {'password' =>sensitive('secret') } }
    as described at https://www.rubydoc.info/gems/rspec-puppet, but it seems like
    pdk test unit
    is still attempting to open eyaml keys, which don't exist in CI. Related, I know onceover has the ability to use a separate
    hiera.yaml
    file where the suggestion is to remove the eyaml config options, but not sure if pdk/rspec-puppet supports anything like that.
    y
    t
    • 3
    • 5
  • j

    jesse

    06/13/2025, 5:10 AM
    What's the newest release of PDK that I can use without having to agree to the Puppet Core License? In other words, what was the final open source version of PDK released? (Where the source is publicly available at the time of package build and release, and where I'm allowed to delve into the source code included in the package?)
    b
    r
    • 3
    • 23
  • g

    Garrett Rowell

    07/15/2025, 7:41 PM
    hey all, I have a curious situation where my simple
    it { <http://is_expected.to|is_expected.to> compile.with_all_deps }
    test is failing only for windows nodes, rhel/debian/etc work just fine. of note i’m running the tests on a mac. In my manifest I have the following:
    Copy code
    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,
      }
    }
    I’ve narrowed it down to https://github.com/puppetlabs/puppetlabs-stdlib/blob/main/functions/deferrable_epp.pp#L12 specifically the
    .file
    call in stdlib::deferrable_epp. The error I’m getting is:
    Copy code
    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 <http://windows-2022.corp.com|windows-2022.corp.com>
    The code in question works as expected when ran against a windows node, just trying to get the tests working as well
  • b

    bastelfreak

    07/15/2025, 7:42 PM
    can you share you test aswell?
  • g

    Garrett Rowell

    07/15/2025, 7:43 PM
    sure thing its just the standard one the pdk spits out:
    Copy code
    # frozen_string_literal: true
    
    require 'spec_helper'
    
    describe 'deferred_test' do
      on_supported_os.each do |os, os_facts|
        context "on #{os}" do
          let(:facts) { os_facts }
          it { <http://is_expected.to|is_expected.to> compile.with_all_deps }
        end
      end
    end
  • b

    bastelfreak

    07/15/2025, 8:02 PM
    is
    /Users/garrett.rowell/workspace/puppet/deferred_test/spec/fixtures/modules/deferred_test/templates/api_response.epp
    the correct path?
  • g

    Garrett Rowell

    07/15/2025, 8:05 PM
    should be. against for example
    redhat-7-x86_64
    it seems to find the template just fine
  • b

    bastelfreak

    07/15/2025, 8:06 PM
    mhm
  • b

    bastelfreak

    07/15/2025, 8:06 PM
    raise a github issue for stdlib maybe
  • g

    Garrett Rowell

    07/15/2025, 8:08 PM
    sure thing. I didn’t know if it was more a stdlib issue or an rspec issue with how it translates paths when the tests are ran on a non windows node.
  • b

    bastelfreak

    07/15/2025, 8:09 PM
    I'm not sure to be honest. maybe it does something weird when translating windows vs unix file paths
  • g

    Garrett Rowell

    07/15/2025, 8:13 PM
    that was my initial thinking. though it could even be something with the
    file
    function. since if i change:
    Copy code
    Deferred(
          'inline_epp',
          [find_template($template).file, $variables],
        )
    to:
    Copy code
    Deferred(
          'inline_epp',
          [find_template($template), $variables],
        )
    my test spits out the correct path, it just won’t render the template which is to be expected
  • g

    Garrett Rowell

    07/15/2025, 9:07 PM
    anyways i’ve opened the following issue for stdlib: https://github.com/puppetlabs/puppetlabs-stdlib/issues/1455
  • c

    CVQuesty

    08/04/2025, 3:33 PM
    @CVQuesty has left the channel
  • n

    natemccurdy

    08/04/2025, 9:55 PM
    @natemccurdy has left the channel
  • k

    Keith Ward

    08/12/2025, 6:37 PM
    @Keith Ward has left the channel
  • t

    Tino Müller

    09/08/2025, 7:40 AM
    @Tino Müller has left the channel