From 19d52da6116cfa00f13e66c5f2cfde91d2f24e90 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 11 Jul 2018 13:27:15 +0200 Subject: [PATCH] Add beaker tests Add basic tests to ensure the puppet class applies cleanly and the service can start. Change-Id: I091d1cd7b4a00f1ef3c955ab330d24cd066818a6 --- spec/acceptance/basic_spec.rb | 27 ++++++++++++++++++++++++ spec/acceptance/fixtures/default.pp | 32 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100755 spec/acceptance/basic_spec.rb create mode 100644 spec/acceptance/fixtures/default.pp diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb new file mode 100755 index 0000000..0b7f7a5 --- /dev/null +++ b/spec/acceptance/basic_spec.rb @@ -0,0 +1,27 @@ +require 'puppet-openstack_infra_spec_helper/spec_helper_acceptance' + +describe 'gerritbot', if: os[:family] == 'ubuntu' 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 + + 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 service('gerritbot') 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..15c2639 --- /dev/null +++ b/spec/acceptance/fixtures/default.pp @@ -0,0 +1,32 @@ +$gerritbot_ssh_rsa_pubkey_contents = 'ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFnYsbHrGl99in5doo1uy+V3N3ayR4J0/sJprK+7E8exDwAGe1vZmUftjZ6uMi4RckxuFTuVJdxrFvTLEQpNrSU=' + +$gerritbot_ssh_rsa_key_contents = 'MHcCAQEEIJUIOR4hPwqds8ESewPHm+r5ejSqjuFjBfVa7jQTH99QoAoGCCqGSM49 +AwEHoUQDQgAEWdixsesaX32Kfl2ijW7L5Xc3drJHgnT+wmmsr7sTx7EPAAZ7W9mZ +R+2Nnq4yLhFyTG4VO5Ul3GsW9MsRCk2tJQ== +-----END EC PRIVATE KEY-----' + +file { '/etc/gerritbot-channels.yaml': + ensure => present, + content => '', +} + +include gerrit::user + +file { '/home/gerrit2/.ssh': + ensure => directory, + owner => 'gerrit2', + mode => '0700', + require => User['gerrit2'], +} + +class { 'gerritbot': + nick => 'openstackgerrit', + password => 'gerritbot_password', + server => 'irc.freenode.net', + user => 'gerritbot', + vhost_name => 'review.openstack.org', + ssh_rsa_key_contents => $gerritbot_ssh_rsa_key_contents, + ssh_rsa_pubkey_contents => $gerritbot_ssh_rsa_pubkey_contents, + channel_file => '/etc/gerritbot-channels.yaml', + require => File['/etc/gerritbot-channels.yaml'], +}