Browse Source

Beaker tests

Implement basic structure for beaker tests.

Change-Id: I8b5db1c81dd5816080617ea2c773574312b3d23d
Closes-bug: #1444736
tags/6.0.0
Emilien Macchi 4 years ago
parent
commit
d6e7965bc1

+ 1
- 0
Gemfile View File

@@ -16,6 +16,7 @@ group :development, :test do
16 16
   gem 'puppet-lint-variable_contains_upcase'
17 17
   gem 'puppet-lint-numericvariable'
18 18
 
19
+  gem 'beaker-rspec', '~> 2.2.4', :require => false
19 20
   gem 'json'
20 21
   gem 'webmock'
21 22
 end

+ 14
- 0
README.md View File

@@ -37,6 +37,20 @@ designate is a combination of Puppet manifest and ruby code to delivery configur
37 37
 Limitations
38 38
 -----------
39 39
 
40
+None.
41
+
42
+Beaker-Rspec
43
+------------
44
+
45
+This module has beaker-rspec tests
46
+
47
+To run:
48
+
49
+``shell
50
+bundle install
51
+bundle exec rspec spec/acceptance
52
+``
53
+
40 54
 Development
41 55
 -----------
42 56
 

+ 116
- 0
spec/acceptance/basic_designate_spec.rb View File

@@ -0,0 +1,116 @@
1
+require 'spec_helper_acceptance'
2
+
3
+describe 'basic designate' do
4
+
5
+  context 'default parameters' do
6
+
7
+    it 'should work with no errors' do
8
+      pp= <<-EOS
9
+      Exec { logoutput => 'on_failure' }
10
+
11
+      # Common resources
12
+      include ::apt
13
+      # some packages are not autoupgraded in trusty.
14
+      # it will be fixed in liberty, but broken in kilo.
15
+      $need_to_be_upgraded = ['python-tz', 'python-pbr']
16
+      apt::source { 'trusty-updates-kilo':
17
+        location          => 'http://ubuntu-cloud.archive.canonical.com/ubuntu/',
18
+        release           => 'trusty-updates',
19
+        required_packages => 'ubuntu-cloud-keyring',
20
+        repos             => 'kilo/main',
21
+        trusted_source    => true,
22
+      } ~>
23
+      exec { '/usr/bin/apt-get -y dist-upgrade':
24
+        refreshonly => true,
25
+      }
26
+      Apt::Source['trusty-updates-kilo'] -> Package<| |>
27
+
28
+      class { '::mysql::server': }
29
+
30
+      class { '::rabbitmq':
31
+        delete_guest_user => true,
32
+        erlang_cookie     => 'secrete',
33
+      }
34
+
35
+      rabbitmq_vhost { '/':
36
+        provider => 'rabbitmqctl',
37
+        require  => Class['rabbitmq'],
38
+      }
39
+
40
+      rabbitmq_user { 'designate':
41
+        admin    => true,
42
+        password => 'an_even_bigger_secret',
43
+        provider => 'rabbitmqctl',
44
+        require  => Class['rabbitmq'],
45
+      }
46
+
47
+      rabbitmq_user_permissions { 'designate@/':
48
+        configure_permission => '.*',
49
+        write_permission     => '.*',
50
+        read_permission      => '.*',
51
+        provider             => 'rabbitmqctl',
52
+        require              => Class['rabbitmq'],
53
+      }
54
+
55
+      # Keystone resources, needed by Designate to run
56
+      class { '::keystone::db::mysql':
57
+        password => 'keystone',
58
+      }
59
+      class { '::keystone':
60
+        verbose             => true,
61
+        debug               => true,
62
+        database_connection => 'mysql://keystone:keystone@127.0.0.1/keystone',
63
+        admin_token         => 'admin_token',
64
+        enabled             => true,
65
+      }
66
+      class { '::keystone::roles::admin':
67
+        email    => 'test@example.tld',
68
+        password => 'a_big_secret',
69
+      }
70
+      class { '::keystone::endpoint':
71
+        public_url => "https://${::fqdn}:5000/",
72
+        admin_url  => "https://${::fqdn}:35357/",
73
+      }
74
+
75
+      # Designate resources
76
+      class { '::designate::db::mysql':
77
+        password => 'a_big_secret',
78
+      }
79
+      class { '::designate::keystone::auth':
80
+        password => 'a_big_secret',
81
+      }
82
+      class { '::designate':
83
+        rabbit_userid       => 'designate',
84
+        rabbit_password     => 'an_even_bigger_secret',
85
+        rabbit_host         => '127.0.0.1',
86
+      }
87
+      class { '::designate::api':
88
+        enabled           => true,
89
+        auth_strategy     => 'keystone',
90
+        keystone_password => 'a_big_secret',
91
+      }
92
+      class { '::designate::backend::bind9':
93
+        rndc_config_file => '',
94
+        rndc_key_file    => '',
95
+      }
96
+      include ::designate::client
97
+      class { '::designate::agent': }
98
+      class { '::designate::db':
99
+        database_connection => 'mysql://designate:a_big_secret@127.0.0.1/designate?charset=utf8',
100
+      }
101
+      include ::designate::dns
102
+      EOS
103
+
104
+
105
+      # Run it once, idempotency does not work
106
+      # this is what we have each time we run puppet after first time:
107
+      # http://paste.openstack.org/show/2ebHALkNguNsE0804Oev/
108
+      apply_manifest(pp, :catch_failures => true)
109
+    end
110
+
111
+    describe port(9001) do
112
+      it { is_expected.to be_listening.with('tcp') }
113
+    end
114
+
115
+  end
116
+end

