git clone git@github.com:DataDog/puppet-datadog-agent.git
cd puppet-datadog-agent
First, to install the Ruby dependencies run:
gem install bundler:1.17.3
bundle install --path .bundle
Afterwards, on the first run of the tests, further dependencies will be installed. The tests can be run with:
bundle exec rake test
The test
task has a few different steps, which you can run separately:
rake lint # Check Puppet manifests with puppet-lint / Run puppet-lint
rake spec # Run spec tests in a clean fixtures directory
rake syntax # Syntax check Puppet manifests and templates
rake syntax:manifests # Syntax check Puppet manifests
rake syntax:templates # Syntax check Puppet templates
Lastly, you should install the pre-commit hook:
pip install pre-commit
pre-commit install
To test the roles provided by this project, you can follow the instructions in the manual tests readme.md.
This project uses Kitchen as its integration tests engine. To really verify integration tests, you should have Vagrant installed on your machine as it is used as a driver-engine.
Kitchen allows you to test specific recipes described in kitchen.yml. For now, there is only a basic one on Ubuntu, but that should be enough to develop others or to add features in TDD.
To list available targets, you can use the list
command:
bundle exec kitchen list
To test a specific target, you can run:
bundle exec kitchen test <target>
So for example, if you want to test the Agent installation, you can run:
bundle exec kitchen test dd-agent-ubuntu-1604
More information about kitchen on its Getting Started.
To develop fixes or features, work on the platform and version of your choice, setting the machine up with the create
command and applying the recipe with the converge
command. If you want to explore the machine and try different things, you can also log into the machine with the login
command.
# Create the relevant vagrant virtual machine
bundle exec kitchen create dd-agent-ubuntu1604
# Converge to test your recipe
bundle exec kitchen converge dd-agent-ubuntu1604
# Login to your machine to check stuff
bundle exec kitchen login dd-agent-ubuntu1604
# Verify the integration tests for your machine
bundle exec kitchen verify dd-agent-ubuntu1604
# Clean your machine
bundle exec kitchen destroy dd-agent-ubuntu1604
It is advised that you work in TDD and that you write tests before making changes so that developing your feature or fix is just making tests pass.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request