Add beaker tests

Add functional tests to ensure that the meetbot module can be applied
without errors, and that the service is accessible. It also validates
that the vhost template renders as expected, since this tends to be one
of the harder parts to get right in module development.

Change-Id: I812a7503d0fda4823bbc0bb7b268f8287b2def8b
This commit is contained in:
Colleen Murphy 2018-04-28 21:25:54 +02:00 committed by Colleen Murphy
parent 63153c941e
commit b44d392811
2 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,64 @@
require 'puppet-openstack_infra_spec_helper/spec_helper_acceptance'
describe 'basic meetbot', :if => ['debian', 'ubuntu'].include?(os[:family]) do
def pp_path
base_path = File.dirname(__FILE__)
File.join(base_path, 'fixtures')
end
def puppet_manifest
module_path = File.join(pp_path, 'default.pp')
File.read(module_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
describe command(" curl http://localhost") do
its(:stdout) { should contain('Welcome to Openstack IRC log server') }
end
expected_vhost = <<EOF
# ************************************
# Managed by Puppet
# ************************************
NameVirtualHost *:80
<VirtualHost *:80>
ServerName eavesdrop.openstack.org
DocumentRoot /srv/meetbot-openstack
<FilesMatch \\.log$>
ForceType text/plain
AddDefaultCharset UTF-8
</FilesMatch>
<Directory /srv/meetbot-openstack>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
<Location /alert>
Header set Access-Control-Allow-Origin "*"
</Location>
ErrorLog /var/log/apache2/eavesdrop.openstack.org_error.log
LogLevel warn
CustomLog /var/log/apache2/eavesdrop.openstack.org_access.log combined
ServerSignature Off
</VirtualHost>
EOF
describe file('/etc/apache2/sites-enabled/50-eavesdrop.openstack.org.conf') do
its(:content) { should eq expected_vhost }
end
end

View File

@ -0,0 +1,22 @@
include httpd
httpd::mod { 'headers':
ensure => present,
}
include meetbot
$vhost_extra = '
<Location /alert>
Header set Access-Control-Allow-Origin "*"
</Location>
'
meetbot::site { 'openstack':
nick => 'openstack',
nickpass => 'nickpass',
network => 'FreeNode',
server => 'chat.freenode.net:7000',
use_ssl => 'True',
vhost_extra => $vhost_extra,
vhost_name => 'eavesdrop.openstack.org',
manage_index => true,
channels => ['#one', '#two', '#three'],
}