integration tests environment

Use https://github.com/puppetlabs/rspec-system-puppet to implement
vagrant based integration tests. The README.md is updated with
instructions to run the integration tests locally. These tests could be
run by a deamon listening to the gerrit stream, when a changeset is
submitted for review, to prove that they do not introduce a regression.

The dependencies from .fixtures.yml have been manually replicated to
spec/spec_helper_system.rb . rspec system puppet is still young and
people do this. It will be a burden only for long term maintenance. And
when it does, in a few months from now, it is safe to assume that rspec
system puppet will have support for reading from an existing file. The
alternative is that rspec system puppet is obsoleted / dead, in which
case this is even a bigger problem. In any case, if work had to be done
to fix this, it should be a patch against rspec system puppet and not
part of puppet-ceph.
https://github.com/puppetlabs/rspec-system-puppet/issues/5

A test for the ceph::repo class is included to demonstrate the
environment actually works. It is not meant to fully test the ceph::repo
integration this would require a separate patch. rspec-system-puppet
requires at least one file in spec/system otherwise it will fail with
an unrelated error:

   Could not autoload puppet/provider/ceph_config/ini_setting: undefined
   method `provider' for nil:NilClass (Puppet::Error)

This test can be removed as soon as another is added.

Change-Id: Ib65120a58ce203126be5897f602e280c474642dc
Signed-off-by: Loic Dachary <loic@dachary.org>
This commit is contained in:
Loic Dachary 2013-10-24 11:14:54 +02:00
parent 0383a1aea2
commit 7557d5e8ee
7 changed files with 123 additions and 2 deletions

3
.gitignore vendored
View File

@ -5,3 +5,6 @@ metadata.json
spec/fixtures/modules/*
pkg
Gemfile.lock
.bundle
vendor
.rspec_system

6
.nodeset.yml Normal file
View File

@ -0,0 +1,6 @@
default_set: 'ubuntu-server-12042-x64'
sets:
'ubuntu-server-12042-x64':
nodes:
'main.vm':
prefab: 'ubuntu-server-12042-x64'

View File

@ -1,8 +1,10 @@
# vim:ft=ruby
source 'https://rubygems.org'
group :development, :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', '~> 0.3.2'
gem 'rspec-system-puppet'
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
@ -10,5 +12,3 @@ if puppetversion = ENV['PUPPET_GEM_VERSION']
else
gem 'puppet', :require => false
end
# vim:ft=ruby

View File

@ -10,6 +10,7 @@ ceph
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)
7. [Contributors - Those with commits](#contributors)
7. [Integration - Apply the module and test restults](#integration-tests)
8. [Release Notes - Notes on the most recent updates to the module](#release-notes)
Overview
@ -50,6 +51,28 @@ IRC channels:
* irc.freenode.net#puppet-openstack
* irc.oftc.net#ceph-devel
Integration
-----------
Relies on
[rspec-system-puppet](https://github.com/puppetlabs/rspec-system-puppet)
and tests are in spec/system. It runs virtual machines and requires
4GB of free memory and 10GB of free disk space.
* [Install Vagrant and Virtualbox](http://docs-v1.vagrantup.com/v1/docs/getting-started/)
* bundle install --path vendor/bundle
* bundle exec rake spec:system
On success it should complete with
...
=end=============================================================
Finished in 4 minutes 1.7 seconds
1 example, 0 failures
Contributors
------------

View File

@ -1,5 +1,11 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
begin
require 'rspec-system/rake_task'
rescue LoadError => e
warn e.message
warn "Run `gem install rspec-system-puppet` to enable integration tests."
end
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('disable_80chars')

View File

@ -0,0 +1,38 @@
#
# Copyright 2013 Cloudwatt <libre-licensing@cloudwatt.com>
#
# Author: Loic Dachary <loic@dachary.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'rspec-system/spec_helper'
require 'rspec-system-puppet/helpers'
include RSpecSystemPuppet::Helpers
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Enable colour
c.tty = true
c.include RSpecSystemPuppet::Helpers
c.before :suite do
puppet_install
puppet_master_install
puppet_module_install(:source => proj_root, :module_name => 'ceph')
shell 'puppet module install --version 1.4.0 puppetlabs/apt'
end
end

45
spec/system/basic_spec.rb Normal file
View File

@ -0,0 +1,45 @@
#
# Copyright 2013 Cloudwatt <libre-licensing@cloudwatt.com>
#
# Author: Loic Dachary <loic@dachary.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'spec_helper_system'
describe 'basic tests:' do
# Using puppet_apply as a helper
it 'ceph::repo should work with no errors' do
pp = <<-EOS
class { 'ceph::repo':
release => 'dumpling'
}
EOS
# Run it twice and test for idempotency
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
r.refresh
r.exit_code.should be_zero
end
end
context shell 'apt-cache policy ceph' do
its(:stdout) { should =~ /Candidate: 0.67/ }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
end
end