Browse Source

Boilerplate beaker-rspec files

Change-Id: I3ae18482462b90826452059f51223c5c5000e87e
Spencer Krum 3 years ago
parent
commit
32b048bfbc

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

@@ -0,0 +1,11 @@
1
+HOSTS:
2
+  ubuntu-server-1404-x64:
3
+    roles:
4
+      - master
5
+    platform: ubuntu-14.04-amd64
6
+    box: puppetlabs/ubuntu-14.04-64-nocm
7
+    box_url: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
8
+    hypervisor: vagrant
9
+CONFIG:
10
+  log_level: debug
11
+  type: git

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

@@ -0,0 +1,10 @@
1
+HOSTS:
2
+  centos-70-x64:
3
+    roles:
4
+      - master
5
+    platform: el-7-x86_64
6
+    hypervisor: none
7
+    ip: 127.0.0.1
8
+CONFIG:
9
+  type: foss
10
+  set_env: false

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

@@ -0,0 +1,10 @@
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
10
+  set_env: false

+ 58
- 0
spec/spec_helper_acceptance.rb View File

@@ -0,0 +1,58 @@
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
+  modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1]
14
+
15
+  # Readable test descriptions
16
+  c.formatter = :documentation
17
+
18
+  # Configure all nodes in nodeset
19
+  c.before :suite do
20
+    # Install module and dependencies
21
+    hosts.each do |host|
22
+
23
+      # Clean out any module cruft
24
+      shell('rm -fr /etc/puppet/modules/*')
25
+
26
+      # install git
27
+      install_package host, 'git'
28
+
29
+      zuul_ref = ENV['ZUUL_REF']
30
+      zuul_branch = ENV['ZUUL_BRANCH']
31
+      zuul_url = ENV['ZUUL_URL']
32
+
33
+      # Install dependent modules via git or zuul
34
+      r = on host, "test -e /usr/zuul-env/bin/zuul-cloner", { :acceptable_exit_codes => [0,1] }
35
+      repo = 'openstack-infra/system-config'
36
+      if r.exit_code == 0
37
+        zuul_clone_cmd = '/usr/zuul-env/bin/zuul-cloner '
38
+        zuul_clone_cmd += '--cache-dir /opt/git '
39
+        zuul_clone_cmd += "--zuul-ref #{zuul_ref} "
40
+        zuul_clone_cmd += "--zuul-branch #{zuul_branch} "
41
+        zuul_clone_cmd += "--zuul-url #{zuul_url} "
42
+        zuul_clone_cmd += "git://git.openstack.org #{repo}"
43
+        on host, zuul_clone_cmd
44
+      else
45
+        on host, "git clone https://git.openstack.org/#{repo}"
46
+      end
47
+
48
+      on host, "ZUUL_REF=#{zuul_ref} ZUUL_BRANCH=#{zuul_branch} ZUUL_URL=#{zuul_url} bash #{repo}/tools/install_modules_acceptance.sh"
49
+      on host, "rm -fr /etc/puppet/modules/#{modname}"
50
+
51
+      # Install the module being tested
52
+      puppet_module_install(:source => proj_root, :module_name => modname)
53
+      on host, "rm -fr #{repo}"
54
+      # List modules installed to help with debugging
55
+      on hosts[0], puppet('module','list'), { :acceptable_exit_codes => 0 }
56
+    end
57
+  end
58
+end

Loading…
Cancel
Save