mirror of
https://opendev.org/openstack/puppet-openstack-guide.git
synced 2026-01-16 23:02:01 +00:00
Migrate unit testing wiki
This commit aims to move all wikis about tests [1][2][3] [1] https://wiki.openstack.org/wiki/Puppet/Unit_testing [2] https://wiki.openstack.org/wiki/Puppet/Functional_testing [3] https://wiki.openstack.org/wiki/TripleOPuppetCI Change-Id: I23334e07c7d51825aa9cc0554d7436fcc181638d
This commit is contained in:
parent
04c15c1c13
commit
053deba1cd
4 changed files with 216 additions and 0 deletions
103
doc/source/ci.rst
Normal file
103
doc/source/ci.rst
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
######################
|
||||
Continuous Integration
|
||||
######################
|
||||
|
||||
|
||||
This is a list of the CI jobs that are running against most of Puppet
|
||||
OpenStack modules: The code that configure Jenkins jobs is hosted by
|
||||
`project-config
|
||||
<http://git.openstack.org/cgit/openstack-infra/project-config/tree/jenkins
|
||||
/jobs/puppet-module-jobs.yaml>`__.
|
||||
|
||||
.. list-table:: **CI Jobs in puppet-openstack**
|
||||
:widths: 12 25 8 55
|
||||
:header-rows: 1
|
||||
|
||||
* - Job name
|
||||
- Description
|
||||
- Voting
|
||||
- What to do in case of failure
|
||||
* - gate-puppet--puppet-lint
|
||||
- It makes sure the code follows recommended `Puppet style guidelines
|
||||
<http://docs.puppetlabs.com/guides/style_guide.html>`__
|
||||
- Yes
|
||||
- Read the job logs to see where the code does not follow the Puppet lint
|
||||
style.
|
||||
* - gate-puppet--puppet-syntax-{3,4}
|
||||
- Syntax checks for Puppet manifests, templates, and Hiera YAML. The jobs
|
||||
runs on latest Puppet 3.x and 4.x releases.
|
||||
- Yes
|
||||
- Read the job logs to see where the code does not follow the Puppet
|
||||
syntax style.
|
||||
* - gate-puppet--puppet-unit-{3.4,3.6,3.7,3.8,4.0}
|
||||
- RSpec tests for Puppet manifests. The jobs runs on Puppet 3.4, 3.6,
|
||||
3.7, 3.8 and 4.0.
|
||||
- Yes
|
||||
- Read the job logs to see where the tests are failing. `More
|
||||
documentation about RSpec <http://rspec-puppet.com/tutorial/>`__
|
||||
* - gate-puppet--puppet-unit-latest
|
||||
- RSpec tests for Puppet manifests. The jobs runs on the latest version
|
||||
of Puppet. It aims to be experimental to track any work to do in the
|
||||
module to be compatible with the latest release of Puppet.
|
||||
- No
|
||||
- Read the job logs to see where the tests are failing. Even though the
|
||||
job is not voting, please raise a bug in Launchpad to make sure someone
|
||||
have a look and maybe update the module to work with latest version of
|
||||
Puppet.
|
||||
* - gate-puppet--puppet-beaker-rspec-dsvm-{centos7,trusty}
|
||||
- Beaker jobs to do functional testing. It will prepare the Puppet
|
||||
environment on 2 different systems (CentOS 7 and Ubuntu Trusty), run
|
||||
Puppet to configure the module resources and run some tests with
|
||||
serverspec.
|
||||
- Yes
|
||||
- Read the job logs. Sometimes, the job fails because of packaging issues
|
||||
or mirrors downtime. Please report a bug for this so we can find
|
||||
workarounds. Otherwise, make sure your patch is supposed to work with
|
||||
current tests or you'll have to adapt the tests to change the expected
|
||||
behavior. `More documentation about Beaker
|
||||
<https://github.com/puppetlabs/beaker/wiki>`__
|
||||
* - gate-puppet-openstack-integration-{3,4}-scenarioX-tempest-dsvm-{centos7
|
||||
,trusty}
|
||||
- Functional testing jobs that will deploy OpenStack run tempest smoke to
|
||||
validate OpenStack is actually working. Now deploy Puppet 3 but our
|
||||
team is testing Puppet 4 too. More details `here <https://github.com/op
|
||||
enstack/puppet-openstack-integration#description>`__
|
||||
- Yes
|
||||
- Read the job logs. Sometimes, the job fails because of
|
||||
packaging issues or mirrors downtime. Please report a bug for this so we
|
||||
can find workarounds. It can also be a problem in Tempest, a new test
|
||||
that is failing or a new parameter which is missing.
|
||||
* - check-tripleo-ironic-overcloud-f21puppet-nonha
|
||||
- Deploy a `TripleO <http://docs.openstack.org/developer/tripleo-docs/>`__
|
||||
overcloud by running Puppet OpenStack modules.
|
||||
- No
|
||||
- If it's not a TripleO CI downtime, you can dig into
|
||||
os-collect-config.txt.gz logs to see why catalog is failing. Sometimes
|
||||
it's very interesting to test the modules against a real use-case
|
||||
(TripleO is an OpenStack installer). Also make sure to consult the
|
||||
`status of TripleO CI <http://tripleo.org/cistatus.html>`__.
|
||||
* - puppet-openstack.fuel-library.pkgs.ubuntu.{neutron\_vlan\_ha,smoke\_neutron}
|
||||
- Deploy OpenStack cloud on top of libvirt VMs using `Fuel
|
||||
<https://wiki.openstack.org/wiki/Fuel>`__ and Puppet OpenStack modules.
|
||||
More details `here
|
||||
<https://wiki.openstack.org/wiki/Fuel/CI#CI_for_Puppet_OpenStack>`__
|
||||
- No
|
||||
- You can read the job logs and take a look into diagnostic snapshot
|
||||
attached to the build, however it takes some understanding of Fuel
|
||||
mechanics to make a good use of this logs. Fuel engineers will
|
||||
investigate the failure according to `Fuel CI duty for Puppet OpenStack
|
||||
<https://wiki.openstack.org/wiki/Fuel/CI/Puppet_OpenStack_CI_duty>`__
|
||||
and may contact you to discuss the reason behind failure. Feel free to
|
||||
aks any questions on #fuel-dev at freenode.
|
||||
* - puppet-openstack.fuel.noop
|
||||
- Read the job logs. Fuel engineers will investigate the failure
|
||||
according to `Fuel CI duty for Puppet OpenStack
|
||||
<https://wiki.openstack.org/wiki/Fuel/CI/Puppet_OpenStack_CI_duty>`__
|
||||
and may contact you to discuss the reason behind failure. Feel free to
|
||||
aks any questions on #fuel-dev at freenode.
|
||||
- No
|
||||
- Run `Fuel-library <https://github.com/openstack/fuel-library>`__ noop
|
||||
tests against Puppet OpenStack modules. More details `here
|
||||
<http://fuel-noop-fixtures.readthedocs.org/en/latest/>`_
|
||||
|
||||
|
||||
|
|
@ -15,6 +15,7 @@ OpenStack cloud deployments.
|
|||
backporting
|
||||
community
|
||||
mailing-list
|
||||
testing
|
||||
|
||||
|
||||
.. note:: This documentation is work in progress, we are moving the content
|
||||
|
|
|
|||
99
doc/source/testing-your-code.rst
Normal file
99
doc/source/testing-your-code.rst
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
#################
|
||||
Testing your code
|
||||
#################
|
||||
|
||||
#. `Unit Tests`_
|
||||
#. `Functional Tests`_
|
||||
|
||||
|
||||
Unit Tests
|
||||
==========
|
||||
|
||||
Unit tests are written in ruby, so you need to be familiar with Rspec, below
|
||||
you can find usefull comands to test your code.
|
||||
|
||||
Running Rspec
|
||||
-------------
|
||||
|
||||
The following command can be invoked in any module diretories to run their
|
||||
rspec tests (lint, syntax, spec, acceptance, etc). It assumes that both
|
||||
bundler as well as rubygems (and ruby) are already installed on the system.
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
mkdir vendor
|
||||
export GEM_HOME=vendor
|
||||
bundle install
|
||||
bundle exec rake lint # Run puppet-lint
|
||||
bundle exec rake syntax # Syntax check Puppet manifests and templates
|
||||
bundle exec rake spec # Run spec tests in a clean fixtures directory
|
||||
bundle exec rake acceptance # Run acceptance tests
|
||||
|
||||
|
||||
This relies on the file fixtures.yaml to install all of the external module
|
||||
required for testing. The url in this file use the git:// protocol, so this
|
||||
may need to be updated if you are behind a proxy.
|
||||
|
||||
.. note::
|
||||
|
||||
Be advised that your local run can be sucessfull and you can get a -1 from
|
||||
Jenkis, because you only run the tests for your Operating System Family.
|
||||
|
||||
The best reference for getting started with rspec-puppet can be found here_.
|
||||
|
||||
.. _here: http://rspec-puppet.com/
|
||||
|
||||
Functional Tests
|
||||
================
|
||||
|
||||
We use beaker to run functional tests, the best reference for getting started
|
||||
with beaker can be found `here <https://github.com/puppetlabs/beaker/wiki>`__.
|
||||
|
||||
Running beaker
|
||||
--------------
|
||||
|
||||
.. code:: bash
|
||||
|
||||
#!/bin/bash
|
||||
if [ -f /usr/bin/yum ]; then
|
||||
sudo yum -y install libxml2-devel libxslt-devel ruby-devel
|
||||
sudo yum -y groupinstall "Development Tools"
|
||||
OS_TYPE='centos7'
|
||||
elif [ -f /usr/bin/apt-get ]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libxml2-dev libxslt-dev zlib1g-dev git ruby
|
||||
ruby-dev build-essential
|
||||
OS_TYPE='trusty'
|
||||
fi
|
||||
echo "" | sudo tee -a /etc/ssh/sshd_config
|
||||
echo "Match address 127.0.0.1" | sudo tee -a /etc/ssh/sshd_config
|
||||
echo " PermitRootLogin without-password" | sudo tee -a
|
||||
/etc/ssh/sshd_config
|
||||
echo "" | sudo tee -a /etc/ssh/sshd_config
|
||||
echo "Match address ::1" | sudo tee -a /etc/ssh/sshd_config
|
||||
echo " PermitRootLogin without-password" | sudo tee -a
|
||||
/etc/ssh/sshd_config
|
||||
mkdir -p .ssh
|
||||
ssh-keygen -f ~/.ssh/id_rsa -b 2048 -C "beaker key" -P ""
|
||||
sudo mkdir -p /root/.ssh
|
||||
sudo rm /root/.ssh/authorized_keys
|
||||
cat ~/.ssh/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys
|
||||
if [ -f /usr/bin/yum ]; then
|
||||
sudo systemctl restart sshd
|
||||
elif [ -f /usr/bin/apt-get ]; then
|
||||
sudo service ssh restart
|
||||
fi
|
||||
sudo gem install bundler --no-rdoc --no-ri --verbose
|
||||
mkdir .bundled_gems
|
||||
export GEM_HOME=`pwd`/.bundled_gems
|
||||
bundle install
|
||||
export BEAKER_set=nodepool-$OS_TYPE
|
||||
export BEAKER_debug=yes
|
||||
bundle exec rspec spec/acceptance
|
||||
|
||||
|
||||
|
|
||||
|
||||
The last command runs beaker tests by installing & testing the OpenStack
|
||||
service.
|
||||
13
doc/source/testing.rst
Normal file
13
doc/source/testing.rst
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#######
|
||||
Testing
|
||||
#######
|
||||
|
||||
As contributor to any of the puppet-openstack repositories and you are not
|
||||
familiar with the tests we use, you should visit testing you code and CI
|
||||
section.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
testing-your-code.rst
|
||||
ci.rst
|
||||
Loading…
Add table
Reference in a new issue