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

    bastelfreak

    11/14/2025, 6:16 PM
    This has probably more to do with your rspec-puppet version and how you run the tests
  • j

    jms1

    11/14/2025, 6:17 PM
    i'm using what comes with PDK 3.5.1, running
    pdk test unit -v --tests=spec/classes/blah_spec.rb
  • j

    jms1

    11/14/2025, 6:18 PM
    Copy code
    $ pdk bundle exec rspec --version
    pdk (INFO): Using Ruby 3.2.8
    pdk (INFO): Using Puppet 8.10.0
    RSpec 3.13
      - rspec-core 3.13.5
      - rspec-expectations 3.13.5
      - rspec-mocks 3.13.5
      - rspec-support 3.13.6
  • b

    bastelfreak

    11/14/2025, 6:26 PM
    https://github.com/puppetlabs/rspec-puppet/blob/main/lib/rspec-puppet/support.rb#L291-L315 should be this logic
  • j

    jms1

    11/14/2025, 6:32 PM
    so how does one override the values of
    servername
    ,
    serverip
    , and
    serverversion
    ?
  • j

    jms1

    11/14/2025, 6:32 PM
    back in PE2018 i was able to do this, but it's not having any effect now:
    Copy code
    let(:node_params) do
        {
          'serverversion' => '1.2.3' ,
          'servername'    => '<http://unit-test.domain.xyz|unit-test.domain.xyz>' ,
        }
      end
  • b

    bastelfreak

    11/14/2025, 6:34 PM
    I spend so much time to unify it to and now you want to change it 😞
  • b

    bastelfreak

    11/14/2025, 6:35 PM
    I think it always uses the values from the facts you set
  • b

    bastelfreak

    11/14/2025, 6:36 PM
    networking.fqdn and networking.ip
  • j

    jms1

    11/14/2025, 6:36 PM
    wouldn't that set the hostname and IP of the machine being configured, rather than the machine where the compiler is running?
  • b

    bastelfreak

    11/14/2025, 6:36 PM
    both
  • j

    jms1

    11/14/2025, 6:37 PM
    so then how does one test whether the catalog is being built for a machine OTHER THAN the puppet server itself?
  • b

    bastelfreak

    11/14/2025, 6:38 PM
    I'm not sure if I understand the question
  • j

    jms1

    11/14/2025, 6:39 PM
    FWIW a lot of the files i generate include a "This file was generated by Puppet on `pe-server.example.com`" header, that needs to include the name of the puppet server, not the name of the machine whose catalog is being compiled.
  • b

    bastelfreak

    11/14/2025, 6:40 PM
    this is a bad approach as soon as you have multiple compilers. and the report already knows who compiled the catalog
  • j

    jms1

    11/14/2025, 6:40 PM
    in the real world, the puppet server is almost always NOT the same as the name of the machine whose catalog is being built. i can use
    let(:node) { '<http://target.example.com|target.example.com>' }
    to set the name of the machine whose catalog is being built, i need to be able to set the name of the puppet server which is building the catalog.
  • b

    bastelfreak

    11/14/2025, 6:41 PM
    I'm not sure if there's an option for that right now
  • b

    bastelfreak

    11/14/2025, 6:41 PM
    but I'm also cooking dinner and don't work for Perforce
  • j

    jms1

    11/14/2025, 6:41 PM
    there was in PE2018
  • b

    bastelfreak

    11/14/2025, 6:41 PM
    I don't think so
  • b

    bastelfreak

    11/14/2025, 6:41 PM
    There was an option in older rspec-puppet versions
  • b

    bastelfreak

    11/14/2025, 6:41 PM
    your PE version has nothing to do with the unit tests / testsetup
  • j

    jms1

    11/14/2025, 6:42 PM
    like ... the older rspec-puppet version that was part of PDK back in the PE2018 days maybe?
  • b

    bastelfreak

    11/14/2025, 6:42 PM
    yes. We removed that a long long time ago
  • b

    bastelfreak

    11/14/2025, 6:43 PM
    mhm, node_params is still a thing
  • j

    jms1

    11/14/2025, 6:44 PM
    okay, well ... i'm just going to say it, whoever made the decision to remove it, made a bad decision.
  • b

    bastelfreak

    11/14/2025, 6:44 PM
    I say this just exposes a flaw in your code 😄
  • b

    bastelfreak

    11/14/2025, 6:44 PM
    https://github.com/puppetlabs/rspec-puppet/blob/main/lib/rspec-puppet.rb#L43 is still around, but I don't think you can set the server facts with it
  • b

    bastelfreak

    11/14/2025, 6:54 PM
    https://github.com/puppetlabs/rspec-puppet/pull/73 not sure why it was removed it. not sure if there was a config option in puppet < 7 to configure it within puppet
  • j

    jms1

    11/19/2025, 10:45 PM
    question ... running
    pdk validate
    returns this error
    Copy code
    pdk (WARNING): puppet-lint: class parameter with String type defaults to empty string
    on this line in a class's parameter list
    Copy code
    String $xyz = '' ,
    ... removing the
    = ''
    makes
    puppet-lint
    happy, but it changes the parameter from "optional with a default value" (which is what i need in this case) to "required" (which is NOT what i need)
    b
    k
    +2
    • 5
    • 11