fairchild-poolparty 1.3.5 → 1.3.17
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/bin/cloud +1 -0
- data/bin/cloud-compile +1 -0
- data/bin/cloud-misc +34 -0
- data/bin/cloud-show +13 -1
- data/bin/cloud-ssh +4 -1
- data/bin/cloud-thrift +32 -18
- data/config/jeweler.rb +5 -3
- data/examples/monitored_cloud.rb +1 -1
- data/examples/thrift/thrift_example.rb +8 -4
- data/examples/vmware.rb +10 -0
- data/lib/cloud_providers/cloud_provider.rb +9 -0
- data/lib/cloud_providers/cloud_provider_instance.rb +9 -4
- data/lib/cloud_providers/connections.rb +9 -5
- data/lib/cloud_providers/ec2/ec2.rb +42 -12
- data/lib/cloud_providers/ec2/ec2_helpers.rb +62 -5
- data/lib/cloud_providers/ec2/ec2_instance.rb +14 -1
- data/lib/cloud_providers/vmware/vmware.rb +3 -0
- data/lib/core/file.rb +12 -0
- data/lib/core/object.rb +1 -1
- data/lib/dependency_resolvers/base.rb +2 -9
- data/lib/dependency_resolvers/chef.rb +3 -3
- data/lib/keypair.rb +5 -3
- data/lib/poolparty.rb +3 -1
- data/lib/poolparty/base.rb +45 -22
- data/lib/poolparty/cloud.rb +70 -15
- data/lib/poolparty/default.rb +1 -0
- data/lib/poolparty/installer.rb +1 -1
- data/lib/poolparty/installers/ec2.rb +30 -16
- data/lib/poolparty/monitor.rb +25 -3
- data/lib/poolparty/plugin.rb +1 -5
- data/lib/poolparty/plugins/apache.rb +37 -11
- data/lib/poolparty/plugins/apache2/passenger_site.rb +1 -1
- data/lib/poolparty/plugins/apache2/virtual_host.rb +1 -0
- data/lib/poolparty/plugins/collectd.rb +29 -0
- data/lib/poolparty/plugins/collectd/templates/collectd.conf.erb +369 -0
- data/lib/poolparty/plugins/hermes.rb +101 -0
- data/lib/poolparty/pool.rb +14 -6
- data/lib/poolparty/resource.rb +20 -17
- data/lib/poolparty/resources/file.rb +2 -2
- data/lib/poolparty/resources/line.rb +1 -1
- data/lib/poolparty/resources/link.rb +2 -1
- data/lib/proto/command_interface_handler.rb +42 -7
- data/lib/proto/command_query_handler.rb +19 -0
- data/lib/proto/gen-py/cloudthrift/CommandInterface.pyc +0 -0
- data/lib/proto/gen-py/cloudthrift/__init__.pyc +0 -0
- data/lib/proto/gen-py/cloudthrift/constants.pyc +0 -0
- data/lib/proto/gen-py/cloudthrift/ttypes.pyc +0 -0
- data/lib/proto/gen-py/thrift/Thrift.pyc +0 -0
- data/lib/proto/gen-py/thrift/__init__.pyc +0 -0
- data/lib/proto/gen-py/thrift/protocol/TBinaryProtocol.pyc +0 -0
- data/lib/proto/gen-py/thrift/protocol/TProtocol.pyc +0 -0
- data/lib/proto/gen-py/thrift/protocol/__init__.pyc +0 -0
- data/lib/proto/gen-py/thrift/transport/TSocket.pyc +0 -0
- data/lib/proto/gen-py/thrift/transport/TTransport.pyc +0 -0
- data/lib/proto/gen-py/thrift/transport/__init__.pyc +0 -0
- data/lib/proto/poolparty.thrift +1 -0
- data/tasks/poolparty.rake +24 -0
- data/test/fixtures/clouds/fake_clouds.rb +2 -2
- data/test/fixtures/clouds/simple_cloud.rb +2 -2
- data/test/fixtures/resources/fake_plugin.rb +5 -0
- 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/core/array_test.rb +4 -0
- data/test/lib/dependency_resolvers/base_test.rb +1 -1
- data/test/lib/dependency_resolvers/chef/resources/remote_directory_test.rb +2 -2
- data/test/lib/dependency_resolvers/chef/resources/remote_file_test.rb +1 -1
- data/test/lib/dependency_resolvers/chef_test.rb +3 -3
- data/test/lib/poolparty/base_test.rb +1 -1
- data/test/lib/poolparty/cloud_test.rb +140 -33
- data/test/lib/poolparty/monitor_test.rb +29 -2
- data/test/lib/poolparty/plugins/apache_test.rb +5 -0
- data/test/lib/poolparty/pool_test.rb +3 -3
- data/test/lib/poolparty/resource_test.rb +14 -2
- data/test/lib/poolparty/resources/conditional_test.rb +1 -0
- data/test/lib/poolparty/resources/directory_test.rb +1 -1
- data/test/lib/poolparty/resources/file_test.rb +1 -1
- data/test/lib/poolparty/resources/user_test.rb +1 -1
- data/test/lib/proto/command_query_handler_test.rb +11 -0
- data/test/lib/provision/bootstrapper_test.rb +0 -25
- data/test/test_helper.rb +0 -1
- metadata +15 -4
@@ -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
|
@@ -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
|
data/test/lib/core/array_test.rb
CHANGED
@@ -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
|
@@ -26,10 +26,10 @@ class RemoteDirectoryResourceTest < Test::Unit::TestCase
|
|
26
26
|
remote_directory "/tmp/remote_something" do
|
27
27
|
source "something"
|
28
28
|
files_backup 10
|
29
|
-
files_mode 0644
|
29
|
+
files_mode "0644"
|
30
30
|
action :create
|
31
31
|
recursive false
|
32
|
-
mode 0755
|
32
|
+
mode "0755"
|
33
33
|
owner "nobody"
|
34
34
|
group "nobody"
|
35
35
|
files_owner "root"
|
@@ -54,7 +54,7 @@ class ChefTest < Test::Unit::TestCase
|
|
54
54
|
|
55
55
|
def test_compile_to_the_recipes
|
56
56
|
@base.compile_to(@resources[:files], test_dir)
|
57
|
-
assert_equal "template \"/etc/motd\" do\n source \"/etc/motd.erb\"\n action :create\n backup 5\n mode 0644\n owner \"root\"\nend\n", open(@cookboox_directory/"recipes"/"default.rb").read
|
57
|
+
assert_equal "template \"/etc/motd\" do\n source \"/etc/motd.erb\"\n action :create\n backup 5\n mode \"0644\"\n owner \"root\"\nend\n", open(@cookboox_directory/"recipes"/"default.rb").read
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_compile_the_recipes
|
@@ -78,14 +78,14 @@ template "/etc/motd" do
|
|
78
78
|
source "/etc/motd.erb"
|
79
79
|
action :create
|
80
80
|
backup 5
|
81
|
-
mode 0644
|
81
|
+
mode "0644"
|
82
82
|
owner "root"
|
83
83
|
end
|
84
84
|
|
85
85
|
directory "/etc/poolparty" do
|
86
86
|
action :create
|
87
87
|
recursive true
|
88
|
-
mode 0644
|
88
|
+
mode "0644"
|
89
89
|
owner "root"
|
90
90
|
group "root"
|
91
91
|
end
|
@@ -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
|
@@ -34,93 +35,165 @@ class CloudTest < Test::Unit::TestCase
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def test_have_a_keypair
|
37
|
-
assert_not_nil
|
38
|
-
assert_equal 'test_key',
|
38
|
+
assert_not_nil @cloud.keypair
|
39
|
+
assert_equal 'test_key', @cloud.keypair.basename
|
39
40
|
end
|
40
41
|
|
41
42
|
def test_set_the_dependency_resolver
|
42
|
-
|
43
|
-
assert_equal DependencyResolvers::Chef,
|
43
|
+
@cloud.dependency_resolver(:chef)
|
44
|
+
assert_equal DependencyResolvers::Chef, @cloud.dependency_resolver
|
44
45
|
end
|
45
46
|
|
46
47
|
def test_can_use_basic_resources
|
47
|
-
|
48
|
+
@cloud.instance_eval do
|
48
49
|
has_file "/etc/motd"
|
49
50
|
end
|
50
|
-
assert_equal "/etc/motd",
|
51
|
+
assert_equal "/etc/motd", @cloud.files.first.name
|
51
52
|
end
|
52
53
|
|
53
54
|
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"/"
|
55
|
+
assert_equal PoolParty::Default.tmp_path/"poolparty"/"simple_cloud", @cloud.tmp_path
|
55
56
|
end
|
56
57
|
|
57
58
|
def test_be_using_ec2_cloud_provider_by_default
|
58
|
-
assert_equal :ec2,
|
59
|
-
assert_kind_of ::CloudProviders::Ec2,
|
59
|
+
assert_equal :ec2, @cloud.cloud_provider_name
|
60
|
+
assert_kind_of ::CloudProviders::Ec2, @cloud.cloud_provider
|
60
61
|
end
|
61
62
|
|
62
63
|
def test_raise_if_the_cloud_provider_is_not_a_known_type
|
63
64
|
PoolParty::PoolPartyError.create("UnknownCloudProviderError")
|
64
65
|
assert_raises UnknownCloudProviderError do
|
65
|
-
|
66
|
-
|
66
|
+
@cloud.cloud_provider_name = :not_a_cloud_provider
|
67
|
+
@cloud.cloud_provider
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
70
71
|
def test_set_the_cloud_provider_cloud_and_keypair_with_cloud_provider
|
71
|
-
assert_equal
|
72
|
-
assert_equal
|
72
|
+
assert_equal @cloud, @cloud.cloud_provider.cloud
|
73
|
+
assert_equal @cloud.keypair.basename, @cloud.cloud_provider.keypair_name
|
73
74
|
end
|
74
75
|
|
75
76
|
def test_set_the_cloud_provider_with_a_using_block
|
76
|
-
|
77
|
+
@cloud.instance_eval do
|
78
|
+
keypair "test_key"
|
77
79
|
using :ec2 do
|
78
80
|
image_id 'emi-39921602'
|
79
81
|
end
|
80
82
|
end
|
81
|
-
assert_equal :ec2,
|
82
|
-
assert_equal CloudProviders::Ec2,
|
83
|
-
assert_equal "emi-39921602",
|
83
|
+
assert_equal :ec2, @cloud.cloud_provider_name
|
84
|
+
assert_equal CloudProviders::Ec2, @cloud.cloud_provider.class
|
85
|
+
assert_equal "emi-39921602", @cloud.cloud_provider.image_id
|
84
86
|
end
|
85
87
|
|
86
88
|
def test_nodes
|
87
|
-
assert_respond_to
|
88
|
-
assert_respond_to
|
89
|
-
assert
|
89
|
+
assert_respond_to @cloud, :nodes
|
90
|
+
assert_respond_to @cloud.nodes, :each
|
91
|
+
assert @cloud.nodes.size>1
|
90
92
|
end
|
91
93
|
|
92
94
|
def test_terminate!
|
93
|
-
assert
|
94
|
-
result =
|
95
|
+
assert @cloud.nodes.size > 0
|
96
|
+
result = @cloud.terminate!
|
95
97
|
assert_respond_to result, :each
|
96
98
|
assert_equal 'shutting-down', result.first.status
|
97
99
|
end
|
98
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
|
+
|
99
145
|
def test_run
|
100
146
|
# WHAT?
|
101
|
-
result =
|
102
|
-
assert_match /uptime/, result["app"]
|
147
|
+
# result = @cloud.run('uptime')
|
148
|
+
# assert_match /uptime/, result["app"]
|
103
149
|
end
|
104
150
|
|
105
151
|
def test_os
|
106
|
-
assert_equal :centos,
|
152
|
+
assert_equal :centos, @cloud.os
|
107
153
|
end
|
108
154
|
|
109
155
|
def test_expansion
|
110
156
|
#TODO: improve this test
|
111
|
-
# size =
|
112
|
-
# assert_equal size+1,
|
113
|
-
# assert_nothing_raised
|
157
|
+
# size = @cloud.nodes.size
|
158
|
+
# assert_equal size+1, @cloud.expand.nodes.size
|
159
|
+
# assert_nothing_raised @cloud.expand
|
114
160
|
end
|
115
161
|
|
116
162
|
def test_contract!
|
117
163
|
#TODO: need to better mock the terminate! ec2 call
|
118
|
-
# size =
|
119
|
-
# result =
|
164
|
+
# size = @cloud.nodes.size
|
165
|
+
# result = @cloud.contract!
|
120
166
|
# assert_equal 'shuttin-down', result.status
|
121
|
-
# assert_equal size-1,
|
167
|
+
# assert_equal size-1, @cloud.nodes.size
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_change_ssh_port
|
171
|
+
clear!
|
172
|
+
pool "ssh_port" do
|
173
|
+
cloud "babity" do
|
174
|
+
keypair "test_key"
|
175
|
+
ssh_port 1922
|
176
|
+
end
|
177
|
+
end
|
178
|
+
assert_equal 1922, clouds["babity"].ssh_port
|
179
|
+
assert_equal 22, clouds["noneity"].ssh_port
|
122
180
|
end
|
123
181
|
|
182
|
+
def test_change_ssh_port
|
183
|
+
clear!
|
184
|
+
pool "ssher" do
|
185
|
+
cloud "custom" do
|
186
|
+
keypair "test_key"
|
187
|
+
# ssh_options("-P" => "1992")
|
188
|
+
end
|
189
|
+
cloud "noneity" do
|
190
|
+
keypair "test_key"
|
191
|
+
end
|
192
|
+
end
|
193
|
+
# assert_equal "1992", clouds["custom"].ssh_options["-P"]
|
194
|
+
end
|
195
|
+
|
196
|
+
|
124
197
|
def test_children_getting_parent_options
|
125
198
|
clear!
|
126
199
|
pool "outside" do
|
@@ -145,12 +218,46 @@ class CloudTest < Test::Unit::TestCase
|
|
145
218
|
configure if v < 0.2
|
146
219
|
vote_for(:expand) if v > 1.1
|
147
220
|
end
|
221
|
+
|
222
|
+
monitor :load do |a|
|
223
|
+
# [0.42 0.43 0.37]
|
224
|
+
vote_for(:expand) if a[0] > 0.8
|
225
|
+
end
|
226
|
+
|
227
|
+
monitor_format :load do |d|
|
228
|
+
d.split(",").map {|ele| ele.to_f }
|
229
|
+
end
|
230
|
+
|
148
231
|
end
|
149
232
|
end
|
150
233
|
|
151
|
-
assert_equal
|
152
|
-
assert_equal [:cpu], clouds["monitor_app"].monitors.map {|m,v| v.name }
|
234
|
+
assert_equal 2, clouds["monitor_app"].monitors.size
|
235
|
+
assert_equal [:cpu, :load], clouds["monitor_app"].monitors.map {|m,v| v.name }
|
153
236
|
assert_equal({:configure => []}, clouds["monitor_app"].run_monitor("cpu", "0.1"))
|
154
237
|
assert_equal({:vote_for => [:expand]}, clouds["monitor_app"].run_monitor("cpu", "1.4"))
|
238
|
+
assert_equal({:vote_for => [:expand]}, clouds["monitor_app"].run_monitor("load", "0.98, 0.23, 0.1"))
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_add_monitoring_stack_if_needed
|
242
|
+
clear!
|
243
|
+
pool "monitoring2" do
|
244
|
+
cloud "app_cloud" do
|
245
|
+
keypair "test_key", fixtures_dir/"keys"
|
246
|
+
platform :ubuntu
|
247
|
+
monitor "cpu-idle" do |c|
|
248
|
+
vote_for(:expand) if c > 0.8
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
assert_equal 1, clouds["app_cloud"].monitors.size
|
254
|
+
|
255
|
+
clouds["app_cloud"].compile
|
256
|
+
|
257
|
+
compile_dir = clouds["app_cloud"].tmp_path/"etc"/"chef"/"cookbooks"/"poolparty"
|
258
|
+
recipe_file = compile_dir/"recipes"/"default.rb"
|
259
|
+
recipe_contents = open(recipe_file).read
|
260
|
+
|
261
|
+
assert_match /install_hermes/, recipe_contents
|
155
262
|
end
|
156
263
|
end
|