From b6c60c0414279b4f3ad1bca2aacf65b6a7c85c7f Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Thu, 12 Jul 2018 13:24:46 +0200 Subject: [PATCH] Add beaker tests Add basic tests to ensure the puppet manifests can be applied cleanly and the service will start. We could test with a real IRC network and a real registered IRC user, but the service starts just fine even if it can't connect to an IRC server, and it's not the puppet module's job to test the bot itself, it's sufficient to test that the server is configured the way we expect it to be. Change-Id: If153cdbfcd0a78b25ca01f22a10ab1c9055c0766 --- spec/acceptance/basic_spec.rb | 36 ++++++++++++++++++++++ spec/acceptance/fixtures/default.pp | 15 +++++++++ spec/acceptance/fixtures/postconditions.pp | 3 ++ 3 files changed, 54 insertions(+) create mode 100755 spec/acceptance/basic_spec.rb create mode 100644 spec/acceptance/fixtures/default.pp create mode 100644 spec/acceptance/fixtures/postconditions.pp diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb new file mode 100755 index 0000000..abdbd2e --- /dev/null +++ b/spec/acceptance/basic_spec.rb @@ -0,0 +1,36 @@ +require 'puppet-openstack_infra_spec_helper/spec_helper_acceptance' + +describe 'statusbot' do + + def pp_path + base_path = File.dirname(__FILE__) + File.join(base_path, 'fixtures') + end + + def puppet_manifest + manifest_path = File.join(pp_path, 'default.pp') + File.read(manifest_path) + end + + def postconditions_puppet_manifest + manifest_path = File.join(pp_path, 'postconditions.pp') + File.read(manifest_path) + end + + it 'should work with no errors' do + apply_manifest(puppet_manifest, catch_failures: true) + end + + it 'should be idempotent' do + apply_manifest(puppet_manifest, catch_changes: true) + end + + it 'should start' do + apply_manifest(postconditions_puppet_manifest, catch_failures: true) + end + + describe service('statusbot') do + it { should be_running } + end + +end diff --git a/spec/acceptance/fixtures/default.pp b/spec/acceptance/fixtures/default.pp new file mode 100644 index 0000000..190a69d --- /dev/null +++ b/spec/acceptance/fixtures/default.pp @@ -0,0 +1,15 @@ +class { 'statusbot': + nick => 'statusbot-test', + password => 'statusbot-password', + server => 'irc.notreal.net', + channels => 'unrealchannel', + auth_nicks => 'statusbot-test', + wiki_user => 'dummy', + wiki_password => 'dummy', + wiki_url => 'dummy', + wiki_pageid => 'dummy', + wiki_successpageid => 'dummy', + wiki_successpageurl => 'dummy', + wiki_thankspageid => 'dummy', + wiki_thankspageurl => 'dummy', +} diff --git a/spec/acceptance/fixtures/postconditions.pp b/spec/acceptance/fixtures/postconditions.pp new file mode 100644 index 0000000..8359147 --- /dev/null +++ b/spec/acceptance/fixtures/postconditions.pp @@ -0,0 +1,3 @@ +service { 'statusbot': + ensure => running, +}