Add RSpec tests that pass unitfile/tarball URLs
[integration/packaging/puppet-opendaylight.git] / CONTRIBUTING.md
1 If you follow these contributing guidelines your patch
2 will likely make it into a release a little quicker.
3
4
5 ## Contributing
6
7 1. Fork the repo.
8
9 2. Run the tests. We only take pull requests with passing tests, and
10    it's great to know that you have a clean slate.
11
12 3. Add a test for your change. Only refactoring and documentation
13    changes require no new tests. If you are adding functionality
14    or fixing a bug, please add a test.
15
16 4. Make the test pass.
17
18 5. Push to your fork and submit a pull request.
19
20
21 ## Dependencies
22
23 The testing and development tools have a bunch of dependencies,
24 all managed by [Bundler](http://bundler.io/) according to the
25 [Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions).
26
27 By default the tests use a baseline version of Puppet.
28
29 If you have Ruby 2.x or want a specific version of Puppet,
30 you must set an environment variable such as:
31
32     export PUPPET_VERSION="~> 3.2.0"
33
34 Install the dependencies like so...
35
36     bundle install
37
38 ## Syntax and style
39
40 The test suite will run [Puppet Lint](http://puppet-lint.com/) and
41 [Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to
42 check various syntax and style things. You can run these locally with:
43
44     bundle exec rake lint
45     bundle exec rake syntax
46
47 ## Running the unit tests
48
49 The unit test suite covers most of the code. As mentioned above, please
50 add tests if you're adding new functionality. Running the test suite is done
51 with:
52
53     bundle exec rake spec
54
55 Note also you can run the syntax, style and unit tests in one go with:
56
57     bundle exec rake test
58
59 ### Automatically run the tests
60
61 During development of your puppet module you might want to run your unit
62 tests a couple of times. You can use the following command to automate
63 running the unit tests on every change made in the manifests folder.
64
65     bundle exec guard
66
67 ## Integration tests
68
69 The unit tests just check the code runs, not that it does exactly what
70 we want on a real machine. For that we're using
71 [Beaker](https://github.com/puppetlabs/beaker).
72
73 Beaker fires up a new virtual machine (using Vagrant) and runs a series of
74 simple tests against it after applying the module. You can run our Beaker
75 tests with:
76
77     bundle exec rake acceptance
78
79 This will use the host described in `spec/acceptance/nodeset/default.yml`
80 by default. To run against another host, set the `RS_SET` environment
81 variable to the name of a host described by a `.yml` file in the
82 `nodeset` directory. For example, to run against Fedora 20:
83
84     RS_SET=fedora-20-x64 bundle exec rake acceptance
85
86 If you don't want to have to recreate the virtual machine every time you
87 can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will
88 at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile
89 for the created virtual machines will be in `.vagrant/beaker_vagrant_files`.