Browse Source

Add basic rspec test

Add a basic apply test

Change-Id: Iff4d74806c67c9480e3679fcca56d8470b9fd29e
changes/22/527822/11
Ian Wienand 1 year ago
parent
commit
15c133270b
2 changed files with 59 additions and 0 deletions
  1. 54
    0
      spec/acceptance/ethercalc_spec.rb
  2. 5
    0
      spec/acceptance/fixtures/ethercalc.pp

+ 54
- 0
spec/acceptance/ethercalc_spec.rb View File

@@ -0,0 +1,54 @@
1
+require 'puppet-openstack_infra_spec_helper/spec_helper_acceptance'
2
+
3
+describe 'puppet-ethercalc:: manifest', :if => ['debian', 'ubuntu'].include?(os[:family]) do
4
+  def pp_path
5
+    base_path = File.dirname(__FILE__)
6
+    File.join(base_path, 'fixtures')
7
+  end
8
+
9
+  def init_puppet_module
10
+    module_path = File.join(pp_path, 'ethercalc.pp')
11
+    File.read(module_path)
12
+  end
13
+
14
+  it 'should work with no errors' do
15
+    apply_manifest(init_puppet_module, catch_failures: true)
16
+  end
17
+
18
+  describe 'required packages' do
19
+    describe 'os packages' do
20
+      required_packages = [
21
+        package('curl'),
22
+        package('redis-server'),
23
+      ]
24
+
25
+      required_packages.each do |package|
26
+        describe package do
27
+          it { should be_installed }
28
+        end
29
+      end
30
+    end
31
+  end
32
+
33
+  describe 'required files' do
34
+    describe file('/opt/ethercalc') do
35
+      it { should be_directory }
36
+    end
37
+  end
38
+
39
+  # TODO(ianw): not quite reliable ... possibly need this in a retry
40
+  # loop for a little to let the service start up?
41
+
42
+  # describe 'required services' do
43
+  #   describe 'ports are open and services are reachable' do
44
+  #     describe port(8000) do
45
+  #       it { should be_listening }
46
+  #     end
47
+
48
+  #     describe command('curl http://localhost:8000 --verbose') do
49
+  #       its(:stdout) { should contain('EtherCalc - Share the URL to your friends') }
50
+  #     end
51
+  #   end
52
+  # end
53
+
54
+end

+ 5
- 0
spec/acceptance/fixtures/ethercalc.pp View File

@@ -0,0 +1,5 @@
1
+$source_dir = '/opt/openstack-health'
2
+
3
+include ethercalc::redis
4
+
5
+class { '::ethercalc': }

Loading…
Cancel
Save