From d6e7965bc1cc64d76baee902c0e5c1f614eb9279 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 28 Apr 2015 15:48:08 -0400 Subject: [PATCH] Beaker tests Implement basic structure for beaker tests. Change-Id: I8b5db1c81dd5816080617ea2c773574312b3d23d Closes-bug: #1444736 --- Gemfile | 1 + README.md | 14 +++ spec/acceptance/basic_designate_spec.rb | 116 ++++++++++++++++++++++++ spec/acceptance/nodesets/default.yml | 9 ++ spec/acceptance/nodesets/nodepool.yml | 9 ++ spec/spec_helper_acceptance.rb | 46 ++++++++++ 6 files changed, 195 insertions(+) create mode 100644 spec/acceptance/basic_designate_spec.rb create mode 100644 spec/acceptance/nodesets/default.yml create mode 100644 spec/acceptance/nodesets/nodepool.yml create mode 100644 spec/spec_helper_acceptance.rb diff --git a/Gemfile b/Gemfile index b96ac8a1..571fd65d 100644 --- a/Gemfile +++ b/Gemfile @@ -16,6 +16,7 @@ group :development, :test do gem 'puppet-lint-variable_contains_upcase' gem 'puppet-lint-numericvariable' + gem 'beaker-rspec', '~> 2.2.4', :require => false gem 'json' gem 'webmock' end diff --git a/README.md b/README.md index 48650213..119afe84 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,20 @@ designate is a combination of Puppet manifest and ruby code to delivery configur Limitations ----------- +None. + +Beaker-Rspec +------------ + +This module has beaker-rspec tests + +To run: + +``shell +bundle install +bundle exec rspec spec/acceptance +`` + Development ----------- diff --git a/spec/acceptance/basic_designate_spec.rb b/spec/acceptance/basic_designate_spec.rb new file mode 100644 index 00000000..9c59442c --- /dev/null +++ b/spec/acceptance/basic_designate_spec.rb @@ -0,0 +1,116 @@ +require 'spec_helper_acceptance' + +describe 'basic designate' do + + context 'default parameters' do + + it 'should work with no errors' do + pp= <<-EOS + Exec { logoutput => 'on_failure' } + + # Common resources + include ::apt + # some packages are not autoupgraded in trusty. + # it will be fixed in liberty, but broken in kilo. + $need_to_be_upgraded = ['python-tz', 'python-pbr'] + apt::source { 'trusty-updates-kilo': + location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu/', + release => 'trusty-updates', + required_packages => 'ubuntu-cloud-keyring', + repos => 'kilo/main', + trusted_source => true, + } ~> + exec { '/usr/bin/apt-get -y dist-upgrade': + refreshonly => true, + } + Apt::Source['trusty-updates-kilo'] -> Package<| |> + + class { '::mysql::server': } + + class { '::rabbitmq': + delete_guest_user => true, + erlang_cookie => 'secrete', + } + + rabbitmq_vhost { '/': + provider => 'rabbitmqctl', + require => Class['rabbitmq'], + } + + rabbitmq_user { 'designate': + admin => true, + password => 'an_even_bigger_secret', + provider => 'rabbitmqctl', + require => Class['rabbitmq'], + } + + rabbitmq_user_permissions { 'designate@/': + configure_permission => '.*', + write_permission => '.*', + read_permission => '.*', + provider => 'rabbitmqctl', + require => Class['rabbitmq'], + } + + # Keystone resources, needed by Designate to run + class { '::keystone::db::mysql': + password => 'keystone', + } + class { '::keystone': + verbose => true, + debug => true, + database_connection => 'mysql://keystone:keystone@127.0.0.1/keystone', + admin_token => 'admin_token', + enabled => true, + } + class { '::keystone::roles::admin': + email => 'test@example.tld', + password => 'a_big_secret', + } + class { '::keystone::endpoint': + public_url => "https://${::fqdn}:5000/", + admin_url => "https://${::fqdn}:35357/", + } + + # Designate resources + class { '::designate::db::mysql': + password => 'a_big_secret', + } + class { '::designate::keystone::auth': + password => 'a_big_secret', + } + class { '::designate': + rabbit_userid => 'designate', + rabbit_password => 'an_even_bigger_secret', + rabbit_host => '127.0.0.1', + } + class { '::designate::api': + enabled => true, + auth_strategy => 'keystone', + keystone_password => 'a_big_secret', + } + class { '::designate::backend::bind9': + rndc_config_file => '', + rndc_key_file => '', + } + include ::designate::client + class { '::designate::agent': } + class { '::designate::db': + database_connection => 'mysql://designate:a_big_secret@127.0.0.1/designate?charset=utf8', + } + include ::designate::dns + EOS + + + # Run it once, idempotency does not work + # this is what we have each time we run puppet after first time: + # http://paste.openstack.org/show/2ebHALkNguNsE0804Oev/ + apply_manifest(pp, :catch_failures => true) + end + + describe port(9001) do + it { is_expected.to be_listening.with('tcp') } + end + + end +end diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 100644 index 00000000..a2c1ecc6 --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -0,0 +1,9 @@ +HOSTS: + ubuntu-14.04-amd64: + roles: + - master + platform: ubuntu-14.04-amd64 + hypervisor : none + ip: 127.0.0.1 +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/nodepool.yml b/spec/acceptance/nodesets/nodepool.yml new file mode 100644 index 00000000..a2c1ecc6 --- /dev/null +++ b/spec/acceptance/nodesets/nodepool.yml @@ -0,0 +1,9 @@ +HOSTS: + ubuntu-14.04-amd64: + roles: + - master + platform: ubuntu-14.04-amd64 + hypervisor : none + ip: 127.0.0.1 +CONFIG: + type: foss diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 00000000..f293a532 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,46 @@ +require 'beaker-rspec' + +hosts.each do |host| + + install_puppet + + on host, "mkdir -p #{host['distmoduledir']}" +end + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + hosts.each do |host| + + # install git + install_package host, 'git' + + # clean out any module cruft + shell('rm -fr /etc/puppet/modules/*') + + # install library modules from the forge + on host, puppet('module','install','puppetlabs-inifile'), { :acceptable_exit_codes => 0 } + on host, puppet('module','install','theforeman/dns'), { :acceptable_exit_codes => 0 } + on host, puppet('module','install','puppetlabs-mysql'), { :acceptable_exit_codes => 0 } + on host, puppet('module','install','dprince/qpid'), { :acceptable_exit_codes => 0 } + on host, puppet('module','install','stahnma-epel'), { :acceptable_exit_codes => 0 } + on host, puppet('module','install','puppetlabs-rabbitmq'), { :acceptable_exit_codes => 0 } + + # install puppet modules from git, use master + shell('git clone https://git.openstack.org/stackforge/puppet-openstacklib /etc/puppet/modules/openstacklib') + shell('git clone https://git.openstack.org/stackforge/puppet-keystone /etc/puppet/modules/keystone') + + # Install the module being tested + puppet_module_install(:source => proj_root, :module_name => 'designate') + # List modules installed to help with debugging + on hosts[0], puppet('module','list'), { :acceptable_exit_codes => 0 } + end + end +end