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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTU1MTk3N2RlMjAxZGRlNzNlNmIxNDYwMjY1NzU1MmJkYTBhZmI0NA==
4
+ MzY3ODY2Zjg5MDdjZWNmY2E1Yjg0OTJmNTJkZmEzMzNlYjhkNzkzOA==
5
5
  data.tar.gz: !binary |-
6
- YWVjOTAyNTcwYmEwY2U3ZTkyOTZkOWRjOTFjOTUxM2JlNTU1MmZkMA==
6
+ MTFmMmM2NDFiZGI2ZjIwZTNmZTQ5OWFkN2NmNGUyZWNmYzljNGY5Yw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2JlYWRmNzM3ZDczNjdmM2VmNWQxMmVhMjBkOWY2ZGQ5YmI0MDhjZjQ3YzM0
10
- ZGZlZDUxNjQyMTY0Yjg3ZjBmYjczMzlmNTRlYzY0MmUzNmVlYjYyYzNkYmUz
11
- MWUwZGM3MGZlODg3ZmVmNTA3NWYzZDFjN2QwNDIxZjFiZGEyMzM=
9
+ NmJmOTQ0MjM3N2I0NTk3Y2Q3MGUzYzUxMTZmNTI4ZDUyMzNmYTE2MWU2NGNj
10
+ MjNjNmY3NDdjNDAwNzZhYjk3NDIwOGViODE3YjZkNTgyZTdiMmZjYjJjMzgw
11
+ MzcwY2VhZGM2YmRhYWJlZTFiYzk4Yjk5YTBlNGZiMmVkODg0OGE=
12
12
  data.tar.gz: !binary |-
13
- YzYxODU2ZWUxOTEwMmRlN2QxZTJmYWIwZmFmOWMwMDVjM2E0OGZmZmE3NTM1
14
- ZGZlMzg4MDIzMTUwNTEwOTVlMjZkMTY0ZDMxMmFmMzRkMzhhNDMyMGQ1N2Nl
15
- NDEzM2I4ODBhOTllMTk2YWNkNmIzNzkzOWVjMzZkODgxZDhlMmU=
13
+ NDExZGI2NmQ5ZjRmYTk0MThkYjY0NmEyYjZmOWQyZGE1MWQ2ZmJkMmUzYzNh
14
+ NmUzNDEzNDhjOThmODAwNDk1OTU3ZThkMTgzZjcxOTExMjlhNzY3ZDU0YWRm
15
+ NTNmODEzMTU2NTVlYmE4NWQ3MzhkYjY5YzIxYzg0M2JiMTkyZjQ=
@@ -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 'bundler'
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, MongoDB, Ruby, Ruby gems, etc), which might interfere with
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 "mongodb.host" parameter)
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 mongodb.host configuration to the public IP/hostname of a central MongoDB server to be
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 # (create container)
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.2
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
@@ -17,7 +17,6 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "rubygems"
21
20
  require "test/unit"
22
21
  require "chef"
23
22
 
@@ -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 ruby #{ROOT_DIR}/lib/toaster/web_ui.rb")
285
+ Kernel::exec("screen -d -m #{cmd}")
288
286
  else
289
- exec("ruby #{ROOT_DIR}/lib/toaster/web_ui.rb")
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, distribution="")
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
@@ -9,8 +9,6 @@ require "toaster/util/util"
9
9
 
10
10
  module Toaster
11
11
 
12
- # TODO deprecated, remove?
13
-
14
12
  class DB
15
13
 
16
14
  class << self;
@@ -4,7 +4,6 @@
4
4
  # Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
5
5
  #
6
6
 
7
- require 'rubygems'
8
7
  require 'json'
9
8
  require 'rexml/document'
10
9
  require 'hashdiff'
@@ -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,"")
@@ -4,7 +4,6 @@
4
4
  # Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
5
5
  #
6
6
 
7
- require "active_record"
8
7
  require "toaster/model/automation"
9
8
  require "toaster/model/task_execution"
10
9
  require "toaster/model/run_attribute"
@@ -2,8 +2,6 @@
2
2
  # Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
3
3
  #
4
4
 
5
- require "active_record"
6
-
7
5
  module Toaster
8
6
  class KeyValuePair < ActiveRecord::Base
9
7
  self.inheritance_column = :type
@@ -3,8 +3,6 @@
3
3
  # Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
4
4
  #
5
5
 
6
- require "active_record"
7
-
8
6
  module Toaster
9
7
 
10
8
  class StateChange < ActiveRecord::Base
@@ -4,7 +4,6 @@
4
4
  # Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
5
5
  #
6
6
 
7
- require "active_record"
8
7
  require "toaster/util/util"
9
8
  require "toaster/model/task_execution"
10
9
  require "toaster/model/task_parameter"
@@ -4,7 +4,6 @@
4
4
  # Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
5
5
  #
6
6
 
7
- require "active_record"
8
7
  require "toaster/model/task"
9
8
  require "toaster/model/state"
10
9
  require "toaster/model/state_change"
@@ -4,8 +4,6 @@
4
4
  # Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
5
5
  #
6
6
 
7
- require "active_record"
8
-
9
7
  include Toaster
10
8
 
11
9
  module Toaster
@@ -136,9 +136,8 @@ module Toaster
136
136
  end
137
137
 
138
138
  def gen_test_each_transition()
139
- result = []
140
139
  # TODO
141
- return result
140
+ raise "not implemented"
142
141
  end
143
142
 
144
143
  private
@@ -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
- {"automation_run_id" => nil, "test_suite_id" => id},
146
- {"test_suite" => self}
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")