poolparty 1.3.13 → 1.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/bin/cloud-compile +1 -0
- data/lib/cloud_providers/connections.rb +3 -2
- data/lib/cloud_providers/ec2/ec2.rb +2 -2
- data/lib/cloud_providers/vmware/vmware.rb +3 -0
- data/lib/poolparty/cloud.rb +6 -4
- data/lib/poolparty/installers/ec2.rb +2 -14
- data/lib/poolparty/plugins/apache.rb +30 -9
- data/lib/poolparty/plugins/apache2/passenger_site.rb +1 -1
- data/lib/poolparty/pool.rb +1 -1
- data/test/fixtures/clouds/fake_clouds.rb +2 -2
- data/test/fixtures/clouds/simple_cloud.rb +1 -1
- data/test/fixtures/resources/fake_subclassed_plugin.rb +19 -0
- data/test/lib/cloud_providers/ec2/ec2_instance_test.rb +17 -8
- data/test/lib/cloud_providers/ec2/ec2_test.rb +15 -11
- data/test/lib/poolparty/cloud_test.rb +47 -32
- data/test/lib/poolparty/pool_test.rb +3 -3
- data/test/lib/provision/bootstrapper_test.rb +0 -25
- data/test/test_helper.rb +0 -1
- metadata +3 -2
data/VERSION.yml
CHANGED
data/bin/cloud-compile
CHANGED
|
@@ -41,10 +41,11 @@ module CloudProviders
|
|
|
41
41
|
# {'-i'=>'keyfile, '-l' => 'fred' } would become
|
|
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
46
|
"-o" =>"StrictHostKeyChecking=no"
|
|
46
47
|
}.merge(opts)
|
|
47
|
-
|
|
48
|
+
@ssh_options = ssh_options.collect{ |k,v| "#{k} #{v}"}.join(' ')
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
def rsync( opts={} )
|
|
@@ -102,11 +102,12 @@ module CloudProviders
|
|
|
102
102
|
|
|
103
103
|
# Start a new instance with the given options
|
|
104
104
|
def run_instance(o={})
|
|
105
|
+
number_of_instances = o[:number_of_instances] || 1
|
|
105
106
|
set_vars_from_options o
|
|
106
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
|
|
107
108
|
response_array = ec2(o).run_instances(image_id,
|
|
108
109
|
min_count,
|
|
109
|
-
|
|
110
|
+
number_of_instances,
|
|
110
111
|
security_group,
|
|
111
112
|
keypair.basename,
|
|
112
113
|
user_data,
|
|
@@ -123,7 +124,6 @@ module CloudProviders
|
|
|
123
124
|
|
|
124
125
|
after_run_instance(instances)
|
|
125
126
|
|
|
126
|
-
#FIXME: This needs to deal with the case when an array is returned if max_instances > 1
|
|
127
127
|
instances.first
|
|
128
128
|
end
|
|
129
129
|
|
data/lib/poolparty/cloud.rb
CHANGED
|
@@ -14,7 +14,8 @@ module PoolParty
|
|
|
14
14
|
:cloud_provider_name => :ec2,
|
|
15
15
|
:dependency_resolver_name => nil,
|
|
16
16
|
:os => nil,
|
|
17
|
-
:bootstrap_script => nil
|
|
17
|
+
:bootstrap_script => nil,
|
|
18
|
+
:ssh_options => {}
|
|
18
19
|
)
|
|
19
20
|
|
|
20
21
|
# Define what gets run on the callbacks
|
|
@@ -29,7 +30,7 @@ module PoolParty
|
|
|
29
30
|
def before_compile
|
|
30
31
|
add_monitoring_stack_if_needed
|
|
31
32
|
|
|
32
|
-
validate_all_resources
|
|
33
|
+
validate_all_resources unless ENV["POOLPARTY_NO_VALIDATION"]
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
# Freeze the cloud_name so we can't modify it at all, set the plugin_directory
|
|
@@ -59,7 +60,8 @@ module PoolParty
|
|
|
59
60
|
def using(provider_symbol, o={}, &block)
|
|
60
61
|
return @cloud_provider if @cloud_provider
|
|
61
62
|
self.cloud_provider_name = provider_symbol
|
|
62
|
-
cloud_provider(o, &block)
|
|
63
|
+
cloud_provider(ssh_options.merge(o), &block)
|
|
64
|
+
cloud_provider.keypair(keypair)
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
# Cloud provider methods
|
|
@@ -79,7 +81,7 @@ module PoolParty
|
|
|
79
81
|
return @cloud_provider if @cloud_provider
|
|
80
82
|
klass_name = "CloudProviders::#{cloud_provider_name}".classify
|
|
81
83
|
if provider_klass = CloudProviders.all.detect {|k| k.to_s == klass_name }
|
|
82
|
-
opts.merge!(:cloud => self, :keypair_name => self.keypair.
|
|
84
|
+
opts.merge!(:cloud => self, :keypair_name => self.keypair.full_filepath)
|
|
83
85
|
@cloud_provider = provider_klass.new(dsl_options.merge(opts), &block)
|
|
84
86
|
else
|
|
85
87
|
raise PoolParty::PoolPartyError.create("UnknownCloudProviderError", "Unknown cloud_provider: #{cloud_provider_name}")
|
|
@@ -4,7 +4,7 @@ module PoolParty
|
|
|
4
4
|
|
|
5
5
|
def steps
|
|
6
6
|
[
|
|
7
|
-
:
|
|
7
|
+
:ask_for_ec2_directory, :ask_for_access_key, :ask_for_private_access_key,
|
|
8
8
|
:show_env_setup
|
|
9
9
|
]
|
|
10
10
|
end
|
|
@@ -16,19 +16,7 @@ module PoolParty
|
|
|
16
16
|
def self.description
|
|
17
17
|
"Ec2 installer"
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
def find_ec2_directory
|
|
21
|
-
msg = "We found the following vmware files in the default vmware directory.\nChoose one of these to use as your vmrun file or select other\n<line>"
|
|
22
|
-
|
|
23
|
-
directories = {}
|
|
24
|
-
default_ec2_directories.each_with_index do |file,idx|
|
|
25
|
-
directories.merge!(idx+1 => file)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
base = choose(msg, directories)
|
|
29
|
-
@ec2_directory = base == :other ? ask_for_ec2_directory : base
|
|
30
|
-
end
|
|
31
|
-
|
|
19
|
+
|
|
32
20
|
def ask_for_access_key
|
|
33
21
|
access_key_help =<<-EOV
|
|
34
22
|
EC2 uses an access key to identify you and allows you to start and stop instances.
|
|
@@ -7,7 +7,7 @@ module PoolParty
|
|
|
7
7
|
default_options :port => 80,
|
|
8
8
|
:www_user => 'www-data',
|
|
9
9
|
:www_dir => "/var/www",
|
|
10
|
-
:passenger_version => "2.2.
|
|
10
|
+
:passenger_version => "2.2.5"
|
|
11
11
|
|
|
12
12
|
def before_load
|
|
13
13
|
installed_as_worker
|
|
@@ -39,6 +39,13 @@ module PoolParty
|
|
|
39
39
|
def install_passenger
|
|
40
40
|
enable_passenger
|
|
41
41
|
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
|
|
45
|
+
# PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5
|
|
46
|
+
# PassengerRuby /usr/bin/ruby1.8
|
|
47
|
+
#
|
|
48
|
+
# creating this thing below may not be being run b/c it checks for the passenger.conf which isn't really a good test
|
|
42
49
|
|
|
43
50
|
def enable_passenger
|
|
44
51
|
unless @enable_passenger
|
|
@@ -46,7 +53,7 @@ module PoolParty
|
|
|
46
53
|
has_package "build-essential"
|
|
47
54
|
has_package "apache2-prefork-dev"
|
|
48
55
|
has_gem_package "fastthread"
|
|
49
|
-
has_gem_package "passenger"
|
|
56
|
+
has_gem_package "passenger", :version => passenger_version
|
|
50
57
|
passenger_configs
|
|
51
58
|
|
|
52
59
|
has_exec "install_passenger_script" do
|
|
@@ -55,8 +62,8 @@ module PoolParty
|
|
|
55
62
|
requires get_exec("restart-apache2")
|
|
56
63
|
requires get_package("apache2")
|
|
57
64
|
requires get_gem_package("passenger")
|
|
58
|
-
not_if "test -
|
|
59
|
-
creates lambda { "
|
|
65
|
+
not_if "test -e \#{node[:passenger_site][:passenger_module_path]}"
|
|
66
|
+
# creates lambda { "passenger_site[:passenger_module_path]" }
|
|
60
67
|
end
|
|
61
68
|
|
|
62
69
|
@enable_passenger = true
|
|
@@ -65,15 +72,26 @@ module PoolParty
|
|
|
65
72
|
|
|
66
73
|
def passenger_configs
|
|
67
74
|
unless @passenger_configs
|
|
75
|
+
|
|
76
|
+
# requires doesn't work for has_variable?
|
|
68
77
|
|
|
78
|
+
# has_variable("passenger_version", passenger_version)
|
|
79
|
+
# has_variable("passenger_root_path", "\#{languages[:ruby][:gems_dir]}/gems/passenger-#{passenger_version}",
|
|
80
|
+
# :requires => get_variable("passenger_version"))
|
|
81
|
+
# has_variable("passenger_module_path", "\#{passenger_site[:passenger_root_path]}/ext/apache2/mod_passenger.so",
|
|
82
|
+
# :requires => get_variable("passenger_root_path"))
|
|
83
|
+
|
|
69
84
|
has_variable("passenger_version", passenger_version)
|
|
70
|
-
has_variable("passenger_root_path", "\#{languages[:ruby][:gems_dir]}/gems/passenger-#{passenger_version}"
|
|
71
|
-
|
|
85
|
+
has_variable("passenger_root_path", "\#{languages[:ruby][:gems_dir]}/gems/passenger-#{passenger_version}",
|
|
86
|
+
:requires => get_variable("passenger_version"))
|
|
87
|
+
has_variable("passenger_module_path", "\#{languages[:ruby][:gems_dir]}/gems/passenger-#{passenger_version}/ext/apache2/mod_passenger.so",
|
|
88
|
+
:requires => get_variable("passenger_root_path"))
|
|
72
89
|
|
|
73
90
|
has_file(:name => "/etc/apache2/mods-available/passenger.load") do
|
|
74
91
|
content <<-eof
|
|
75
92
|
LoadModule passenger_module <%= @node[:passenger_site][:passenger_module_path] %>
|
|
76
93
|
eof
|
|
94
|
+
requires get_exec("install_passenger_script")
|
|
77
95
|
end
|
|
78
96
|
|
|
79
97
|
has_file(:name => "/etc/apache2/mods-available/passenger.conf") do
|
|
@@ -81,9 +99,10 @@ LoadModule passenger_module <%= @node[:passenger_site][:passenger_module_path] %
|
|
|
81
99
|
PassengerRoot <%= @node[:passenger_site][:passenger_root_path] %>
|
|
82
100
|
PassengerRuby <%= @node[:languages][:ruby][:ruby_bin] %>
|
|
83
101
|
eof
|
|
102
|
+
requires get_exec("install_passenger_script")
|
|
84
103
|
end
|
|
85
104
|
|
|
86
|
-
present_apache_module(:passenger)
|
|
105
|
+
present_apache_module(:passenger, {:requires => get_file("/etc/apache2/mods-available/passenger.load")})
|
|
87
106
|
@passenger_configs = true
|
|
88
107
|
end
|
|
89
108
|
end
|
|
@@ -159,9 +178,9 @@ PassengerRuby <%= @node[:languages][:ruby][:ruby_bin] %>
|
|
|
159
178
|
def install_site(name, opts={})
|
|
160
179
|
sitename = name
|
|
161
180
|
|
|
162
|
-
opts.merge!(:name => "/etc/apache2/sites-available/#{sitename}")
|
|
181
|
+
opts.merge!(:name => "/etc/apache2/sites-available/#{sitename}", :requires => get_package("apache2"))
|
|
163
182
|
has_directory(:name => "/etc/apache2/sites-available")
|
|
164
|
-
has_file(opts) unless opts[:no_file]
|
|
183
|
+
has_file(opts, :requires => get_package("apache2")) unless opts[:no_file]
|
|
165
184
|
has_exec(:name => "/usr/sbin/a2ensite #{sitename}") do
|
|
166
185
|
notifies get_exec("reload-apache2"), :run
|
|
167
186
|
requires get_exec("reload-apache2")
|
|
@@ -175,12 +194,14 @@ PassengerRuby <%= @node[:languages][:ruby][:ruby_bin] %>
|
|
|
175
194
|
end
|
|
176
195
|
|
|
177
196
|
def present_apache_module(*names)
|
|
197
|
+
opts = names.pop if names.last.kind_of?(::Hash)
|
|
178
198
|
names.each do |name|
|
|
179
199
|
has_exec(:name => "mod-#{name}", :command => "/usr/sbin/a2enmod #{name}") do
|
|
180
200
|
not_if "/bin/sh -c \'[ -L /etc/apache2/mods-enabled/#{name}.load ] && [ /etc/apache2/mods-enabled/#{name}.load -ef /etc/apache2/mods-available/#{name}.load ]\'"
|
|
181
201
|
requires get_package("apache2")
|
|
182
202
|
notifies get_exec("force-reload-apache2"), :run
|
|
183
203
|
requires get_exec("force-reload-apache2")
|
|
204
|
+
requires opts[:requires] if opts && opts[:requires]
|
|
184
205
|
end
|
|
185
206
|
end
|
|
186
207
|
end
|
|
@@ -34,7 +34,7 @@ module PoolParty
|
|
|
34
34
|
# setup an initial symlink so apache will start even if there have not been any deploys yet
|
|
35
35
|
#has_site_directory "releases/initial/public"
|
|
36
36
|
#FIXME the following line is chef specific. It will fail with puppet
|
|
37
|
-
has_link(:target_file => "#{dir}/#{name}/current", :to => "#{dir}/#{name}/releases/initial")
|
|
37
|
+
has_link(:target_file => "#{dir}/#{name}/current", :to => "#{dir}/#{name}/releases/initial", :requires => get_directory(site_directory))
|
|
38
38
|
end
|
|
39
39
|
log_dir = "#{site_directory}/shared/log"
|
|
40
40
|
appended_path "current"
|
data/lib/poolparty/pool.rb
CHANGED
|
@@ -155,7 +155,7 @@ module PoolParty
|
|
|
155
155
|
$:.unshift("#{File.dirname(filepath)}/lib")
|
|
156
156
|
$:.unshift("#{File.dirname(filepath)}/plugins")
|
|
157
157
|
|
|
158
|
-
Dir["#{File.dirname(filepath)}/lib
|
|
158
|
+
Dir["#{File.dirname(filepath)}/lib/*.rb"].each {|lib_path| require lib_path }
|
|
159
159
|
Dir["#{File.dirname(filepath)}/plugins/*"].each do |plugin_path|
|
|
160
160
|
if File.directory?(plugin_path)
|
|
161
161
|
$:.unshift(plugin_path)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module PoolParty
|
|
2
|
+
module Resources
|
|
3
|
+
|
|
4
|
+
class FakeSubclassedPlugin < Resource
|
|
5
|
+
|
|
6
|
+
def self.has_method_name
|
|
7
|
+
"subclassed"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def after_loaded
|
|
11
|
+
has_file "/etc/my_configs/special_config" do
|
|
12
|
+
requires get_directory("/etc/my_configs")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
require "#{File.dirname(__FILE__)}/../../../test_helper"
|
|
2
2
|
require File.dirname(__FILE__)+"/ec2_test.rb"
|
|
3
3
|
|
|
4
|
+
stub_keypair_searchable_paths
|
|
5
|
+
|
|
4
6
|
class Ec2InstanceTest < Test::Unit::TestCase
|
|
5
7
|
include CloudProviders
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
clear!
|
|
11
|
+
@filepath = fixtures_dir/"clouds/simple_cloud.rb"
|
|
12
|
+
@pool = PoolParty::Pool.load_from_file(@filepath)
|
|
13
|
+
@cloud = @pool.clouds[@pool.clouds.keys.first]
|
|
14
|
+
end
|
|
15
|
+
|
|
7
16
|
def inst
|
|
8
|
-
@inst ||=
|
|
17
|
+
@inst ||= @cloud.describe_instances.first
|
|
9
18
|
end
|
|
10
19
|
|
|
11
20
|
def test_has_cloud_provider
|
|
@@ -20,18 +29,18 @@ class Ec2InstanceTest < Test::Unit::TestCase
|
|
|
20
29
|
def test_to_s
|
|
21
30
|
vals = inst.to_s.split("\t")
|
|
22
31
|
assert_equal 3, vals.size
|
|
23
|
-
assert_equal '
|
|
32
|
+
assert_equal 'simple_cloud', vals.first
|
|
24
33
|
end
|
|
25
34
|
|
|
26
35
|
def test_has_cloud_set_when_created_from_cloud
|
|
27
|
-
assert_equal
|
|
28
|
-
assert_equal
|
|
29
|
-
assert_equal '
|
|
30
|
-
assert_equal '
|
|
36
|
+
assert_equal @cloud, @cloud.cloud_provider.cloud
|
|
37
|
+
assert_equal @cloud, inst.cloud
|
|
38
|
+
assert_equal 'simple_cloud', inst.dsl_options[:cloud_name]
|
|
39
|
+
assert_equal 'simple_cloud', inst.to_hash[:cloud_name]
|
|
31
40
|
end
|
|
32
41
|
|
|
33
42
|
def test_cloud_keypair
|
|
34
|
-
assert_equal
|
|
43
|
+
assert_equal @cloud.keypair.to_s, inst.keypair.to_s
|
|
35
44
|
end
|
|
36
45
|
|
|
37
46
|
def test_refresh!
|
|
@@ -5,7 +5,7 @@ stub_ec2_calls
|
|
|
5
5
|
class Ec2ProviderTest < Test::Unit::TestCase
|
|
6
6
|
|
|
7
7
|
def ec2
|
|
8
|
-
@ec2 ||=
|
|
8
|
+
@ec2 ||= @cloud.cloud_provider
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def setup
|
|
@@ -13,11 +13,15 @@ class Ec2ProviderTest < Test::Unit::TestCase
|
|
|
13
13
|
:image_id => "ami-abc123",
|
|
14
14
|
:keypair => fixtures_dir/'keys/test_key'
|
|
15
15
|
)
|
|
16
|
+
|
|
17
|
+
@filepath = fixtures_dir/"clouds/simple_cloud.rb"
|
|
18
|
+
@pool = PoolParty::Pool.load_from_file(@filepath)
|
|
19
|
+
@cloud = @pool.clouds[@pool.clouds.keys.first]
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
def test_setup
|
|
19
|
-
assert_not_nil
|
|
20
|
-
assert_not_nil
|
|
23
|
+
assert_not_nil @cloud
|
|
24
|
+
assert_not_nil @cloud.keypair
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
|
|
@@ -67,9 +71,9 @@ class Ec2ProviderTest < Test::Unit::TestCase
|
|
|
67
71
|
end
|
|
68
72
|
|
|
69
73
|
def test_basic_setup
|
|
70
|
-
assert_equal :ec2,
|
|
71
|
-
assert_instance_of CloudProviders::Ec2,
|
|
72
|
-
assert_instance_of RightAws::Ec2,
|
|
74
|
+
assert_equal :ec2, @cloud.cloud_provider_name
|
|
75
|
+
assert_instance_of CloudProviders::Ec2, @cloud.cloud_provider
|
|
76
|
+
assert_instance_of RightAws::Ec2, @cloud.cloud_provider.ec2
|
|
73
77
|
end
|
|
74
78
|
|
|
75
79
|
def test_that_test_ec2_env_variables_are_set
|
|
@@ -89,7 +93,7 @@ class Ec2ProviderTest < Test::Unit::TestCase
|
|
|
89
93
|
end
|
|
90
94
|
|
|
91
95
|
def test_cloud_is_set_when_created_from_a_cloud
|
|
92
|
-
assert_equal
|
|
96
|
+
assert_equal @cloud, @cloud.cloud_provider.cloud
|
|
93
97
|
end
|
|
94
98
|
|
|
95
99
|
def test_inherited_default_options
|
|
@@ -98,10 +102,10 @@ class Ec2ProviderTest < Test::Unit::TestCase
|
|
|
98
102
|
end
|
|
99
103
|
|
|
100
104
|
def amazon?
|
|
101
|
-
stub(
|
|
102
|
-
assert
|
|
103
|
-
stub(
|
|
104
|
-
assert
|
|
105
|
+
stub(@cloud.cloud_provider).ec2_url {'http://example.com'}
|
|
106
|
+
assert @cloud.cloud_provider.eucalyptus?
|
|
107
|
+
stub(@cloud.cloud_provider).ec2_url {'https://ec2.amazonaws.com'}
|
|
108
|
+
assert !@cloud.cloud_provider.eucalyptus?
|
|
105
109
|
end
|
|
106
110
|
|
|
107
111
|
def test_aws_hash
|
|
@@ -34,106 +34,121 @@ class CloudTest < Test::Unit::TestCase
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def test_have_a_keypair
|
|
37
|
-
assert_not_nil
|
|
38
|
-
assert_equal 'test_key',
|
|
37
|
+
assert_not_nil @cloud.keypair
|
|
38
|
+
assert_equal 'test_key', @cloud.keypair.basename
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def test_set_the_dependency_resolver
|
|
42
|
-
|
|
43
|
-
assert_equal DependencyResolvers::Chef,
|
|
42
|
+
@cloud.dependency_resolver(:chef)
|
|
43
|
+
assert_equal DependencyResolvers::Chef, @cloud.dependency_resolver
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def test_can_use_basic_resources
|
|
47
|
-
|
|
47
|
+
@cloud.instance_eval do
|
|
48
48
|
has_file "/etc/motd"
|
|
49
49
|
end
|
|
50
|
-
assert_equal "/etc/motd",
|
|
50
|
+
assert_equal "/etc/motd", @cloud.files.first.name
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def test_have_a_temp_path_of_the_name_as_Default_tmp_path_pool_name_cloud_name
|
|
54
|
-
assert_equal PoolParty::Default.tmp_path/"poolparty"/"
|
|
54
|
+
assert_equal PoolParty::Default.tmp_path/"poolparty"/"simple_cloud", @cloud.tmp_path
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def test_be_using_ec2_cloud_provider_by_default
|
|
58
|
-
assert_equal :ec2,
|
|
59
|
-
assert_kind_of ::CloudProviders::Ec2,
|
|
58
|
+
assert_equal :ec2, @cloud.cloud_provider_name
|
|
59
|
+
assert_kind_of ::CloudProviders::Ec2, @cloud.cloud_provider
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def test_raise_if_the_cloud_provider_is_not_a_known_type
|
|
63
63
|
PoolParty::PoolPartyError.create("UnknownCloudProviderError")
|
|
64
64
|
assert_raises UnknownCloudProviderError do
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
@cloud.cloud_provider_name = :not_a_cloud_provider
|
|
66
|
+
@cloud.cloud_provider
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def test_set_the_cloud_provider_cloud_and_keypair_with_cloud_provider
|
|
71
|
-
assert_equal
|
|
72
|
-
assert_equal
|
|
71
|
+
assert_equal @cloud, @cloud.cloud_provider.cloud
|
|
72
|
+
assert_equal @cloud.keypair.basename, @cloud.cloud_provider.keypair_name
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def test_set_the_cloud_provider_with_a_using_block
|
|
76
|
-
|
|
76
|
+
@cloud.instance_eval do
|
|
77
|
+
keypair "test_key"
|
|
77
78
|
using :ec2 do
|
|
78
79
|
image_id 'emi-39921602'
|
|
79
80
|
end
|
|
80
81
|
end
|
|
81
|
-
assert_equal :ec2,
|
|
82
|
-
assert_equal CloudProviders::Ec2,
|
|
83
|
-
assert_equal "emi-39921602",
|
|
82
|
+
assert_equal :ec2, @cloud.cloud_provider_name
|
|
83
|
+
assert_equal CloudProviders::Ec2, @cloud.cloud_provider.class
|
|
84
|
+
assert_equal "emi-39921602", @cloud.cloud_provider.image_id
|
|
84
85
|
end
|
|
85
86
|
|
|
86
87
|
def test_nodes
|
|
87
|
-
assert_respond_to
|
|
88
|
-
assert_respond_to
|
|
89
|
-
assert
|
|
88
|
+
assert_respond_to @cloud, :nodes
|
|
89
|
+
assert_respond_to @cloud.nodes, :each
|
|
90
|
+
assert @cloud.nodes.size>1
|
|
90
91
|
end
|
|
91
92
|
|
|
92
93
|
def test_terminate!
|
|
93
|
-
assert
|
|
94
|
-
result =
|
|
94
|
+
assert @cloud.nodes.size > 0
|
|
95
|
+
result = @cloud.terminate!
|
|
95
96
|
assert_respond_to result, :each
|
|
96
97
|
assert_equal 'shutting-down', result.first.status
|
|
97
98
|
end
|
|
98
99
|
|
|
99
100
|
def test_run
|
|
100
101
|
# WHAT?
|
|
101
|
-
# result =
|
|
102
|
+
# result = @cloud.run('uptime')
|
|
102
103
|
# assert_match /uptime/, result["app"]
|
|
103
104
|
end
|
|
104
105
|
|
|
105
106
|
def test_os
|
|
106
|
-
assert_equal :centos,
|
|
107
|
+
assert_equal :centos, @cloud.os
|
|
107
108
|
end
|
|
108
109
|
|
|
109
110
|
def test_expansion
|
|
110
111
|
#TODO: improve this test
|
|
111
|
-
# size =
|
|
112
|
-
# assert_equal size+1,
|
|
113
|
-
# assert_nothing_raised
|
|
112
|
+
# size = @cloud.nodes.size
|
|
113
|
+
# assert_equal size+1, @cloud.expand.nodes.size
|
|
114
|
+
# assert_nothing_raised @cloud.expand
|
|
114
115
|
end
|
|
115
116
|
|
|
116
117
|
def test_contract!
|
|
117
118
|
#TODO: need to better mock the terminate! ec2 call
|
|
118
|
-
# size =
|
|
119
|
-
# result =
|
|
119
|
+
# size = @cloud.nodes.size
|
|
120
|
+
# result = @cloud.contract!
|
|
120
121
|
# assert_equal 'shuttin-down', result.status
|
|
121
|
-
# assert_equal size-1,
|
|
122
|
+
# assert_equal size-1, @cloud.nodes.size
|
|
122
123
|
end
|
|
123
124
|
|
|
124
125
|
def test_change_ssh_port
|
|
125
126
|
clear!
|
|
126
127
|
pool "ssh_port" do
|
|
127
128
|
cloud "babity" do
|
|
129
|
+
keypair "test_key"
|
|
128
130
|
ssh_port 1922
|
|
129
131
|
end
|
|
130
|
-
cloud "noneity" do
|
|
131
|
-
end
|
|
132
132
|
end
|
|
133
133
|
assert_equal 1922, clouds["babity"].ssh_port
|
|
134
134
|
assert_equal 22, clouds["noneity"].ssh_port
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
+
def test_change_ssh_port
|
|
138
|
+
clear!
|
|
139
|
+
pool "ssher" do
|
|
140
|
+
cloud "custom" do
|
|
141
|
+
keypair "test_key"
|
|
142
|
+
ssh_options("-P" => "1992")
|
|
143
|
+
end
|
|
144
|
+
cloud "noneity" do
|
|
145
|
+
keypair "test_key"
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
assert_equal "1992", clouds["custom"].ssh_options["-P"]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
|
|
137
152
|
def test_children_getting_parent_options
|
|
138
153
|
clear!
|
|
139
154
|
pool "outside" do
|
|
@@ -11,9 +11,9 @@ class PoolTest < Test::Unit::TestCase
|
|
|
11
11
|
should "load the file with load_from_file on Pool" do
|
|
12
12
|
PoolParty::Pool.load_from_file(@filepath)
|
|
13
13
|
assert_equal PoolParty::Pool, pools["poolparty"].class
|
|
14
|
-
assert_equal PoolParty::Cloud, pools["poolparty"].clouds["
|
|
15
|
-
assert_equal "test_key", pools["poolparty"].clouds["
|
|
16
|
-
assert_equal "/etc/motd", pools["poolparty"].clouds["
|
|
14
|
+
assert_equal PoolParty::Cloud, pools["poolparty"].clouds["simple_cloud"].class
|
|
15
|
+
assert_equal "test_key", pools["poolparty"].clouds["simple_cloud"].keypair.basename
|
|
16
|
+
assert_equal "/etc/motd", pools["poolparty"].clouds["simple_cloud"].files.first.name
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
should "find_and_load_default_clouds_dot_rb in Pool" do
|
|
@@ -16,29 +16,4 @@ class BootstrapperTest < Test::Unit::TestCase
|
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
context "configure_script" do
|
|
20
|
-
setup do
|
|
21
|
-
clear!
|
|
22
|
-
@filepath = fixtures_dir/"clouds/simple_cloud.rb"
|
|
23
|
-
@pool = PoolParty::Pool.load_from_file(@filepath)
|
|
24
|
-
@cloud = @pool.clouds[@pool.clouds.keys.first]
|
|
25
|
-
@outfile = test_dir/"configure_script.sh"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
should "get the script for ubuntu" do
|
|
29
|
-
assert_equal File.expand_path(@outfile), Provision::Bootstrapper.configure_script(@cloud, :ubuntu, @outfile)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
should "output some stuffies" do
|
|
33
|
-
assert_match /echo app > \/etc\/poolparty\/cloud_name/, open(@outfile).read
|
|
34
|
-
assert_match /echo poolparty > \/etc\/poolparty\/pool_name/, open(@outfile).read
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
should "raise an exception if the os isn't supported yet" do
|
|
38
|
-
assert_raises StandardError do
|
|
39
|
-
Provision::Bootstrapper.configure_script(@cloud, :non_existant_os)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
19
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: poolparty
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.14
|
|
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-
|
|
14
|
+
date: 2009-09-18 00:00:00 -07:00
|
|
15
15
|
default_executable:
|
|
16
16
|
dependencies: []
|
|
17
17
|
|
|
@@ -276,6 +276,7 @@ files:
|
|
|
276
276
|
- test/fixtures/keys/test_pub_key
|
|
277
277
|
- test/fixtures/resources/fake_plugin.rb
|
|
278
278
|
- test/fixtures/resources/fake_resource.rb
|
|
279
|
+
- test/fixtures/resources/fake_subclassed_plugin.rb
|
|
279
280
|
- test/fixtures/resources/random_proc_file.rb
|
|
280
281
|
- test/fixtures/templates/apache_conf.erb
|
|
281
282
|
- test/fixtures/test_template.erb
|