-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
208 lines (203 loc) · 6.81 KB
/
Rakefile
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if ENV['RAKE_DEBUG'] == 'true'
require 'debugger'
debugger
end
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
#
# puppet lint
#
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_class_parameter_defaults')
#PuppetLint.configuration.send('disable_documentation')
#PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.ignore_paths = ["spec/fixtures/**","spec/**/*.rb","spec/**/*.pp", "pkg/**/*.pp"]
#
# beaker testing
# use BEAKER_destroy=no env to stop from destroying containers
# connect with ssh root@localhost -p <the port of the container>
# password root
desc "do beaker based spec testing"
task :acceptance,:platform do |t, args|
args.acceptance(:platform => :default)
puts "running acceptance test : #{args}"
if args.count > 0 && args[0].to_sym != :default
ENV['BEAKER_node'] = args[0]
end
Rake::Task['spec_prep'].invoke
Rake::Task['beaker'].invoke
Rake::Task['spec_clean'].invoke
end
#TODO: cleanup old stuff
#require 'rake'
#require 'rspec/core/rake_task'
#
#require 'rubygems'
#require 'puppetlabs_spec_helper/rake_tasks'
#require 'puppet-lint/tasks/puppet-lint'
#
#GARDENER_RAKE_ROOT = File.dirname(__FILE__)
#
#PuppetLint.configuration.fail_on_warnings = true
#
## Disable check due to complexity added while reading/writing manifests
#PuppetLint.configuration.send('disable_80chars')
#
## Disable check due to upstream bug: https://github.com/rodjek/puppet-lint/issues/170
#PuppetLint.configuration.send('disable_class_parameter_defaults')
#
## Disable check, no need to be compatible with Puppet 2.6.2 and earlier
#PuppetLint.configuration.send('disable_class_inherits_from_params_class')
#
##require 'puppetlabs_spec_helper/rake_tasks'
## This module could be used to instrument the location of a fog_rc file
## and pull it from a secure location for purposes of this rakefile run
#CLOUDCREDS_DIR=(ENV['CLOUDCREDS_DIR'] == nil || ENV['CLOUDCREDS_DIR'] == '') ? '/opt/workspace/git/infra/puppet/modules/cloudcreds' : ENV['CLOUDCREDS_DIR']
#
#Dir.glob("#{CLOUDCREDS_DIR}/Rakefile").each { |r| load r }
#def check_cloudcreds
#
# unless defined?(::CloudCreds::RAKE_ROOT)
# if ENV['FOG_RC'] == nil or ENV['FOG_RC'] == ''
# message = "FOG_RC should be configured or cloudcreds module should be used to define a dynamic FOG_RC \n CLOUDCREDS_DIR => #{CLOUDCREDS_DIR}"
# raise ArgumentError, message
# else
# return false
# end
# end
#
# unless File.exist?(::CloudCreds::RAKE_ROOT)
# if ENV['FOG_RC'] == nil or ENV['FOG_RC'] == ''
# message = "FOG_RC should be configured or set CLOUDCREDS_DIR environment, this Rakefile requires cloudcreds module"
# raise ArgumentError, message
# else
# return false
# end
# end
# return true
#end
#
## Check if the FOG_RC export is enabled, and return true
#def is_fogrc?
# if ENV['FOG_RC'] != nil and ENV['FOG_RC'] != '' and File.exist?(ENV['FOG_RC'])
# return true
# end
# return false
#end
##
## task definitions
##
#Rake::Task["spec"].clear
#desc "Default spec execution"
#task :spec, :fog_spec do |t, args|
# args.spec(:fog_spec => :default)
# Rake::Task['gardener:spec'].invoke(args[0])
#end
#
#namespace :gardener do
# desc "Setup default _spec test"
# RSpec::Core::RakeTask.new(:spec_standalone) do |t|
# t.rspec_opts = ['--color']
# t.pattern = 'spec/{facter,classes,defines,unit,functions,hosts}/**/*_spec.rb'
# end
# RSpec::Core::RakeTask.new(:spec_standalone) do |t|
# t.pattern = 'spec/*/is_domain_managed_test.rb'
# end
#
# RSpec::Core::RakeTask.new(:spec_standalone) do |t|
# t.pattern = 'spec/*/server_up_test.rb'
# end
#
# RSpec::Core::RakeTask.new(:spec_standalone) do |t|
# t.pattern = 'spec/*/compute_id_lookup_test.rb'
# end
#
# RSpec::Core::RakeTask.new(:spec_standalone) do |t|
# t.pattern = 'spec/*/dns_manage_test.rb'
# end
#
# RSpec::Core::RakeTask.new(:spec_standalone) do |t|
# t.pattern = 'spec/*/server_destroy_test.rb'
# end
#
# desc "gardener test."
## task :spec, [:fog_spec] => ['cloudcreds:spec_noclean'] do |t, args|
# task :spec, :fog_spec do |t, args|
# args.spec(:fog_spec => :default)
# puts "Running gardener test... #{args}"
# if ! is_fogrc? and check_cloudcreds
# Rake::Task['cloudcreds:spec_noclean'].invoke(args[0]) #experimental hook for dealing with fog credentials. Not yet supported.
# end
# cd GARDENER_RAKE_ROOT
# puts "using : #{ENV['FOG_RC']}"
# Rake::Task['gardener:spec_prep'].invoke
# Rake::Task['gardener:spec_standalone'].invoke
# Rake::Task['gardener:spec_clean'].invoke
# end
#
# desc "Create the fixtures directory"
# task :spec_prep do
# fixtures("repositories").each do |remote, opts|
# if opts.instance_of?(String)
# target = opts
# ref = "refs/remotes/origin/master"
# elsif opts.instance_of?(Hash)
# target = opts["target"]
# ref = opts["ref"]
# end
#
# unless File::exists?(target) || system("git clone #{remote} #{target}")
# fail "Failed to clone #{remote} into #{target}"
# end
# system("cd #{target}; git reset --hard #{ref}") if ref
# end
#
# FileUtils::mkdir_p("spec/fixtures/modules")
# fixtures("symlinks").each do |source, target|
# puts "source => #{source}"
# puts "target => #{target}"
# if File::exists?(source)
# File::exists?(target) || FileUtils::ln_s(source, target)
# end
# end
#
# FileUtils::mkdir_p("spec/fixtures/manifests")
# FileUtils::touch("spec/fixtures/manifests/site.pp")
# end
#
# desc "Clean up the fixtures directory"
# task :spec_clean do
# fixtures("repositories").each do |remote, opts|
# if opts.instance_of?(String)
# target = opts
# elsif opts.instance_of?(Hash)
# target = opts["target"]
# end
# FileUtils::rm_rf(target)
# end
#
# fixtures("symlinks").each do |source, target|
# puts "cleaning target => #{target}"
# FileUtils::rm(target)
# end
# site = "spec/fixtures/manifests/site.pp"
# if File::exists?(site) and ! File.size?(site)
# FileUtils::rm("spec/fixtures/manifests/site.pp")
# end
# end
#end