auser-poolparty 1.3.16 → 1.3.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 3
3
- :patch: 16
3
+ :patch: 17
4
4
  :major: 1
data/bin/cloud CHANGED
@@ -33,6 +33,7 @@ EOS
33
33
  $DEBUGGING = true if command[:debug]
34
34
  $VERY_DEBUGGING = true if command[:very_debug]
35
35
 
36
+ PoolParty::Pool.command = command
36
37
  @loaded_pool = PoolParty::Pool.find_and_load_default_clouds_dot_rb(command[:clouds_dot_rb])
37
38
  @loaded_clouds = command[:name] ? [clouds[command[:name]]] : @loaded_pool.clouds.map {|name,cld|cld}
38
39
  @loaded_clouds.map do |cld|
@@ -16,6 +16,7 @@ shows output about the clouds.rb
16
16
  EOS
17
17
 
18
18
  short_desc "shows output about the clouds.rb"
19
+ opt :generate_graph, "Generate the dependency tree graph", :type => :string, :default => nil
19
20
 
20
21
  run do |command|
21
22
 
@@ -30,7 +31,18 @@ EOS
30
31
  "Running on: #{cld.cloud_provider_name}"
31
32
  ]
32
33
 
33
- print_msg(msg)
34
+ if verbose?
35
+ msg << [
36
+ "Keypair: #{cld.keypair.basename}"
37
+ ]
38
+ end
39
+
40
+ if command[:generate_graph]
41
+ vputs "Generating dependency graph at: #{command[:generate_graph]}"
42
+ cld.output_resources_graph('png', command[:generate_graph], {"fontsize" => 30})
43
+ end
44
+
45
+ print_msg(msg.flatten)
34
46
 
35
47
  end
36
48
 
@@ -42,10 +42,10 @@ module CloudProviders
42
42
  # "-i keyfile -o StrictHostKeyChecking=no -i keypair.to_s -l fred"
43
43
  def ssh_options(opts={})
44
44
  return @ssh_options if @ssh_options && opts.empty?
