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

    David Sandilands

    01/27/2025, 1:35 PM
    We did a role and profile pattern where you could manage classes via hiera to make it slightly less rigid for some customers
    b
    r
    • 3
    • 7
  • r

    ralfbosz

    01/27/2025, 2:41 PM
    Anybody here using beaker with Ubuntu-24 ? The 'run_puppet_install_helper' installs the puppet just fine, but then gives me this error: puppet agent -t Last 10 lines of output were: bash: line 1: puppet: command not found Seems a PATH issue, but when I login manually I can't reproduce it, the $PATH has /opt/puppetlabs/bin
    b
    • 2
    • 10
  • r

    ralfbosz

    01/27/2025, 2:42 PM
    Same beaker with Ubuntu-22 runs just fine, somethings changed in Ubuntu-24 seems
  • t

    TheMeier

    01/28/2025, 8:19 AM
    I have an issue to mock a fact in testing. I am having some code like this in a spec test:
    Copy code
    on_supported_os.each do |os, os_facts|
          context "on #{os}" do
            let(:facts) do
              os_facts.merge(networking: { fqdn: 'my.domain.foo' })
            end
    but
    $facts{'networking']['fqdn']
    always has the value defined in
    spec/default_facts.yml
    b
    y
    h
    • 4
    • 35
  • j

    Joel Wilson

    02/25/2025, 5:38 PM
    Any beaker geniuses in here?
  • b

    bastelfreak

    02/25/2025, 5:43 PM
    "genius" is a bit much
  • b

    bastelfreak

    02/25/2025, 5:43 PM
    but #C0W1Y5VL0 maintains beaker
  • j

    Joel Wilson

    02/25/2025, 5:43 PM
    Trying to add a couple of docker settings like a different network and a bind mount, but can't figure out how to get that into my
    spec_helper_acceptance.rb
  • j

    Joel Wilson

    02/25/2025, 5:43 PM
    So, I should go to that channel?
  • b

    bastelfreak

    02/25/2025, 5:43 PM
    it's worth trying 🙂
  • j

    Joel Wilson

    02/25/2025, 5:43 PM
    Thx.
  • t

    TheMeier

    02/28/2025, 1:35 PM
    in a standard unit test can I access the parameters of the class/defined resource that is currently evaluated?
    y
    h
    • 3
    • 4
  • e

    Ed Rude

    03/11/2025, 10:47 AM
    It’s hard enough to keep modules all up to date without folding in your own changes :)
    👍 1
    b
    • 2
    • 1
  • b

    Brian Schonecker

    04/28/2025, 12:36 PM
    I'm dong what couldn't be a more simple test on a class module that does concat. It fails with:
    error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, wrong number of arguments (given 3, expected 1..2)
    The class module (if you can call it that) couldn't be more simple:
    --class manhattan::a {
    concat { '/bin/foo':
    owner => 'root',
    group => 'root',
    mode  => '0755',
    }
    }
    bundle references me to:
    concat/manifests/init.pp, line: 107, column: 27)
    but for the life of me I can't figure out what's going on. The class module passes all other tests. My .fixtures.yml file references:
    concat:
    repo: "<https://github.com/puppetlabs/puppetlabs-concat.git>"
    ref: "v9.0.2"
    The spec file is:
    require 'spec_helper'
    describe 'manhattan::a' do
    it { <http://is_expected.to|is_expected.to> compile }
    end
    It doesn't get much more simple than that. Can anyone shed light on what I might be doing wrong?
    b
    • 2
    • 40
  • b

    bastelfreak

    04/28/2025, 12:38 PM
    IMO the .fixtures.yml should reference the latest branch, not tag
    r
    • 2
    • 1
  • 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