cloud-toaster 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/{webapp/Gemfile → Gemfile} +5 -2
- data/README.md +14 -4
- data/VERSION +1 -1
- data/bin/toaster +8 -1
- data/chef/cookbooks/chef-solo-search/tests/test_search.rb +0 -1
- data/chef/cookbooks/lxc/attributes/install_ruby.rb +0 -1
- data/chef/cookbooks/toaster/recipes/testing.rb +0 -1
- data/lib/toaster/api.rb +5 -16
- data/lib/toaster/chef/chef_util.rb +43 -44
- data/lib/toaster/db/db.rb +0 -2
- data/lib/toaster/markup/markup_util.rb +0 -1
- data/lib/toaster/model/automation.rb +1 -2
- data/lib/toaster/model/automation_run.rb +0 -1
- data/lib/toaster/model/key_value_pair.rb +0 -2
- data/lib/toaster/model/state_change.rb +0 -2
- data/lib/toaster/model/task.rb +0 -1
- data/lib/toaster/model/task_execution.rb +0 -1
- data/lib/toaster/test/test_coverage_goal.rb +0 -2
- data/lib/toaster/test/test_generator.rb +1 -2
- data/lib/toaster/test/test_suite.rb +2 -3
- data/lib/toaster/toaster_app_service.rb +13 -1
- data/lib/toaster/util/util.rb +0 -1
- data/webapp/app/views/util/chef.html.erb +0 -1
- data/webapp/config/application.rb +0 -1
- data/webapp/config/boot.rb +1 -1
- data/webapp/log/development.log +587 -0
- metadata +45 -4
- data/webapp/Gemfile.lock +0 -237
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzY3ODY2Zjg5MDdjZWNmY2E1Yjg0OTJmNTJkZmEzMzNlYjhkNzkzOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTFmMmM2NDFiZGI2ZjIwZTNmZTQ5OWFkN2NmNGUyZWNmYzljNGY5Yw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmJmOTQ0MjM3N2I0NTk3Y2Q3MGUzYzUxMTZmNTI4ZDUyMzNmYTE2MWU2NGNj
|
10
|
+
MjNjNmY3NDdjNDAwNzZhYjk3NDIwOGViODE3YjZkNTgyZTdiMmZjYjJjMzgw
|
11
|
+
MzcwY2VhZGM2YmRhYWJlZTFiYzk4Yjk5YTBlNGZiMmVkODg0OGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDExZGI2NmQ5ZjRmYTk0MThkYjY0NmEyYjZmOWQyZGE1MWQ2ZmJkMmUzYzNh
|
14
|
+
NmUzNDEzNDhjOThmODAwNDk1OTU3ZThkMTgzZjcxOTExMjlhNzY3ZDU0YWRm
|
15
|
+
NTNmODEzMTU2NTVlYmE4NWQ3MzhkYjY5YzIxYzg0M2JiMTkyZjQ=
|
data/{webapp/Gemfile → Gemfile}
RENAMED
@@ -36,11 +36,14 @@ gem 'chef'
|
|
36
36
|
gem 'ohai'
|
37
37
|
gem 'rspec' # tests
|
38
38
|
gem 'ruby_parser' # parse Ruby code
|
39
|
+
gem 'bson'
|
39
40
|
gem 'bson_ext'
|
41
|
+
gem 'logger'
|
42
|
+
gem 'thor' # CLI generator
|
40
43
|
gem 'tidy' # tidy XML library
|
41
44
|
gem 'diffy' # comparing source files
|
42
45
|
gem 'mysql2' # for DB access
|
43
46
|
gem 'therubyracer' # required by execjs
|
44
47
|
gem 'railties'
|
45
|
-
gem 'activesupport'
|
46
|
-
gem '
|
48
|
+
gem 'activesupport', :require => "active_support"
|
49
|
+
gem 'activerecord', :require => "active_record"
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Automated testing of Infrastructure as Code automation scripts (e.g., Chef).
|
|
11
11
|
production servers or your own development machine! The reasons are twofold: first,
|
12
12
|
toaster requires a high amount of disk space for creating LXC containers, storing
|
13
13
|
test data etc; second, toaster relies on a comprehensive third-party software stack
|
14
|
-
(docker.io, LXC, Squid,
|
14
|
+
(docker.io, LXC, Squid, MySQL, Ruby, Ruby gems, etc), which might interfere with
|
15
15
|
and pollute the working environment of production machines.
|
16
16
|
|
17
17
|
* Target platform: Ubuntu 13.04
|
@@ -32,12 +32,12 @@ gem install --no-ri --no-rdoc toaster-1.0.0.gem
|
|
32
32
|
# (OR: install directly using rubygems.org: gem install cloud-toaster)
|
33
33
|
|
34
34
|
# toaster setup:
|
35
|
-
toaster setup # (setup testing host / utility host. Enter 192.168.100.2 as "
|
35
|
+
toaster setup # (setup testing host / utility host. Enter 192.168.100.2 as "db.host" parameter)
|
36
36
|
toaster proto ubuntu1 ubuntu # (initialize prototype container)
|
37
37
|
```
|
38
38
|
|
39
39
|
The code listing above illustrates the single-node installation. For multiple testing hosts,
|
40
|
-
set the
|
40
|
+
set the db.host configuration to the public IP/hostname of a central MySQL DB server to be
|
41
41
|
shared among all hosts.
|
42
42
|
|
43
43
|
## User Commands
|
@@ -45,10 +45,20 @@ shared among all hosts.
|
|
45
45
|
```
|
46
46
|
toaster web -d # (run the Web UI in a screen session in the background; web port 8080)
|
47
47
|
toaster agent # (start test agent in the background; web port 8385)
|
48
|
-
toaster spawn lxc1 ubuntu1
|
48
|
+
toaster spawn lxc1 ubuntu1 # (create container)
|
49
49
|
toaster clean # (clean containers)
|
50
50
|
```
|
51
51
|
|
52
|
+
## Notes and Known Issues
|
53
|
+
|
54
|
+
* If the command "toaster web" does not work for you (i.e., hangs), try the following:
|
55
|
+
|
56
|
+
```
|
57
|
+
cd /usr/local/rvm/gems/ruby-2.1.2/gems/cloud-toaster-1.1.2/webapp/ && bundle install
|
58
|
+
/usr/local/rvm/gems/ruby-2.1.2/gems/cloud-toaster-1.1.2/webapp/bin/rails server thin
|
59
|
+
# (assuming your gems directory is /usr/local/rvm/gems/ruby-2.1.2/gems)
|
60
|
+
```
|
61
|
+
|
52
62
|
## License
|
53
63
|
|
54
64
|
ToASTER is published under the Apache License version 2.0. See LICENSE.txt for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.3
|
data/bin/toaster
CHANGED
@@ -8,9 +8,16 @@
|
|
8
8
|
REQUIRED_CONFIGS = {"db.host" => "Database host"}
|
9
9
|
ROOT_DIR = File.join(File.dirname(File.expand_path(__FILE__)), "..")
|
10
10
|
|
11
|
+
# call bundler
|
12
|
+
require "rubygems"
|
13
|
+
require "bundler/setup"
|
14
|
+
# bug fix for ruby 1.9+
|
15
|
+
require 'dl/import'
|
16
|
+
DL::Importable = DL::Importer
|
17
|
+
Bundler.require(:default)
|
18
|
+
|
11
19
|
# requires
|
12
20
|
$LOAD_PATH << File.join(ROOT_DIR, "lib")
|
13
|
-
require "rubygems"
|
14
21
|
require "toaster/api.rb"
|
15
22
|
|
16
23
|
# util functions
|
@@ -34,7 +34,6 @@ set['ruby']['install_script']['ubuntu'] = <<-EOH
|
|
34
34
|
# The following line fails under Ubuntu quantal..
|
35
35
|
apt-get -y --force-yes install libc6-dev-amd6
|
36
36
|
apt-get -y --force-yes install libeditline-dev build-essential
|
37
|
-
# removed from list: package rubygems (automatically installs Ruby 1.8, which is undesired)
|
38
37
|
apt-get -y --force-yes install bison git autoconf automake patch make bzip2 zlib1g-dev sed libtool
|
39
38
|
apt-get -y --force-yes install less screen whiptail tar lsof unzip curl wget patch apt-utils make vim
|
40
39
|
|
@@ -134,7 +134,6 @@ $last_toaster_resource_name = "toaster_init_chef_listener"
|
|
134
134
|
ruby_block $last_toaster_resource_name do
|
135
135
|
block do
|
136
136
|
|
137
|
-
require 'rubygems'
|
138
137
|
begin
|
139
138
|
# the following two commands are used to load gems that were actually installed
|
140
139
|
# within this Chef run and are hence not yet available in this running instance.
|
data/lib/toaster/api.rb
CHANGED
@@ -61,7 +61,6 @@ module Toaster
|
|
61
61
|
long_desc "Example: #{CMD} spawn lxc1 ubuntu1"
|
62
62
|
def spawn(lxc_name, prototype_name)
|
63
63
|
|
64
|
-
distribution = "" # TODO remove ?
|
65
64
|
prototype_name = "prototype_#{prototype_name}"
|
66
65
|
|
67
66
|
prototype_dir = "/lxc/#{prototype_name}"
|
@@ -91,9 +90,6 @@ module Toaster
|
|
91
90
|
"cont": {
|
92
91
|
"name": "#{lxc_name}",
|
93
92
|
"ip_address": "#{guest_ip}"
|
94
|
-
},
|
95
|
-
"bare_os": {
|
96
|
-
"distribution": "#{distribution}"
|
97
93
|
}
|
98
94
|
}
|
99
95
|
}
|
@@ -283,10 +279,12 @@ module Toaster
|
|
283
279
|
#option :detached, :type => :boolean, :aliases => ["-d"]
|
284
280
|
def web(detached=false)
|
285
281
|
puts "INFO: Starting Web application on port 8080"
|
282
|
+
dir = File.join(File.dirname(__FILE__), "..", "..")
|
283
|
+
cmd = "cd \"#{dir}\" && webapp/bin/rails server thin"
|
286
284
|
if detached
|
287
|
-
exec("screen -d -m
|
285
|
+
Kernel::exec("screen -d -m #{cmd}")
|
288
286
|
else
|
289
|
-
exec("
|
287
|
+
Kernel::exec("#{cmd}")
|
290
288
|
end
|
291
289
|
end
|
292
290
|
|
@@ -345,12 +343,6 @@ module Toaster
|
|
345
343
|
end
|
346
344
|
end
|
347
345
|
|
348
|
-
def exec(command)
|
349
|
-
out = `#{command}`
|
350
|
-
puts out
|
351
|
-
return out
|
352
|
-
end
|
353
|
-
|
354
346
|
}
|
355
347
|
|
356
348
|
####################
|
@@ -390,7 +382,7 @@ module Toaster
|
|
390
382
|
def init_db_connection()
|
391
383
|
Toaster::Config.init_db_connection()
|
392
384
|
end
|
393
|
-
def start_stop_container(action, lxc_name
|
385
|
+
def start_stop_container(action, lxc_name)
|
394
386
|
|
395
387
|
if !Dir.exist?("/lxc/#{lxc_name}")
|
396
388
|
puts "ERROR: Container directory does not exist: /lxc/#{lxc_name}"
|
@@ -412,9 +404,6 @@ module Toaster
|
|
412
404
|
"name": "#{lxc_name}",
|
413
405
|
"ip_address": "#{guest_ip}",
|
414
406
|
"proxy_ip": "#{proxy_ip}"
|
415
|
-
},
|
416
|
-
"bare_os": {
|
417
|
-
"distribution": "#{distribution}"
|
418
407
|
}
|
419
408
|
}
|
420
409
|
}
|
@@ -4,7 +4,6 @@
|
|
4
4
|
# Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
|
5
5
|
#
|
6
6
|
|
7
|
-
require 'rubygems'
|
8
7
|
require 'chef/log'
|
9
8
|
require 'chef/run_context'
|
10
9
|
require 'chef/client'
|
@@ -243,49 +242,49 @@ module Toaster
|
|
243
242
|
end
|
244
243
|
|
245
244
|
# TODO remove?
|
246
|
-
def self.download_cookbook_version1(name, version="latest",
|
247
|
-
target_dir=@@DEFAULT_COOKBOOKS_DIR, quiet=false, num_attempts=2)
|
248
|
-
|
249
|
-
link = get_cookbook_download_link(name, version)
|
250
|
-
|
251
|
-
`mkdir -p '#{target_dir}'` if !File.exist?(target_dir)
|
252
|
-
tgz_file = File.join(target_dir, "#{name}.tgz")
|
253
|
-
tar_file = File.join(target_dir, "#{name}.tar")
|
254
|
-
File.delete(tar_file) if File.exist?(tar_file)
|
255
|
-
cookbook_dir = File.join(target_dir, name)
|
256
|
-
if @@create_backups
|
257
|
-
if File.exist?(cookbook_dir) && !File.exist?("#{cookbook_dir}.bak")
|
258
|
-
`mv #{cookbook_dir} #{cookbook_dir}.bak`
|
259
|
-
end
|
260
|
-
end
|
261
|
-
while num_attempts > 0
|
262
|
-
`rm -rf #{cookbook_dir}`
|
263
|
-
if !quiet
|
264
|
-
puts "DEBUG: Downloading '#{link}' to #{target_dir}"
|
265
|
-
end
|
266
|
-
error = false
|
267
|
-
`wget #{link} -O #{tgz_file} > /dev/null 2>&1`
|
268
|
-
error ||= $?.exitstatus != 0
|
269
|
-
out = `cd #{target_dir} && tar zxf #{name}.tgz`
|
270
|
-
# tar reports status code 2 in case of error...
|
271
|
-
if $?.exitstatus > 1
|
272
|
-
# sometimes, the files are in tar format,
|
273
|
-
# not in tgz format - let's give it a try!
|
274
|
-
puts "DEBUG: 'cd #{target_dir} && tar zxf #{name}.tgz' returned exit code #{$?.exitstatus}, trying to extract as tar file..."
|
275
|
-
full_file = "#{target_dir}/#{name}.tgz"
|
276
|
-
puts "DEBUG: File #{full_file} exists: #{File.exist?(full_file)}}"
|
277
|
-
out += `cd #{target_dir} && cp #{name}.tgz #{name}.tar`
|
278
|
-
out += `cd #{target_dir} && tar xf #{name}.tar`
|
279
|
-
end
|
280
|
-
error ||= $?.exitstatus > 1
|
281
|
-
break if !error
|
282
|
-
puts "WARN: Could not download/extract #{link} to #{target_dir} . Remaining attempts: #{num_attempts}"
|
283
|
-
num_attempts -= 1
|
284
|
-
sleep 2
|
285
|
-
end
|
286
|
-
|
287
|
-
return out
|
288
|
-
end
|
245
|
+
# def self.download_cookbook_version1(name, version="latest",
|
246
|
+
# target_dir=@@DEFAULT_COOKBOOKS_DIR, quiet=false, num_attempts=2)
|
247
|
+
#
|
248
|
+
# link = get_cookbook_download_link(name, version)
|
249
|
+
#
|
250
|
+
# `mkdir -p '#{target_dir}'` if !File.exist?(target_dir)
|
251
|
+
# tgz_file = File.join(target_dir, "#{name}.tgz")
|
252
|
+
# tar_file = File.join(target_dir, "#{name}.tar")
|
253
|
+
# File.delete(tar_file) if File.exist?(tar_file)
|
254
|
+
# cookbook_dir = File.join(target_dir, name)
|
255
|
+
# if @@create_backups
|
256
|
+
# if File.exist?(cookbook_dir) && !File.exist?("#{cookbook_dir}.bak")
|
257
|
+
# `mv #{cookbook_dir} #{cookbook_dir}.bak`
|
258
|
+
# end
|
259
|
+
# end
|
260
|
+
# while num_attempts > 0
|
261
|
+
# `rm -rf #{cookbook_dir}`
|
262
|
+
# if !quiet
|
263
|
+
# puts "DEBUG: Downloading '#{link}' to #{target_dir}"
|
264
|
+
# end
|
265
|
+
# error = false
|
266
|
+
# `wget #{link} -O #{tgz_file} > /dev/null 2>&1`
|
267
|
+
# error ||= $?.exitstatus != 0
|
268
|
+
# out = `cd #{target_dir} && tar zxf #{name}.tgz`
|
269
|
+
# # tar reports status code 2 in case of error...
|
270
|
+
# if $?.exitstatus > 1
|
271
|
+
# # sometimes, the files are in tar format,
|
272
|
+
# # not in tgz format - let's give it a try!
|
273
|
+
# puts "DEBUG: 'cd #{target_dir} && tar zxf #{name}.tgz' returned exit code #{$?.exitstatus}, trying to extract as tar file..."
|
274
|
+
# full_file = "#{target_dir}/#{name}.tgz"
|
275
|
+
# puts "DEBUG: File #{full_file} exists: #{File.exist?(full_file)}}"
|
276
|
+
# out += `cd #{target_dir} && cp #{name}.tgz #{name}.tar`
|
277
|
+
# out += `cd #{target_dir} && tar xf #{name}.tar`
|
278
|
+
# end
|
279
|
+
# error ||= $?.exitstatus > 1
|
280
|
+
# break if !error
|
281
|
+
# puts "WARN: Could not download/extract #{link} to #{target_dir} . Remaining attempts: #{num_attempts}"
|
282
|
+
# num_attempts -= 1
|
283
|
+
# sleep 2
|
284
|
+
# end
|
285
|
+
#
|
286
|
+
# return out
|
287
|
+
# end
|
289
288
|
|
290
289
|
def self.download_cookbook_url(link, target_dir=@@DEFAULT_COOKBOOKS_DIR,
|
291
290
|
quiet=false, num_attempts=2)
|
data/lib/toaster/db/db.rb
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
# Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
|
3
3
|
#
|
4
4
|
|
5
|
-
#require "toaster/model/automation_run"
|
6
|
-
#require "toaster/model/task"
|
7
5
|
require 'active_record'
|
8
6
|
require "toaster/markup/markup_util"
|
9
7
|
require "toaster/chef/chef_util"
|
@@ -86,6 +84,7 @@ module Toaster
|
|
86
84
|
return nil
|
87
85
|
end
|
88
86
|
|
87
|
+
# TODO: fix/revise
|
89
88
|
def get_seen_attribute_values()
|
90
89
|
map = {}
|
91
90
|
attribute_names = self.class.get_attribute_array_names(automation_attributes,"")
|
data/lib/toaster/model/task.rb
CHANGED
@@ -139,11 +139,10 @@ module Toaster
|
|
139
139
|
DB.find_activerecord(TestSuite, criteria)
|
140
140
|
end
|
141
141
|
|
142
|
-
# TODO
|
143
142
|
def query_unfinished_tests
|
144
143
|
return TestCase.find(
|
145
|
-
|
146
|
-
|
144
|
+
:automation_run => nil,
|
145
|
+
:test_suite_id => id
|
147
146
|
)
|
148
147
|
end
|
149
148
|
|
@@ -1,7 +1,18 @@
|
|
1
1
|
|
2
2
|
$LOAD_PATH << File.join(File.expand_path(File.dirname(__FILE__)), "..")
|
3
3
|
|
4
|
+
|
4
5
|
require 'rubygems'
|
6
|
+
require 'bundler/setup'
|
7
|
+
|
8
|
+
# bug fix for ruby 1.9+
|
9
|
+
require 'dl/import'
|
10
|
+
DL::Importable = DL::Importer
|
11
|
+
|
12
|
+
# call bundler
|
13
|
+
Bundler.require(:default)
|
14
|
+
|
15
|
+
|
5
16
|
require 'toaster/util/config'
|
6
17
|
require 'toaster/util/docker'
|
7
18
|
|
@@ -44,7 +55,7 @@ end
|
|
44
55
|
$stdout = MyThreadOut.new
|
45
56
|
|
46
57
|
## capture stdout using thread-local variable
|
47
|
-
require 'stringio'
|
58
|
+
#require 'stringio'
|
48
59
|
module Kernel
|
49
60
|
def capture_stdout(&block)
|
50
61
|
out = StringIO.new
|
@@ -134,6 +145,7 @@ if ARGV.include?("do_start_service")
|
|
134
145
|
puts "Starting service on port #{$service_port}"
|
135
146
|
Toaster::Config.init_db_connection()
|
136
147
|
server = ToasterAppService.new($service_port, "0.0.0.0")
|
148
|
+
|
137
149
|
# client = ToasterApp.new()
|
138
150
|
# client.runtest("2285f8539f6c48873")
|
139
151
|
# client.runtests("88056bebc7e384cac")
|