Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 129 lines (115 sloc) 3.663 kb
742eae4 @jedi4ever updated rake tasks for bundler
authored
1 require 'rubygems'
2 require 'bundler'
3 require 'bundler/setup'
42e8e48 @jedi4ever reactived some test parts, corrected the Centos4-8 template
authored
4 require 'veewee'
742eae4 @jedi4ever updated rake tasks for bundler
authored
5 Bundler::GemHelper.install_tasks
6
cf8d27c @jedi4ever - Restructured the whole project, no real features added
authored
7 desc 'Default: run tests'
8 task :default => :test
495234d @jedi4ever Snapshots get taken now after each step:
authored
9
cf8d27c @jedi4ever - Restructured the whole project, no real features added
authored
10 require 'rake/testtask'
ff2c117 @jedi4ever Almost working
authored
11
d27979d @jedi4ever Again, a massive chunk of restructuring current behavior
authored
12 desc 'Tests not requiring an real box'
cf8d27c @jedi4ever - Restructured the whole project, no real features added
authored
13 Rake::TestTask.new do |t|
14 t.libs << "test"
15 t.pattern = 'test/**/*_test.rb'
16 end
ff2c117 @jedi4ever Almost working
authored
17
d27979d @jedi4ever Again, a massive chunk of restructuring current behavior
authored
18 desc 'Tests requiring an real box'
19 Rake::TestTask.new do |t|
20 t.name="realtest"
21 t.libs << "test"
f73b086 @jedi4ever updated to make test run again with rake 0.9
authored
22 t.libs << "."
d27979d @jedi4ever Again, a massive chunk of restructuring current behavior
authored
23 t.pattern = 'test/**/*_realtest.rb'
24 end
25
42e8e48 @jedi4ever reactived some test parts, corrected the Centos4-8 template
authored
26 desc 'Verify ISO'
e3a2128 @miketheman style: spacing
miketheman authored
27 task :iso, [:template_name] do |t, args|
4836077 @jedi4ever added iso check in rakefile temporary
authored
28 require 'net/http'
29 #if args.to_hash.size!=1
30 #puts "needs one arguments: rake iso [\"yourname\"]"
31 #exit
32 #end
33 Dir.glob("templates/*").each do |name|
e3a2128 @miketheman style: spacing
miketheman authored
34 definition_name = File.basename(name)
f73b086 @jedi4ever updated to make test run again with rake 0.9
authored
35 puts name
e3a2128 @miketheman style: spacing
miketheman authored
36 definition = Veewee::Environment.new(:cwd => ".", :definition_dir => "templates").definitions[definition_name]
37 next if definition.nil? || definition.iso_src.nil? || definition.iso_src == ""
4836077 @jedi4ever added iso check in rakefile temporary
authored
38 begin
e3a2128 @miketheman style: spacing
miketheman authored
39 url = definition.iso_src
40 found = false
4836077 @jedi4ever added iso check in rakefile temporary
authored
41 response = nil
e3a2128 @miketheman style: spacing
miketheman authored
42 while found == false
43 uri = URI.parse(url)
9a53637 @jedi4ever rake iso can now also work with ftp redirects to check size
authored
44 if uri.is_a?(URI::HTTP)
e3a2128 @miketheman style: spacing
miketheman authored
45 Net::HTTP.start(uri.host, uri.port) { |http|
9a53637 @jedi4ever rake iso can now also work with ftp redirects to check size
authored
46 response = http.head(uri.path)
47 }
48 unless response['location'].nil?
49 #puts "Redirecting to "+response['location']
e3a2128 @miketheman style: spacing
miketheman authored
50 url = response['location']
9a53637 @jedi4ever rake iso can now also work with ftp redirects to check size
authored
51 else
e3a2128 @miketheman style: spacing
miketheman authored
52 length = response['content-length']
53 found = true
9a53637 @jedi4ever rake iso can now also work with ftp redirects to check size
authored
54 end
55 elsif uri.is_a?(URI::FTP)
56 require 'net/ftp'
57 ftp = Net::FTP.new(uri.host)
58 ftp.login
59 begin
60 length = ftp.size(uri.path)
61 found = true
62 rescue Net::FTPReplyError => e
63 reply = e.message
e3a2128 @miketheman style: spacing
miketheman authored
64 err_code = reply[0, 3].to_i
9a53637 @jedi4ever rake iso can now also work with ftp redirects to check size
authored
65 unless err_code == 500 || err_code == 502
66 # other problem, raise
67 raise "Got ftp site but doesn't support size subcommand"
68 end
2357496 @jedi4ever added output to autotest and correct exit codes
authored
69 # fallback solution
9a53637 @jedi4ever rake iso can now also work with ftp redirects to check size
authored
70 end
71
4836077 @jedi4ever added iso check in rakefile temporary
authored
72 end
73 end
74 if length.to_i < 10000
75 puts definition.iso_src
9a53637 @jedi4ever rake iso can now also work with ftp redirects to check size
authored
76 puts "Incorrect length #{length.to_i}"
e3a2128 @miketheman style: spacing
miketheman authored
77 puts uri.host, uri.port, uri.path, response.code
4836077 @jedi4ever added iso check in rakefile temporary
authored
78 end
79 rescue Exception => ex
e3a2128 @miketheman style: spacing
miketheman authored
80 puts "Error" + ex.to_s + definition.iso_src
ff2c117 @jedi4ever Almost working
authored
81 end
4836077 @jedi4ever added iso check in rakefile temporary
authored
82 end
2f88ab9 @jedi4ever added export output
authored
83 end
d9e1240 @jedi4ever added rake blast command to test all templates
authored
84
2357496 @jedi4ever added output to autotest and correct exit codes
authored
85 desc 'Builds a template and runs validation.'
86 task :autotest, [:name] do |t, args|
87
88 # Disable color if the proper argument was passed
89 shell = ARGV.include?("--no-color") ? Thor::Shell::Basic.new : Thor::Base.shell.new
d9e1240 @jedi4ever added rake blast command to test all templates
authored
90
739472f @jedi4ever allow override of tcp and ssh timeout through environment variable VE…
authored
91 # We overrule all timeouts for tcp and ssh
80f7921 @jedi4ever no timeout , use VEEWEE_TIMEOUT to override
authored
92 #ENV['VEEWEE_TIMEOUT']='600'
739472f @jedi4ever allow override of tcp and ssh timeout through environment variable VE…
authored
93
e3a2128 @miketheman style: spacing
miketheman authored
94 ve = Veewee::Environment.new
2357496 @jedi4ever added output to autotest and correct exit codes
authored
95 ve.ui = ::Veewee::UI::Shell.new(ve, shell)
e3a2128 @miketheman style: spacing
miketheman authored
96 ve.templates.each do |name, template|
a7aefe8 @jedi4ever enable pattern to be used for autotesting
authored
97
98 # If pattern was given, only take the ones that match the pattern
2357496 @jedi4ever added output to autotest and correct exit codes
authored
99 unless args[:name].nil?
100 next unless name == args[:name]
a7aefe8 @jedi4ever enable pattern to be used for autotesting
authored
101 end
102
d9e1240 @jedi4ever added rake blast command to test all templates
authored
103 begin
e3a2128 @miketheman style: spacing
miketheman authored
104 ve.definitions.define("auto", name, { 'force' => true })
105 vd = ve.definitions["auto"]
106 box = ve.providers["virtualbox"].get_box("auto")
b4ac677 @jedi4ever renamed rake blast to rake autotests
authored
107 puts "AUTO: Building #{name}"
e3a2128 @miketheman style: spacing
miketheman authored
108 box.build({ "auto" => true, "force" => true, 'nogui' => true })
b4ac677 @jedi4ever renamed rake blast to rake autotests
authored
109 puts "AUTO: Validating #{name}"
3a13730 @jedi4ever pass tags for validate of basebox
authored
110 box.validate_vagrant({'tags' => ['virtualbox']})
b4ac677 @jedi4ever renamed rake blast to rake autotests
authored
111 puts "AUTO: Success #{name}"
d9e1240 @jedi4ever added rake blast command to test all templates
authored
112 box.destroy
113 rescue Exception => ex
b4ac677 @jedi4ever renamed rake blast to rake autotests
authored
114 puts "AUTO: Template #{name} failed - #{ex}"
739472f @jedi4ever allow override of tcp and ssh timeout through environment variable VE…
authored
115 if box.running?
116 begin
e3a2128 @miketheman style: spacing
miketheman authored
117 screenshot = "screenshot-auto-#{name}.png"
739472f @jedi4ever allow override of tcp and ssh timeout through environment variable VE…
authored
118 puts "AUTO: Taking snapshot #{screenshot}"
119 box.screenshot(screenshot)
120 rescue Veewee::Error => ex
121 puts "AUTO: Error taking screenshot"
122 end
123 end
2357496 @jedi4ever added output to autotest and correct exit codes
authored
124 exit -1
d9e1240 @jedi4ever added rake blast command to test all templates
authored
125 end
a7aefe8 @jedi4ever enable pattern to be used for autotesting
authored
126
d9e1240 @jedi4ever added rake blast command to test all templates
authored
127 end
128 end
Something went wrong with that request. Please try again.