File: spec_helper_acceptance.rb

package info (click to toggle)
puppet-agent 8.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 27,392 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (46 lines) | stat: -rw-r--r-- 1,487 bytes parent folder | download
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
require 'beaker-rspec'
require 'beaker-puppet'
require 'beaker/module_install_helper'
require 'beaker/puppet_install_helper'
require 'voxpupuli/acceptance/spec_helper_acceptance'

$LOAD_PATH << File.join(__dir__, 'acceptance/lib')

RSpec.configure do |c|
  c.before :suite do
    unless ENV['BEAKER_provision'] == 'no'
      hosts.each { |host| host[:type] = 'aio' }
      run_puppet_install_helper
      install_module_on(hosts)
      install_module_dependencies_on(hosts)
    end
  end
end

shared_context 'mount context' do |agent|
  let(:fs_file) { MountUtils.filesystem_file(agent) }
  let(:fs_type) { MountUtils.filesystem_type(agent) }
  let(:backup) { agent.tmpfile('mount-modify') }
  let(:name) { "pl#{rand(999_999).to_i}" }
  let(:name_w_slash) { "pl#{rand(999_999).to_i}\/" }
  let(:name_w_whitespace) { "pl#{rand(999).to_i} #{rand(999).to_i}" }

  before(:each) do
    on(agent, "cp #{fs_file} #{backup}", acceptable_exit_codes: [0, 1])
  end

  after(:each) do
    # umount disk image
    on(agent, "umount /#{name}", acceptable_exit_codes: (0..254))
    # delete disk image
    if agent['platform'].include?('aix')
      on(agent, "rmlv -f #{name}", acceptable_exit_codes: (0..254))
    else
      on(agent, "rm /tmp/#{name}", acceptable_exit_codes: (0..254))
    end
    # delete mount point
    on(agent, "rm -fr /#{name}", acceptable_exit_codes: (0..254))
    # restore the fstab file
    on(agent, "mv #{backup} #{fs_file}", acceptable_exit_codes: (0..254))
  end
end