Ask Your Question
0

pdk test unit failure

asked 2018-02-01 10:18:14 -0600

xaz gravatar image

updated 2018-02-02 09:54:02 -0600

DarylW gravatar image

Hello,

I want to create a puppet module that can manage various aspects of RabbitMQ, so I found a great puppet module: https://forge.puppet.com/puppet/rabbitmq. I also found I can do my development work using Puppet Development Kit (pdk). So I used it. I created my new module and new class: rabbitmq_server_profile. Per forge, I put the first part of managing server in my profile init.pp file:

class { 'rabbitmq':
  service_manage    => false,
  port              => '5672',
  delete_guest_user => true,
}

When I tried to run pdk test unit, I got below failures:

[✔] Preparing to run the unit tests.
[✖] Running unit tests.
  Evaluated 4 tests in 0.313573675 seconds: 4 failures, 0 pending.
[✔] Cleaning up after running unit tests.
failed: rspec: ./spec/classes/rabbitmq_server_profile_spec.rb:8: error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class rabbitmq::server at /home/xinhuan/rabbitmq_server_profile/spec/fixtures/modules/rabbitmq_server_profile/manifests/init.pp:10:3 on node rmqdev1.christianbook.com
  rabbitmq_server_profile on scientific-7-x86_64 should compile into a catalogue without dependency cycles
  Failure/Error:
        let(:facts) { os_facts }

        it { is_expected.to compile }
      end
    end

failed: rspec: ./spec/classes/rabbitmq_server_profile_spec.rb:8: error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class rabbitmq::server at /home/xinhuan/rabbitmq_server_profile/spec/fixtures/modules/rabbitmq_server_profile/manifests/init.pp:10:3 on node rmqdev1.christianbook.com
  rabbitmq_server_profile on redhat-7-x86_64 should compile into a catalogue without dependency cycles
  Failure/Error:
        let(:facts) { os_facts }

        it { is_expected.to compile }
      end
    end

failed: rspec: ./spec/classes/rabbitmq_server_profile_spec.rb:8: error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class rabbitmq::server at /home/xinhuan/rabbitmq_server_profile/spec/fixtures/modules/rabbitmq_server_profile/manifests/init.pp:10:3 on node rmqdev1.christianbook.com
  rabbitmq_server_profile on centos-7-x86_64 should compile into a catalogue without dependency cycles
  Failure/Error:
        let(:facts) { os_facts }

        it { is_expected.to compile }
      end
    end

failed: rspec: ./spec/classes/rabbitmq_server_profile_spec.rb:8: error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class rabbitmq::server at /home/xinhuan/rabbitmq_server_profile/spec/fixtures/modules/rabbitmq_server_profile/manifests/init.pp:10:3 on node rmqdev1.christianbook.com
  rabbitmq_server_profile on oraclelinux-7-x86_64 should compile into a catalogue without dependency cycles
  Failure/Error:
        let(:facts) { os_facts }

        it { is_expected.to compile }
      end
    end

Is it something I should worry about? When calling unit test, does it try to do similar thing like calling 'include rabbitmq_server_profile' ? How do I accomplish that effect with unit test if it is not?

Thank you,

  • xinhuan
edit retag flag offensive close merge delete

Comments

1

Have you added the rabbitmq module to your .fixtures.yml file? Unless you tell it that it is a dependency, the test runner won't be able to fetch it and use it for evaluating your tests

DarylW gravatar imageDarylW ( 2018-02-02 09:55:29 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2018-02-02 12:21:20 -0600

bmjen gravatar image

Hi xinhuan,

To test with external dependencies, like rabbitmq, you will need to add the dependency and its dependencies to your .fixtures.yml. The PDK should have created a template .fixture.yml in your module root. For your particular situation, the .fixtures.yml should look like this.

# This file can be used to install module depdencies for unit testing
# See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details
---
fixtures:
  forge_modules:
    stdlib:   "puppetlabs/stdlib"
    rabbitmq: "puppet/rabbitmq"
    archive:  "puppet/archive"

Also, if your module is depending on the puppet-rabbitmq module to work, don't forget to add that as a dependency in your metadata.json.

Thanks!

Bryan Jen

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-02-01 10:18:14 -0600

Seen: 204 times

Last updated: Feb 02