File: destroy_spec.rb

package info (click to toggle)
puppet-agent 8.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,392 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (77 lines) | stat: -rw-r--r-- 2,822 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require 'spec_helper_acceptance'

require 'mount_utils'

RSpec.context 'when managing mounts' do
  agents.each do |agent|
    context "on #{agent}" do
      include_context('mount context', agent)

      it 'deletes an entry in filesystem table and unmounts it' do
        step 'create mount point'
        on(agent, "mkdir /#{name}", acceptable_exit_codes: [0, 1])

        step 'create new filesystem to be mounted'
        MountUtils.create_filesystem(agent, name)

        step 'add entry to the filesystem table'
        MountUtils.add_entry_to_filesystem_table(agent, name)

        step 'mount entry'
        on(agent, "mount /#{name}")

        step 'verify entry exists in filesystem table'
        on(agent, "cat #{fs_file}") do |result|
          fail_test "did not find mount #{name}" unless result.stdout.include?(name)
        end

        step 'destroy a mount with puppet (absent)'
        on(agent, puppet_resource('mount', "/#{name}", 'ensure=absent'))

        step 'verify entry removed from filesystem table'
        on(agent, "cat #{fs_file}") do |result|
          fail_test "found the mount #{name}" if result.stdout.include?(name)
        end

        step 'verify entry is not mounted'
        on(agent, 'mount') do |result|
          fail_test "found the mount #{name} mounted" if result.stdout.include?(name)
        end
      end

      it 'deletes an entry with whitespace in filesystem table and unmounts it' do
        step 'create mount point'
        on(agent, "mkdir '/#{name_w_whitespace}'", acceptable_exit_codes: [0, 1])

        step 'create new filesystem to be mounted'
        MountUtils.create_filesystem(agent, name_w_whitespace)

        step 'add entry to the filesystem table'
        MountUtils.add_entry_to_filesystem_table(agent, name_w_whitespace)

        step 'mount entry'
        on(agent, "mount '/#{name_w_whitespace}'")

        step 'verify entry exists in filesystem table'
        on(agent, "cat #{fs_file}") do |result|
          munged_name = name_w_whitespace.gsub(' ', '\\\040')
          fail_test "did not find mount '#{name_w_whitespace}'" unless result.stdout.include?(munged_name)
        end

        step 'destroy a mount with puppet (absent)'
        on(agent, puppet_resource('mount', "'/#{name_w_whitespace}'", 'ensure=absent'))

        step 'verify entry removed from filesystem table'
        on(agent, "cat #{fs_file}") do |result|
          munged_name = name_w_whitespace.gsub(' ', '\\\040')
          fail_test "found the mount '#{name_w_whitespace}'" if result.stdout.include?(munged_name)
        end

        step 'verify entry is not mounted'
        on(agent, 'mount') do |result|
          fail_test "found the mount '#{name_w_whitespace}' mounted" if result.stdout.include?(name_w_whitespace)
        end
      end
    end
  end
end