+ 9
- 0
spec/acceptance/nodesets/default.yml View File

@@ -0,0 +1,9 @@
1
+HOSTS:
2
+  ubuntu-14.04-amd64:
3
+    roles:
4
+      - master
5
+    platform: ubuntu-14.04-amd64
6
+    hypervisor : none
7
+    ip: 127.0.0.1
8
+CONFIG:
9
+  type: foss

+ 9
- 0
spec/acceptance/nodesets/nodepool.yml View File

@@ -0,0 +1,9 @@
1
+HOSTS:
2
+  ubuntu-14.04-amd64:
3
+    roles:
4
+      - master
5
+    platform: ubuntu-14.04-amd64
6
+    hypervisor : none
7
+    ip: 127.0.0.1
8
+CONFIG:
9
+  type: foss

+ 46
- 0
spec/spec_helper_acceptance.rb View File

@@ -0,0 +1,46 @@
1
+require 'beaker-rspec'
2
+
3
+hosts.each do |host|
4
+
5
+  install_puppet
6
+
7
+  on host, "mkdir -p #{host['distmoduledir']}"
8
+end
9
+
10
+RSpec.configure do |c|
11
+  # Project root
12
+  proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
13
+
14
+  # Readable test descriptions
15
+  c.formatter = :documentation
16
+
17
+  # Configure all nodes in nodeset
18
+  c.before :suite do
19
+    # Install module and dependencies
20
+    hosts.each do |host|
21
+
22
+      # install git
23
+      install_package host, 'git'
24
+
25
+      # clean out any module cruft
26
+      shell('rm -fr /etc/puppet/modules/*')
27
+
28
+      # install library modules from the forge
29
+      on host, puppet('module','install','puppetlabs-inifile'), { :acceptable_exit_codes => 0 }
30
+      on host, puppet('module','install','theforeman/dns'), { :acceptable_exit_codes => 0 }
31
+      on host, puppet('module','install','puppetlabs-mysql'), { :acceptable_exit_codes => 0 }
32
+      on host, puppet('module','install','dprince/qpid'), { :acceptable_exit_codes => 0 }
33
+      on host, puppet('module','install','stahnma-epel'), { :acceptable_exit_codes => 0 }
34
+      on host, puppet('module','install','puppetlabs-rabbitmq'), { :acceptable_exit_codes => 0 }
35
+
36
+      # install puppet modules from git, use master
37
+      shell('git clone https://git.openstack.org/stackforge/puppet-openstacklib /etc/puppet/modules/openstacklib')
38
+      shell('git clone https://git.openstack.org/stackforge/puppet-keystone /etc/puppet/modules/keystone')
39
+
40
+      # Install the module being tested
41
+      puppet_module_install(:source => proj_root, :module_name => 'designate')
42
+      # List modules installed to help with debugging
43
+      on hosts[0], puppet('module','list'), { :acceptable_exit_codes => 0 }
44
+    end
45
+  end
46
+end

Loading…
Cancel
Save