File: Rakefile

package info (click to toggle)
r10k 5.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,228 kB
  • sloc: ruby: 18,180; makefile: 10; sh: 1
file content (114 lines) | stat: -rw-r--r-- 3,107 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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
require 'rototiller'
require 'fileutils'

namespace :ci do
  namespace :test do

    desc 'Tests at the component level for the pe-r10k project'
    task :component => [:check_pe_r10k_env_vars] do
      Rake::Task[:beaker].invoke
    end
  end
end

desc 'Run tests against a packaged PE build'
task :acceptance do
  @acceptance_pre_suite = 'pre-suite'
  Rake::Task[:beaker].invoke
end

desc 'The acceptance tests for r10k, run in the beaker framework'
rototiller_task :beaker => [:beaker_hostgenerator] do |t|

  t.add_env do |env|
    env.name = 'PE_FAMILY'
    env.message = 'The puppet enterprise major branch to install from'
  end

  t.add_env do |env|
    env.name = 'pe_dist_dir'
    env.message = 'The location to download PE from, for example "https://artifactory.delivery.puppetlabs.net/artifactory/generic_enterprise__local/20XX.X/ci-ready"'
    ENV['pe_dist_dir'] ||= "https://artifactory.delivery.puppetlabs.net/artifactory/generic_enterprise__local/#{ENV['PE_FAMILY']}/ci-ready"
  end

  t.add_env do |env|
    env.name = 'GIT_PROVIDER'
    env.message = 'The git provider that r10k should use on a SUT'
  end

  t.add_command do |cmd|
    cmd.name = 'beaker --debug'

    common_setup = <<-EOS
pre-suite/00_pe_install.rb,
component/pre-suite/05_install_dev_r10k.rb,
pre-suite/10_git_config.rb,
pre-suite/20_pe_r10k.rb,
EOS
    common_setup.gsub!("\n", '')

    cmd.add_option do |opt|
      opt.name = '--hosts'
      opt.add_argument do |arg|
        arg.name = 'configs/generated'
        arg.add_env({name: 'BEAKER_HOST'})
      end
    end

    cmd.add_option do |opt|
      opt.name = '--keyfile'
      opt.add_argument do |arg|
        arg.name = "#{ENV['HOME']}/.ssh/id_rsa-acceptance"
        arg.add_env({name: 'BEAKER_KEYFILE'})
      end
    end

    cmd.add_option do |opt|
      opt.name = '--pre-suite'
      opt.add_argument do |arg|
        arg.name = @acceptance_pre_suite || common_setup
        arg.add_env({name: 'BEAKER_PRE_SUITE'})
      end
    end

    cmd.add_option do |opt|
      opt.name = '--tests'
      opt.add_argument do |arg|
        arg.name = 'tests'
        arg.add_env({name: 'BEAKER_TESTS'})
      end
    end

    cmd.add_option do |opt|
      opt.name = '--preserve-hosts'
      opt.add_argument do |arg|
        arg.name = 'onfail'
        arg.add_env({name: 'BEAKER_PRESERVE_HOSTS'})
      end
    end

    cmd.add_option do |opt|
      opt.name = '--load-path'
      opt.add_argument({name: 'lib'})
    end
  end
end

desc 'Generate a host configuration used by Beaker'
rototiller_task :beaker_hostgenerator do |t|
  if ENV['BEAKER_HOST'].nil?
    FileUtils.mkdir_p 'configs'
    t.add_command do |c|
      c.name = 'beaker-hostgenerator'
      c.argument = '> configs/generated'
      c.add_option(:name => '', :default => 'centos7-64mdca-64.fa', :override_env => 'TEST_TARGET')
      c.add_option(:name => '--global-config', :default => '{forge_host=forgeapi.puppet.com}', :override_env => 'BHG_GLOBAL_CONFIG')
    end

  end
end

rototiller_task :check_pe_r10k_env_vars do |t|
  t.add_env(:name => 'SHA', :message => 'The sha for pe-r10k')
end