From f5d762f98e2aa85e5060ece7a37caaaf5d920320 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 9 Jul 2018 18:30:00 +0200 Subject: [PATCH] Add beaker tests Add tests to ensure the subunit2sql server and worker classes work and that the worker service can start. Change-Id: I842ecbcd5988484043643fdae1c49dd95bba90f2 --- spec/acceptance/basic_spec.rb | 36 ++++++++++++++++++++++ spec/acceptance/fixtures/default.pp | 30 ++++++++++++++++++ spec/acceptance/fixtures/postconditions.pp | 3 ++ 3 files changed, 69 insertions(+) create mode 100644 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 100644 index 0000000..9184ea4 --- /dev/null +++ b/spec/acceptance/basic_spec.rb @@ -0,0 +1,36 @@ +require 'puppet-openstack_infra_spec_helper/spec_helper_acceptance' + +describe 'subunit2sql', :if => ['debian', 'ubuntu'].include?(os[:family]) 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('jenkins-subunit-worker-A') 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..2ad4530 --- /dev/null +++ b/spec/acceptance/fixtures/default.pp @@ -0,0 +1,30 @@ +$content = "gearman-host: logstash.openstack.org +gearman-port: 4730 +config: /etc/subunit2sql/subunit2sql.conf +mqtt-host: firehose.openstack.org +mqtt-port: 8883 +mqtt-topic: gearman-subunit/localhost +mqtt-user: 'mqtt_user' +mqtt-pass: 'mqtt_pass' +mqtt-ca-certs: /etc/subunit2sql/mqtt-root-CA.pem.crt" + +file { '/etc/subunit2sql/subunit-woker.yaml': + ensure => file, + owner => 'root', + group => 'root', + mode => '0555', + content => $content, +} + +include 'subunit2sql' + +class { 'subunit2sql::server': + db_host => 'subunit2sql_db_host', + db_pass => 'subunit2sql_db_pass', +} + +subunit2sql::worker { 'A': + config_file => '/etc/subunit2sql/subunit-woker.yaml', + db_host => $subunit2sql_db_host, + db_pass => $subunit2sql_db_pass, +} diff --git a/spec/acceptance/fixtures/postconditions.pp b/spec/acceptance/fixtures/postconditions.pp new file mode 100644 index 0000000..647a712 --- /dev/null +++ b/spec/acceptance/fixtures/postconditions.pp @@ -0,0 +1,3 @@ +service { 'jenkins-subunit-worker-A': + ensure => running, +}