From 0025643f9f32b92d4b88d1629452c31cfb3eacfe Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 15 Dec 2017 10:51:49 +1100 Subject: [PATCH] Add basic rspec test Add a basic deployment test Change-Id: I3ebec9b0c82a228f9d3a4e3d865ca44a233ec83e --- manifests/init.pp | 6 +++ spec/acceptance/etherpad_lite_spec.rb | 63 +++++++++++++++++++++++ spec/acceptance/fixtures/etherpad_lite.pp | 21 ++++++++ spec/acceptance/fixtures/preconditions.pp | 4 ++ 4 files changed, 94 insertions(+) create mode 100644 spec/acceptance/etherpad_lite_spec.rb create mode 100644 spec/acceptance/fixtures/etherpad_lite.pp create mode 100644 spec/acceptance/fixtures/preconditions.pp diff --git a/manifests/init.pp b/manifests/init.pp index cc0b3d7..71f476a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -78,6 +78,12 @@ class etherpad_lite ( anchor { 'nodejs-anchor': } + if !defined(Package['git']) { + package { 'git': + ensure => present + } + } + vcsrepo { "${base_install_dir}/etherpad-lite": ensure => $ep_ensure, provider => git, diff --git a/spec/acceptance/etherpad_lite_spec.rb b/spec/acceptance/etherpad_lite_spec.rb new file mode 100644 index 0000000..beb7713 --- /dev/null +++ b/spec/acceptance/etherpad_lite_spec.rb @@ -0,0 +1,63 @@ +require 'puppet-openstack_infra_spec_helper/spec_helper_acceptance' + +describe 'puppet-etherpad_lite:: manifest', :if => ['debian', 'ubuntu'].include?(os[:family]) do + def pp_path + base_path = File.dirname(__FILE__) + File.join(base_path, 'fixtures') + end + + def preconditions_puppet_module + module_path = File.join(pp_path, 'preconditions.pp') + File.read(module_path) + end + + before(:all) do + apply_manifest(preconditions_puppet_module, catch_failures: true) + end + + def init_puppet_module + module_path = File.join(pp_path, 'etherpad_lite.pp') + File.read(module_path) + end + + it 'should work with no errors' do + apply_manifest(init_puppet_module, catch_failures: true) + end + + describe 'required files' do + describe file('/opt/etherpad-lite/') do + it { should be_directory } + it { should be_grouped_into 'eplite' } + end + + # check service file installed + describe file('/etc/systemd/system/etherpad-lite.service') do + it { should be_file } + end + + # check git got all the source + describe file('/opt/etherpad-lite/etherpad-lite/bin/installDeps.sh') do + it { should be_file } + end + + # check npm modules installed + describe file('/home/eplite/.npm') do + it { should be_directory } + end + end + + # This needs more work before it's up in the test env ... + # + # describe 'required services' do + # describe 'ports are open and services are reachable' do + # describe port(80) do + # it { should be_listening } + # end + + # describe command('curl -L -k http://localhost --verbose') do + # its(:stdout) { should contain('randomPadName()') } + # end + # end + # end + +end diff --git a/spec/acceptance/fixtures/etherpad_lite.pp b/spec/acceptance/fixtures/etherpad_lite.pp new file mode 100644 index 0000000..3ff55eb --- /dev/null +++ b/spec/acceptance/fixtures/etherpad_lite.pp @@ -0,0 +1,21 @@ +class { '::etherpad_lite::mysql': + database_password => 'password', + mysql_root_password => 'password', +} + +class { '::etherpad_lite': + ep_ensure => 'latest', + eplite_version => '1.6.2', + nodejs_version => '6.x', +} + +class { '::etherpad_lite::apache': + ssl_cert_file => '/etc/ssl/certs/ssl-cert-snakeoil.pem', + ssl_key_file => '/etc/ssl/private/ssl-cert-snakeoil.key', + vhost_name => 'localhost', +} + +class { '::etherpad_lite::site': + database_password => 'password', + etherpad_title => 'A fake title', +} diff --git a/spec/acceptance/fixtures/preconditions.pp b/spec/acceptance/fixtures/preconditions.pp new file mode 100644 index 0000000..ae34d0e --- /dev/null +++ b/spec/acceptance/fixtures/preconditions.pp @@ -0,0 +1,4 @@ +# Installing ssl-cert in order to get snakeoil certs +package { 'ssl-cert': + ensure => present, +}