Skip to content

Commit

Permalink
Add vagrant-based testing environment (DataDog#462)
Browse files Browse the repository at this point in the history
* Add vagrant-based testing environment

 with '#' will be ignored, and an empty message aborts the commit.

* Update gitignore

* Use versions in Puppetfile

* Fix some paths in the readme

* improve readme
  • Loading branch information
remicalixte authored and truthbk committed Nov 4, 2018
1 parent 812494f commit c3af4d7
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ Gemfile.lock

.rbenv-gemsets
.ruby-version

tests/.vagrant
38 changes: 38 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Test setup

This is an example setup, based on vagrant + virtualbox, that allows to easily run puppet commands to test the module.

# Requirements

- vagrant > 2.0.0
- virtualbox > 5.1.28

# Setup

in `puppet-datadog-agent/tests`:

- provision VM: `vagrant up`
- connect to the VM to check the configuration: `vagrant ssh`
- destroy VM when needed: `vagrant destroy -f`

## Module installation

- The default `Puppetfile` installs the latest released version of the module from Puppetforge.
- To use your development branch instead edit the Puppetfile et replace the `datadog-datadog_agent` with:
```
mod 'datadog-datadog_agent',
:git => 'https://github.com/DataDog/puppet-datadog-agent',
:branch => '<my_branch>'
```

- We can also build the module locally using the `puppet build` or `pdk build` command, upload the archive to the VM and install it with `sudo /opt/puppetlabs/bin/puppet module install datadog-datadog_agent-x.y.z.tar.gz --target-dir /home/vagrant/puppet/modules`


## Manifest

The default manifest is `tests/environment/manifests/site.pp` and simply run the module with the default options.
We can edit the manifest and run `vagrant up --provision` to upload the new version to the VM.

# Test

In the VM, run `sudo /opt/puppetlabs/bin/puppet apply --modulepath=./modules ./manifests/site.pp` in `/home/vagrant/puppet` to apply to manifest on the VM.
10 changes: 10 additions & 0 deletions tests/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Vagrant.configure("2") do |config|
config.vm.box = "puppetlabs/ubuntu-16.04-64-puppet"
config.vm.box_version = "1.0.0"
config.vm.provision "file", source: "./environment", destination: "$HOME/puppet"
config.vm.provision "shell", inline: <<-SHELL
/opt/puppetlabs/puppet/bin/gem install r10k -v 2.6.4
cd /home/vagrant/puppet
sudo /opt/puppetlabs/puppet/bin/r10k puppetfile install
SHELL
end
6 changes: 6 additions & 0 deletions tests/environment/Puppetfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mod 'datadog-datadog_agent'
mod 'puppetlabs-apt', '2.4.0'
mod 'puppetlabs-concat', '4.0.0'
mod 'puppetlabs-puppetserver_gem', '1.0.0'
mod 'puppetlabs-ruby', '1.0.0'
mod 'puppetlabs-stdlib', '4.24.0'
5 changes: 5 additions & 0 deletions tests/environment/manifests/site.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node "localhost" {
class { "datadog_agent":
api_key => "somenonnullapikeythats32charlong",
}
}

0 comments on commit c3af4d7

Please sign in to comment.