45
- ssh_options = {"-i" => keypair.full_filepath,
45
+ ssh_opts = {"-i" => keypair.full_filepath,
46
46
  "-o" =>"StrictHostKeyChecking=no"
47
47
  }.merge(opts)
48
- @ssh_options = ssh_options.collect{ |k,v| "#{k} #{v}"}.join(' ')
48
+ @ssh_options = ssh_opts.collect{ |k,v| "#{k} #{v}"}.join(' ')
49
49
  end
50
50
 
51
51
  def rsync( opts={} )
@@ -88,9 +88,12 @@ module CloudProviders
88
88
  err = stderr.readlines
89
89
  $stderr.write_nonblock(err)
90
90
  rescue SystemCallError => error
91
- $stderr.write_nonblock(stderr)
91
+ err = stderr.readlines
92
+ $stderr.write_nonblock(err)
92
93
  rescue EOFError => error
93
- # nothing
94
+ err = stderr.readlines
95
+ $stderr.write_nonblock(err)
96
+ # used to do nothing
94
97
  end
95
98
  end
96
99
  buf
@@ -105,6 +105,12 @@ module CloudProviders
105
105
  number_of_instances = o[:number_of_instances] || 1
106
106
  set_vars_from_options o
107
107
  raise StandardError.new("You must pass a keypair to launch an instance, or else you will not be able to login. options = #{o.inspect}") if !keypair_name
108
+ vputs("--- Launching ec2 instances")
109
+ vputs({
110
+ "image_id" => image_id,
111
+ "security_group" => security_group,
112
+ "keypair" => keypair.basename
113
+ })
108
114
  response_array = ec2(o).run_instances(image_id,
109
115
  min_count,
110
116
  number_of_instances,
@@ -45,6 +45,7 @@ module CloudProviders
45
45
  # public ip
46
46
  def associate_address(instance_id)
47
47
  new_ip = next_unused_elastic_ip
48
+ vputs("Assigning #{new_ip} to the ec2 instance #{instance_id}")
48
49
  ec2.associate_address(instance_id, new_ip)
49
50
  loop do
50
51
  if describe_instance(:instance_id => instance_id).public_ip == new_ip
@@ -62,20 +63,21 @@ module CloudProviders
62
63
  # intersection of the unused ips and those, find the first one available
63
64
  # and return that.
64
65
  def next_unused_elastic_ip
65
- if unusued_elastic_ips.empty?
66
+ if unused_elastic_ips.empty?
66
67
  nil
67
68
  else
68
- unusued_elastic_ips.first
69
+ vputs("Found an unused elastic ip: #{unused_elastic_ips.first}")
70
+ unused_elastic_ips.first
69
71
  end
70
72
  end
71
73
 
72
74
  private
73
75
 
74
76
  def all_elastic_ips
75
- elastic_ips.empty? ? [] : ec2.describe_addresses & elastic_ips
77
+ elastic_ips.empty? ? [] : ec2.describe_addresses.map {|a| a[:public_ip]} & elastic_ips
76
78
  end
77
79
 
78
- def unusued_elastic_ips
80
+ def unused_elastic_ips
79
81
  all_elastic_ips.select {|i| i[:instance_id] == nil }
80
82
  end
81
83
 
@@ -68,7 +68,7 @@ class Object
68
68
  # MESSAGES
69
69
  # Debugging output helpers
70
70
  def vputs(m="")
71
- puts "[INFO] -- #{m}" if verbose?
71
+ puts "[INFO] -- #{m.is_a?(String) ? m : m.inspect}" if verbose?
72
72
  end
73
73
  def dputs(m="")
74
74
  puts "[DEBUG] -- #{m.is_a?(String) ? m : m.inspect}" if debugging?
@@ -109,10 +109,10 @@ module DependencyResolvers
109
109
  end
110
110
 
111
111
  def apply_meta_notifies(resource, add)
112
- # The meta_notifies is a hash that looks like: {:file => [["pool_name", :reload]]}
112
+ # The meta_notifies is a hash that looks like: {:file => [["pool_name", :reload, :immediately]]}
113
113
  resource.meta_notifies.each do |ty, arr|
114
- arr.each do |nm, action|
115
- add << " notifies :#{action}, resources(:#{chef_safe_resource(ty)} => \"#{nm}\")"
114
+ arr.each do |nm, action, at_time|
115
+ add << " notifies :#{action}, resources(:#{chef_safe_resource(ty)} => \"#{nm}\"), :#{at_time}"
116
116
  end
117
117
  end
118
118
  end
@@ -7,10 +7,12 @@ class Keypair
7
7
  has_searchable_paths(:prepend_paths => [Dir.pwd, '/etc/poolparty/keys', "#{ENV["HOME"]}/.ssh/", "#{ENV["HOME"]}/.ec2/", ENV['EC2_CONFIG_DIR']])
8
8
 
9
9
  attr_accessor :filepath
10
+ attr_reader :extra_paths
10
11
 
11
12
  # Create a new key that defaults to id_rsa as the name.
12
- def initialize(fpath)
13
+ def initialize(fpath, extra_paths=[])
13
14
  @filepath = fpath
15
+ @extra_paths = extra_paths.map {|a| File.expand_path(a) }
14
16
  valid?
15
17
  end
16
18
 
@@ -27,10 +29,10 @@ class Keypair
27
29
  # Returns the full_filepath of the key. If a full filepath is passed, we just return the expanded filepath
28
30
  # for the keypair, otherwise query where it is against known locations
29
31
  def full_filepath
30
- @full_filepath ||= if File.file?(::File.expand_path(filepath))
32
+ @full_filepath ||= if File.file?(File.expand_path(filepath))
31
33
  ::File.expand_path(filepath)
32
34
  else
33
- search_in_known_locations(filepath)
35
+ search_in_known_locations(filepath, extra_paths)
34
36
  end
35
37
  end
36
38
  alias :to_s :full_filepath
@@ -128,47 +128,70 @@ module PoolParty
128
128
  # to create edges on the graph
129
129
  def resources_graph(force=false)
130
130
  return @resources_graph if @resources_graph && !force
131
- result = Digraph.new
131
+ result = Digraph.new
132
132
 
133
133
  create_graph(resources, nil, result)
134
134
 
135
- add_ordered_resources_to_result(resources, result)
136
-
137
135
  @resources_graph = result
138
136
  end
139
137
 
140
- # Add all the resources as edges of each other
141
- def add_ordered_resources_to_result(resources, result)
142
- arr_of_resources = resources.zip_offset(1)
143
-
144
- arr_of_resources.each do |first, second|
145
- result.add_edge!(first, second) unless result.edge?(first, second) or result.edge?(second, first)
146
- add_ordered_resources_to_result(first.resources, result)
147
- end
148
- end
149
-
150
138
  # Create the graph of resources. Blow up if a resource isn't found
151
139
  # that is required. If it is found, add it as an edge to the
152
140
  # dependency graph
153
141
  def create_graph(resources, on, result)
154
- resources.each_with_index do |resource, idx|
142
+ # add_ordered_resources_to_result(without_dependencies, result)
143
+ first_layer_of_ordered_resources = resources_without_dependencies.zip_offset(1)
144
+ first_layer_of_ordered_resources.each do |first, second|
145
+ result.add_edge!(first, second) unless second.nil? or result.edge?(first, second) or result.edge?(second, first)
146
+ end
147
+
148
+ resources_with_dependencies.each do |r|
155
149
 
156
- resource.dependencies.each do |dep_type, deps_array|
150
+ r.dependencies.each do |dep_type, deps_array|
157
151
  deps_array.each do |dep_name|
158
152
  dep = get_resource(dep_type, dep_name)
159
- raise PoolPartyError.create("ResourceNotFound", "A resource required for #{resource.has_method_name}(#{resource.name}) was not found: #{dep_type}(#{dep_name}). Please make sure you've specified this in your configuration.") unless dep
160
- result.add_edge!(dep, resource, dep.name) unless result.edge?(dep, resource) or result.edge?(resource, dep)
153
+ raise PoolPartyError.create("ResourceNotFound", "A resource required for #{dep_type}(#{dep_name}) was not found: #{dep_type}(#{dep_name}). Please make sure you've specified this in your configuration.") unless dep
154
+
155
+ unless result.edge?(dep, r) and result.edge?(r, dep)
156
+ existing_connections = result.adjacent(dep)
157
+ existing_connections.each {|c| result.remove_edge!(r, c) }
158
+
159
+ result.add_edge!(dep, r, dep.name)
160
+
161
+ existing_connections.each {|c| result.add_edge!(dep, c) }
162
+ end
163
+
161
164
  end
162
165
  end
163
-
166
+ end
167
+
168
+ all_resources.each_with_index do |resource, idx|
164
169
  if on
165
170
  result.add_edge!(resource, on, resource.name) unless result.edge?(resource, on) or result.edge?(on, resource)
166
171
  else
167
- result.add_vertex!(resource)
172
+ result.add_vertex!(resource) unless result.vertex?(resource)
168
173
  end
169
-
170
- create_graph(resource.resources, resource, result)
171
174
  end
175
+
176
+ result
177
+ end
178
+
179
+ # Add all the resources as edges of each other
180
+ def add_ordered_resources_to_result(resources, result)
181
+ arr_of_resources = resources.zip_offset(1)
182
+
183
+ arr_of_resources.each do |first, second|
184
+ result.add_edge!(first, second) unless result.edge?(first, second) or result.edge?(second, first)
185
+ add_ordered_resources_to_result(first.resources, result)
186
+ end
187
+ end
188
+
189
+ def resources_without_dependencies(r=all_resources)
190
+ r.reject {|a| !a.dependencies.empty? }
191
+ end
192
+
193
+ def resources_with_dependencies(r=all_resources)
194
+ r - resources_without_dependencies(r)
172
195
  end
173
196
 
174
197
  # All the dependencies that are required by this resource
@@ -14,8 +14,7 @@ module PoolParty
14
14
  :cloud_provider_name => :ec2,
15
15
  :dependency_resolver_name => nil,
16
16
  :os => nil,
17
- :bootstrap_script => nil,
18
- :ssh_options => {}
17
+ :bootstrap_script => nil
19
18
  )
20
19
 
21
20
  # Define what gets run on the callbacks
@@ -51,8 +50,8 @@ module PoolParty
51
50
  # returns an instance of Keypair
52
51
  # You can pass either a filename which will be searched for in ~/.ec2/ and ~/.ssh/
53
52
  # Or you can pass a full filepath
54
- def keypair(n=nil)
55
- @keypair ||= Keypair.new(n)
53
+ def keypair(n=nil, extra_paths=[])
54
+ @keypair ||= Keypair.new(n, extra_paths)
56
55
  end
57
56
 
58
57
  # Declare the CloudProvider for a cloud
@@ -290,17 +289,23 @@ Compiling cloud #{self.name} to #{tmp_path/"etc"/"#{dependency_resolver_name}"}
290
289
  if resources_graph.cyclic?
291
290
  cycles = []
292
291
 
293
- resources_graph.edges.each do |edge|
294
- if resources_graph.adjacent?(edge.source, edge.target) && resources_graph.adjacent?(edge.target, edge.source) && !cycles.include?(edge.source)
295
- cycles << "#{edge.source.class}(#{edge.source.name}) depends on #{edge.target.class}(#{edge.target.name})"
296
- end
292
+ cycles = resources_graph.find_cycle
293
+ cycle_string = cycles.map do |k,v|
294
+ "#{k} -> #{v}"
297
295
  end
296
+
297
+ filepath = "/tmp"
298
+ format = "png"
299
+ dotpath = "#{filepath}/dot.#{format}"
300
+ resources_graph.write_to_graphic_file(format, filepath)
301
+
302
+ `open #{dotpath}`
298
303
  msg =<<-EOE
299
304
 
300
305
  Your resource graph is cyclic. Two resources depend on each other, Cannot decide which resource
301
306
  to go first. Dying instead. Correct this and then try again.
302
307
 
303
- #{cycles.join("\n ")}
308
+ #{dotpath}
304
309
 
305
310
  Hint: You can see the resource graph by generating it with:
306
311
  cloud compile -g name
@@ -325,4 +330,25 @@ Compiling cloud #{self.name} to #{tmp_path/"etc"/"#{dependency_resolver_name}"}
325
330
  end
326
331
 
327
332
  end
328
- end
333
+ end
334
+
335
+ module GRATR
336
+ class Digraph
337
+
338
+ # Crappy n*n
339
+ def find_cycle(from=self)
340
+ return [] unless cyclic?
341
+ cyclic_cycle = []
342
+ forward_edge = Proc.new {|e| }
343
+ back_edge = Proc.new do |b|
344
+ cyclic_cycle = dfs_tree_from_vertex(b)
345
+ end
346
+ from.dfs({
347
+ :forward_edge => forward_edge,
348
+ :back_edge => back_edge
349
+ })
350
+ cyclic_cycle
351
+ end
352
+
353
+ end
354
+ end
@@ -14,8 +14,8 @@ module PoolParty
14
14
  self.__send__ :welcome_message
15
15
  steps.each {|c| self.__send__ c.to_sym }
16
16
  self.__send__ :closing_message
17
+ rescue SystemExit => e
17
18
  rescue Exception => e
18
- colored_say e.inspect
19
19
  colored_say exit_msg
20
20
  ensure
21
21
  Colors.reset!
@@ -2,9 +2,11 @@ module PoolParty
2
2
  module Installers
3
3
  class Ec2 < Installer
4
4
 
5
+ attr_reader :access_key, :secret_access_key, :ec2_directory
6
+
5
7
  def steps
6
8
  [
7
- :ask_for_ec2_directory, :ask_for_access_key, :ask_for_private_access_key,
9
+ :check_for_access_keys,
8
10
  :show_env_setup
9
11
  ]
10
12
  end
@@ -16,6 +18,30 @@ module PoolParty
16
18
  def self.description
17
19
  "Ec2 installer"
18
20
  end
21
+
22
+ def check_for_access_keys
23
+ msg = "
24
+ I've detected the following for your ec2 setup.
25
+ <line>
26
+ access key: #{CloudProviders::Ec2.default_access_key}
27
+ secret access key: #{CloudProviders::Ec2.default_secret_access_key}
28
+ certificate: #{CloudProviders::Ec2.default_cert}
29
+ private key: #{CloudProviders::Ec2.default_private_key}
30
+
31
+ <yellow>Are these values correct?</yellow>
32
+ "
33
+ v = choose msg, %W(Yes No)
34
+ if v == "Yes"
35
+ puts "Using the values above"
36
+ @access_key = CloudProviders::Ec2.default_access_key
37
+ @secret_access_key = CloudProviders::Ec2.default_secret_access_key
38
+ @ec2_directory = File.dirname(CloudProviders::Ec2.default_cert)
39
+ else
40
+ [
41
+ :ask_for_ec2_directory, :ask_for_access_key, :ask_for_private_access_key
42
+ ].each {|meth| self.send meth}
43
+ end
44
+ end
19
45
 
20
46
  def ask_for_access_key
21
47
  access_key_help =<<-EOV
@@ -25,7 +51,7 @@ EC2 uses an access key to identify you and allows you to start and stop instance
25
51
  access_key = <<-EOE
26
52
  What is your access key?
27
53
  EOE
28
- ask_with_help :message => access_key, :help => access_key_help do |k|
54
+ ask_with_help :message => access_key, :no_value => true, :help => access_key_help do |k|
29
55
  @access_key = k
30
56
  end
31
57
  end
@@ -62,11 +88,11 @@ What's path to your ec2 directory with your cert and pk files?
62
88
 
63
89
  Setup your environment:
64
90
 
65
- export EC2_ACCESS_KEY=#{@access_key}
66
- export EC2_SECRET_KEY=#{@secret_access_key}
91
+ export EC2_ACCESS_KEY=#{access_key}
92
+ export EC2_SECRET_KEY=#{secret_access_key}
67
93
 
68
- export EC2_PRIVATE_KEY=$(ls #{@ec2_directory}/pk-*.pem)
69
- export EC2_CERT=$(ls #{@ec2_directory}/cert-*.pem)
94
+ export EC2_PRIVATE_KEY=$(ls #{ec2_directory}/pk-*.pem)
95
+ export EC2_CERT=$(ls #{ec2_directory}/cert-*.pem)
70
96
 
71
97
  <line>
72
98
  EOE
@@ -9,6 +9,11 @@ module PoolParty
9
9
  :www_dir => "/var/www",
10
10
  :passenger_version => "2.2.5"
11
11
 
12
+
13
+ def name
14
+ "apache"
15
+ end
16
+
12
17
  def before_load
13
18
  installed_as_worker
14
19
  configs
@@ -146,7 +151,7 @@ PassengerRuby <%= @node[:languages][:ruby][:ruby_bin] %>
146
151
 
147
152
  def enable_default
148
153
  listen 80 # assumes no haproxy
149
- site "default-site", :template => File.dirname(__FILE__)/:apache2/"default-site.conf.erb"
154
+ site "default-site", :template => File.dirname(__FILE__)/:apache2/"default-site.conf.erb", :notifies => get_exec("reload-apache2"), :requires => get_exec("reload-apache2")
150
155
  end
151
156
 
152
157
  def config(name, temp)
@@ -169,7 +174,7 @@ PassengerRuby <%= @node[:languages][:ruby][:ruby_bin] %>
169
174
  else
170
175
  has_exec(:command => "/usr/sbin/a2dissite #{name}") do
171
176
  notifies get_exec("reload-apache2"), :run
172
- requires get_package("apache2")
177
+ requires get_exec("reload-apache2")
173
178
  only_if "/bin/sh -c \"[ -L /etc/apache2/sites-enabled/#{name} ] && [ /etc/apache2/sites-enabled/#{name} -ef /etc/apache2/sites-available/#{name}]\""
174
179
  end
175
180
  end
@@ -3,6 +3,7 @@ module PoolParty
3
3
  class VirtualHost < Apache
4
4
 
5
5
  default_options(
6
+ :name => nil,
6
7
  :port => 80,
7
8
  :www_dir => "/var/www",
8
9
  :www_user => "www-data"
@@ -60,14 +60,13 @@ module PoolParty
60
60
  :requires => get_package("erlang-dev")
61
61
 
62
62
  has_link :name => "collectd_dir",
63
- :to => "/var/lib/collectd/rrd/\#{`hostname -f`.chomp}", :source => "/var/lib/collectd/localhost",
64
- :requires => [get_package("collectd")]
63
+ :to => "/var/lib/collectd/rrd/\#{`hostname -f`.chomp}", :source => "/var/lib/collectd/localhost"
65
64
  end
66
65
 
67
66
  def run_if_needed
68
67
  has_exec "env GEN_CLUSTER_SEED_CONFIG=/etc/poolparty/seeds.conf HERMES_RRD_DIRECTORY=/var/lib/collectd/localhost #{remote_hermes_deployed_dir}/bin/erl -boot #{remote_hermes_deployed_dir}/releases/#{hermes_release_version}/start -noshell -detached",
69
68
  :not_if => "ps aux | grep -v grep | grep hermes | grep beam",
70
- :requires => [get_exec("install_hermes"), get_link("collectd_dir")]
69
+ :requires => [get_exec("install_hermes")]
71
70
  end
72
71
 
73
72
  private
@@ -27,6 +27,11 @@ module PoolParty
27
27
  end
28
28
  end
29
29
 
30
+ class << self;attr_accessor :command;end
31
+ def command
32
+ self.class.command
33
+ end
34
+
30
35
  # cloud
31
36
  # Define a cloud by a name and a block
32
37
  def cloud(name, o={}, &block)
@@ -40,11 +40,11 @@ module PoolParty
40
40
 
41
41
  # META FUNCTIONS
42
42
  # ALL RESOURCES HAVE THESE METHODS AVAILABLE
43
- def notifies(other_resources_hash, action_to_take=:reload)
43
+ def notifies(other_resources_hash, action_to_take=:reload, at_time=:delayed)
44
44
  @meta_notifies ||= {}
45
45
  other_resources_hash.each do |k,v|
46
46
  notifies_array = (@meta_notifies[k] ||= [])
47
- notifies_array << [v, action_to_take] unless notifies_array.include?([v, action_to_take])
47
+ notifies_array << [v, action_to_take, at_time] unless notifies_array.include?([v, action_to_take, at_time])
48
48
  # Implicitly add a require
49
49
  # requires(k => v)
50
50
  end
@@ -6,7 +6,7 @@ pool :poolparty do
6
6
 
7
7
  cloud :simple_cloud do
8
8
  os :centos
9
- keypair File.dirname(__FILE__)+"/../keys/test_key"
9
+ keypair "test_key", PoolParty.lib_dir+"/../test/fixtures/keys"
10
10
  has_file "/etc/motd", :content => "Simple"
11
11
  end
12
12
 
@@ -7,10 +7,15 @@ module PoolParty
7
7
  "fake_plugin"
8
8
  end
9
9
 
10
+ def name
11
+ "fake_plugin"
12
+ end
13
+
10
14
  def after_loaded
11
15
  has_file "/etc/my_configs/special_config" do
12
16
  requires get_directory("/etc/my_configs")
13
17
  end
18
+ has_directory("/etc/my_configs")
14
19
  end
15
20
 
16
21
  end
@@ -42,7 +42,11 @@ class ArrayTest < Test::Unit::TestCase
42
42
  arr = %w(a b c d e f)
43
43
  assert_equal [["a","b"],["b","c"],["c","d"],["d","e"],["e","f"]], arr.zip_offset(1)
44
44
  assert_equal [["a","b"],["b","c"],["c","d"],["d","e"]], arr.zip_offset(2)
45
+ assert_equal [["a","b"],["b","c"],["c","d"]], arr.zip_offset(3)
45
46
  assert_equal [["a","b"]], arr.zip_offset(5)
47
+
48
+ assert_equal [["a","b"],["b","c"],["c","d"],["d","e"]], %w(a b c d e).zip_offset(1)
49
+ assert_equal [["a","b"],["b","c"],["c","d"]], %w(a b c d e).zip_offset(2)
46
50
  end
47
51
 
48
52
  def test_rotate
@@ -29,7 +29,7 @@ class BaseTest < Test::Unit::TestCase
29
29
  assert_equal %w(c), @b.all_resources.map {|r| r.name }
30
30
  end
31
31
 
32
- def test_resource_graph
32
+ def test_resource_graph_generation
33
33
  assert_equal GRATR::Digraph, inst.resources_graph.class
34
34
  end
35
35
 
@@ -1,6 +1,7 @@
1
1
  require "#{File.dirname(__FILE__)}/../../test_helper"
2
2
  # require 'rr'
3
3
  stub_ec2_calls
4
+ include_fixture_resources
4
5
 
5
6
  class CloudTest < Test::Unit::TestCase
6
7
  # include RR::Adapters::TestUnit
@@ -97,6 +98,50 @@ class CloudTest < Test::Unit::TestCase
97
98
  assert_equal 'shutting-down', result.first.status
98
99
  end
99
100
 
101
+ def test_resource_graph_generation
102
+ pool "resource" do
103
+ cloud "graph" do
104
+
105
+ has_file "a", :content => "a"
106
+ has_file "g", :content => "g", :requires => get_file("c")
107
+ has_file "b", :content => "b"
108
+ has_file "c", :content => "c"
109
+ has_file "d", :content => "d"
110
+ has_file "e", :content => "e"
111
+ has_file "f", :content => "f"
112
+
113
+ end
114
+ end
115
+
116
+ # p clouds["graph"].ordered_resources.map {|a| a.name }
117
+ assert_equal %w(g), clouds["graph"].resources_with_dependencies.map {|a| a.name}
118
+ assert_equal %w(a b c d e f), clouds["graph"].resources_without_dependencies.map {|a| a.name }
119
+ assert_equal %w(a b c g d e f), clouds["graph"].ordered_resources.map {|a| a.name }
120
+
121
+ end
122
+
123
+ def test_deep_resources_graph_generation
124
+ pool "resource" do
125
+ cloud "graph2" do
126
+
127
+ os :ubuntu
128
+
129
+ keypair "test_key", fixtures_dir/"keys"
130
+
131
+ has_fake_plugin do
132
+ has_exec "a", :requires => get_file("b")
133
+ end
134
+ has_exec "c", :requires => get_exec("a")
135
+ has_file "b", :content => "b"
136
+ has_file "q", :requires => get_exec("a")
137
+
138
+ end
139
+ end
140
+
141
+ # Non-deterministic... figure out fix
142
+ # assert_equal ["fake_plugin", "/etc/my_configs", "/etc/my_configs/special_config", "b", "a", "q", "c"], clouds["graph2"].ordered_resources.map {|a| a.name}
143
+ end
144
+
100
145
  def test_run
101
146
  # WHAT?
102
147
  # result = @cloud.run('uptime')
@@ -139,13 +184,13 @@ class CloudTest < Test::Unit::TestCase
139
184
  pool "ssher" do
140
185
  cloud "custom" do
141
186
  keypair "test_key"
142
- ssh_options("-P" => "1992")
187
+ # ssh_options("-P" => "1992")
143
188
  end
144
189
  cloud "noneity" do
145
190
  keypair "test_key"
146
191
  end
147
192
  end
148
- assert_equal "1992", clouds["custom"].ssh_options["-P"]
193
+ # assert_equal "1992", clouds["custom"].ssh_options["-P"]
149
194
  end
150
195
 
151
196
 
@@ -197,7 +242,7 @@ class CloudTest < Test::Unit::TestCase
197
242
  clear!
198
243
  pool "monitoring2" do
199
244
  cloud "app_cloud" do
200
- keypair "test_key"
245
+ keypair "test_key", fixtures_dir/"keys"
201
246
  platform :ubuntu
202
247
  monitor "cpu-idle" do |c|
203
248
  vote_for(:expand) if c > 0.8
@@ -213,6 +258,6 @@ class CloudTest < Test::Unit::TestCase
213
258
  recipe_file = compile_dir/"recipes"/"default.rb"
214
259
  recipe_contents = open(recipe_file).read
215
260
 
216
- assert_match /install hermes/, recipe_contents
261
+ assert_match /install_hermes/, recipe_contents
217
262
  end
218
263
  end
@@ -32,4 +32,9 @@ class ApacheTest < Test::Unit::TestCase
32
32
  @base.compile_to(@cloud, test_dir)
33
33
  end
34
34
 
35
+ def test_resource_graph
36
+ # @cloud.resources_graph.write_to_graphic_file("png", "/tmp/graph")
37
+ assert !@cloud.resources_graph.cyclic?
38
+ end
39
+
35
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auser-poolparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.16
4
+ version: 1.3.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Lerner
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-09-20 00:00:00 -07:00
14
+ date: 2009-09-23 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies: []
17
17