ironfan 4.1.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
- --format documentation
3
- --drb
2
+ --format documentation
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v4.1.1: fixing 'rake spec'
2
+ * Remove all defunct tests and start fresh (fixes #137)
3
+ * Failing spec for #158
4
+
1
5
  # v4.1.0: several bug-fixes and code cleanup
2
6
  * Splat the args to DSL::Volume.snapshot_id so we can call it properly (fixes #161)
3
7
  * cloud(:ec2) lets you declare bitness (fixes #147)
data/Rakefile CHANGED
@@ -64,9 +64,7 @@ Jeweler::RubygemsDotOrgTasks.new
64
64
  #
65
65
  # RSpec -- testing
66
66
  #
67
- RSpec::Core::RakeTask.new(:spec) do |spec|
68
- spec.pattern = FileList['spec/**/*_spec.rb']
69
- end
67
+ RSpec::Core::RakeTask.new(:spec)
70
68
 
71
69
  RSpec::Core::RakeTask.new(:rcov) do |spec|
72
70
  spec.pattern = 'spec/**/*_spec.rb'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.1.0
1
+ 4.1.1
data/ironfan.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ironfan"
8
- s.version = "4.1.0"
8
+ s.version = "4.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Infochimps"]
12
- s.date = "2012-09-24"
12
+ s.date = "2012-09-27"
13
13
  s.description = "Ironfan allows you to orchestrate not just systems but clusters of machines. It includes a powerful layer on top of knife and a collection of cloud cookbooks."
14
14
  s.email = "coders@infochimps.com"
15
15
  s.extra_rdoc_files = [
@@ -85,10 +85,7 @@ Gem::Specification.new do |s|
85
85
  "lib/ironfan/provider/virtualbox/machine.rb",
86
86
  "lib/ironfan/requirements.rb",
87
87
  "spec/ironfan/cluster_spec.rb",
88
- "spec/ironfan/facet_spec.rb",
89
- "spec/ironfan/server_slice_spec.rb",
90
- "spec/ironfan/server_spec.rb",
91
- "spec/ironfan_spec.rb",
88
+ "spec/ironfan/ec2/security_group_spec.rb",
92
89
  "spec/spec_helper.rb",
93
90
  "spec/spec_helper/dummy_chef.rb",
94
91
  "spec/test_config.rb",
@@ -99,7 +96,7 @@ Gem::Specification.new do |s|
99
96
  s.require_paths = ["lib"]
100
97
  s.rubygems_version = "1.8.24"
101
98
  s.summary = "Ironfan allows you to orchestrate not just systems but clusters of machines. It includes a powerful layer on top of knife and a collection of cloud cookbooks."
102
- s.test_files = ["spec/ironfan_spec.rb", "spec/spec_helper/dummy_chef.rb", "spec/ironfan/cluster_spec.rb", "spec/ironfan/server_slice_spec.rb", "spec/ironfan/server_spec.rb", "spec/ironfan/facet_spec.rb", "spec/spec_helper.rb", "spec/test_config.rb"]
99
+ s.test_files = ["spec/spec_helper/dummy_chef.rb", "spec/ironfan/cluster_spec.rb", "spec/ironfan/ec2/security_group_spec.rb", "spec/spec_helper.rb", "spec/test_config.rb"]
103
100
 
104
101
  if s.respond_to? :specification_version then
105
102
  s.specification_version = 3
@@ -48,7 +48,7 @@ class Chef
48
48
  :default => '6666'
49
49
 
50
50
  def relevant?(server)
51
- server.sshable?
51
+ server.machine.running?
52
52
  end
53
53
 
54
54
  def perform_execution(target)
@@ -62,7 +62,7 @@ class Chef
62
62
  def command_for_target(svr)
63
63
  config[:attribute] ||= Chef::Config[:knife][:ssh_address_attribute] || "fqdn"
64
64
  config[:ssh_user] ||= Chef::Config[:knife][:ssh_user]
65
- config[:identity_file] ||= svr.cloud.ssh_identity_file
65
+ config[:identity_file] ||= svr.server.cloud.ssh_identity_file
66
66
  config[:host_key_verify] ||= Chef::Config[:knife][:host_key_verify] || (not config[:no_host_key_verify]) # pre-vs-post 0.10.4
67
67
 
68
68
  address = svr.public_hostname
data/lib/ironfan.rb CHANGED
@@ -64,6 +64,7 @@ module Ironfan
64
64
 
65
65
  cl = ( @@clusters[name] ||= Ironfan::Dsl::Cluster.new({:name => name}) )
66
66
  cl.receive!(attrs, &block)
67
+ cl
67
68
  end
68
69
 
69
70
  #
@@ -1,13 +1,23 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
- require IRONFAN_DIR("lib/ironfan")
3
+ require 'ironfan'
4
4
 
5
- describe Ironfan::Cluster do
6
- describe 'discover!' do
7
- let(:cluster){ get_example_cluster(:monkeyballs) }
8
-
9
- it 'enumerates chef nodes' do
10
- cluster.discover!
5
+ describe Ironfan::Dsl::Cluster do
6
+ describe 'run lists' do
7
+ subject do
8
+ Ironfan.cluster 'foo' do
9
+ environment :dev
10
+
11
+ role :systemwide
12
+
13
+ facet :bar do
14
+ instances 1
15
+ role :nfs_client, :first
16
+ end
17
+ end
11
18
  end
19
+
20
+ its(:environment) { should eql :dev }
21
+ its(:run_list) { should eql ["role[systemwide]"] }
12
22
  end
13
23
  end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ require 'ironfan'
4
+
5
+ describe Ironfan::Dsl::Cluster do
6
+ let (:cluster) do
7
+ Ironfan.cluster "sparky" do
8
+ cloud(:ec2).security_group(:ssh).authorize_port_range 22..22
9
+ facet :web do
10
+ cloud(:ec2).security_group("sparky-web").authorize_port_range(80)
11
+ end
12
+ end
13
+ end
14
+
15
+ describe 'cluster definition' do
16
+ subject { cluster }
17
+
18
+ its(:name) { should eql "sparky" }
19
+ its(:environment) { should eql :_default }
20
+ its(:run_list) { should eql [] }
21
+
22
+ describe 'facets' do
23
+ before { @facets = cluster.facets }
24
+ subject { @facets.values }
25
+ its(:length) { should eql 1 }
26
+
27
+ describe 'web facet' do
28
+ before { @facet = @facets.values.first }
29
+ subject { @facet }
30
+ its(:name) { should eql "web" }
31
+
32
+ describe 'security groups' do
33
+ before { @groups = @facet.clouds.values.first.security_groups.values }
34
+ subject { @groups }
35
+
36
+ its(:length) { should eql 2 }
37
+
38
+ it 'authorizes ssh on port 22 from anywhere' do
39
+ ssh_auth = @groups.first
40
+ ssh_auth.range_authorizations.first.should eql [22..22, "0.0.0.0/0", "tcp"]
41
+ end
42
+
43
+ it 'authorizes HTTP on port 80 from anywhere' do
44
+ http_auth = @groups.last
45
+ http_auth.range_authorizations.first.should eql [80..80, "0.0.0.0/0", "tcp"]
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+ describe 'clouds' do
53
+
54
+ end
55
+ end
56
+ end
57
+
data/spec/spec_helper.rb CHANGED
@@ -1,42 +1,7 @@
1
- require 'rubygems' unless defined?(Gem)
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
-
11
- require 'rspec'
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
12
2
  require 'chef'
13
3
  require 'chef/knife'
14
4
  require 'fog'
15
5
 
16
- unless defined?(IRONFAN_DIR)
17
- IRONFAN_DIR = File.expand_path(File.dirname(__FILE__)+'/..')
18
- def IRONFAN_DIR(*paths) File.join(IRONFAN_DIR, *paths); end
19
- # load from vendored libraries, if present
20
- Dir[IRONFAN_DIR("vendor/*/lib")].each{|dir| p dir ; $LOAD_PATH.unshift(File.expand_path(dir)) } ; $LOAD_PATH.uniq!
21
- end
22
-
23
6
  Fog.mock!
24
7
  Fog::Mock.delay = 0
25
-
26
- CHEF_CONFIG_FILE = File.expand_path(IRONFAN_DIR('spec/test_config.rb')) unless defined?(CHEF_CONFIG_FILE)
27
- Chef::Config.from_file(CHEF_CONFIG_FILE)
28
-
29
- # Requires custom matchers & macros, etc from files in ./spec_helper/
30
- Dir[IRONFAN_DIR("spec/spec_helper/*.rb")].each {|f| require f}
31
-
32
- def load_example_cluster(name)
33
- require(IRONFAN_DIR('clusters', "#{name}.rb"))
34
- end
35
- def get_example_cluster name
36
- load_example_cluster(name)
37
- Ironfan.cluster(name)
38
- end
39
-
40
- # Configure rspec
41
- RSpec.configure do |config|
42
- end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ironfan
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 4.1.0
5
+ version: 4.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Infochimps
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-09-24 00:00:00 Z
13
+ date: 2012-09-27 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: chef
@@ -211,10 +211,7 @@ files:
211
211
  - lib/ironfan/provider/virtualbox/machine.rb
212
212
  - lib/ironfan/requirements.rb
213
213
  - spec/ironfan/cluster_spec.rb
214
- - spec/ironfan/facet_spec.rb
215
- - spec/ironfan/server_slice_spec.rb
216
- - spec/ironfan/server_spec.rb
217
- - spec/ironfan_spec.rb
214
+ - spec/ironfan/ec2/security_group_spec.rb
218
215
  - spec/spec_helper.rb
219
216
  - spec/spec_helper/dummy_chef.rb
220
217
  - spec/test_config.rb
@@ -232,7 +229,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
229
  requirements:
233
230
  - - ">="
234
231
  - !ruby/object:Gem::Version
235
- hash: 3712152495684054514
232
+ hash: 481284130132022925
236
233
  segments:
237
234
  - 0
238
235
  version: "0"
@@ -250,11 +247,8 @@ signing_key:
250
247
  specification_version: 3
251
248
  summary: Ironfan allows you to orchestrate not just systems but clusters of machines. It includes a powerful layer on top of knife and a collection of cloud cookbooks.
252
249
  test_files:
253
- - spec/ironfan_spec.rb
254
250
  - spec/spec_helper/dummy_chef.rb
255
251
  - spec/ironfan/cluster_spec.rb
256
- - spec/ironfan/server_slice_spec.rb
257
- - spec/ironfan/server_spec.rb
258
- - spec/ironfan/facet_spec.rb
252
+ - spec/ironfan/ec2/security_group_spec.rb
259
253
  - spec/spec_helper.rb
260
254
  - spec/test_config.rb
@@ -1,69 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- require IRONFAN_DIR("lib/ironfan")
4
-
5
- describe Ironfan::Facet do
6
- let(:cluster){ Ironfan.cluster(:gibbon) }
7
- let(:facet){
8
- cluster.facet(:namenode) do
9
- instances 5
10
- end
11
- }
12
-
13
- describe 'slicing' do
14
- it 'has servers' do
15
- facet.indexes.should == [0, 1, 2, 3, 4]
16
- facet.valid_indexes.should == [0, 1, 2, 3, 4]
17
- facet.server(3){ name(:bob) }
18
- svrs = facet.servers
19
- svrs.length.should == 5
20
- svrs.map{|svr| svr.name }.should == ["gibbon-namenode-0", "gibbon-namenode-1", "gibbon-namenode-2", :bob, "gibbon-namenode-4"]
21
- end
22
-
23
- it 'servers have bogosity if out of range' do
24
- facet.server(69).should be_bogus
25
- facet.servers.select(&:bogus?).map(&:facet_index).should == [69]
26
- facet.indexes.should == [0, 1, 2, 3, 4, 69]
27
- facet.valid_indexes.should == [0, 1, 2, 3, 4]
28
- end
29
-
30
- it 'returns all on nil or "", but [] means none' do
31
- facet.server(69)
32
- facet.slice('' ).map(&:facet_index).should == [0, 1, 2, 3, 4, 69]
33
- facet.slice(nil).map(&:facet_index).should == [0, 1, 2, 3, 4, 69]
34
- facet.slice([] ).map(&:facet_index).should == []
35
- end
36
-
37
- it 'slice returns all by default' do
38
- facet.server(69)
39
- facet.slice().map(&:facet_index).should == [0, 1, 2, 3, 4, 69]
40
- end
41
-
42
- it 'with an array returns specified indexes (bogus or not) in sorted order' do
43
- facet.server(69)
44
- facet.slice( [3, 1, 0] ).map(&:facet_index).should == [0, 1, 3]
45
- facet.slice( [3, 1, 69, 0] ).map(&:facet_index).should == [0, 1, 3, 69]
46
- end
47
-
48
- it 'with an array does not create new dummy servers' do
49
- facet.server(69)
50
- facet.slice( [3, 1, 69, 0, 75, 123] ).map(&:facet_index).should == [0, 1, 3, 69]
51
- facet.has_server?(75).should be_false
52
- facet.has_server?(69).should be_true
53
- end
54
-
55
- it 'with a string, converts to intervals' do
56
- facet.slice('1' ).map(&:facet_index).should == [1]
57
- facet.slice('5' ).map(&:facet_index).should == []
58
- facet.slice('1-1' ).map(&:facet_index).should == [1]
59
- facet.slice('0-1' ).map(&:facet_index).should == [0,1]
60
- facet.slice('0-1,3-4').map(&:facet_index).should == [0,1,3,4]
61
- facet.slice('0-1,69' ).map(&:facet_index).should == [0,1,69]
62
- facet.slice('0-2,1-3').map(&:facet_index).should == [0,1,2,3]
63
- facet.slice('3-1' ).map(&:facet_index).should == []
64
- facet.slice('2-5' ).map(&:facet_index).should == [2,3,4]
65
- facet.slice(1).map(&:facet_index).should == [1]
66
- end
67
-
68
- end
69
- end
@@ -1,19 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
- require IRONFAN_DIR("lib/ironfan")
3
-
4
- describe Ironfan::ServerSlice do
5
- before do
6
- @slice = Ironfan.slice('webserver_demo')
7
- end
8
-
9
- describe 'attributes' do
10
- it 'security groups' do
11
- @slice.security_groups.keys.sort.should == [
12
- "default",
13
- "webserver_demo", "webserver_demo-awesome_website", "webserver_demo-dbnode", "webserver_demo-esnode",
14
- "webserver_demo-redis_client", "webserver_demo-redis_server",
15
- "webserver_demo-webnode", "nfs_client", "ssh"
16
- ]
17
- end
18
- end
19
- end
@@ -1,112 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
- require IRONFAN_DIR("lib/ironfan")
3
-
4
- describe Ironfan::Server do
5
- include_context 'dummy_chef'
6
-
7
- Ironfan::Server.class_eval do
8
- def chef_node
9
- Chef::Node.new
10
- end
11
- end
12
-
13
- Ironfan::DryRunnable.class_eval do
14
- def unless_dry_run
15
- puts "Not doing that"
16
- end
17
- end
18
-
19
- before do
20
- Ironfan::Server.stub!(:chef_node).and_return( "HI" )
21
- Chef::Config.stub!(:validation_key).and_return("I_AM_VALID")
22
-
23
- foo = Ironfan::Server.new(Ironfan::Facet.new(Ironfan::Cluster.new('hi'),'there'),0)
24
- puts foo.inspect
25
- puts foo.chef_node
26
- @cluster = get_example_cluster('webserver_demo')
27
- @cluster.resolve!
28
- @facet = @cluster.facet(:dbnode)
29
- @server = @facet.server(0)
30
- end
31
-
32
- describe 'volumes' do
33
- describe '#composite_volumes' do
34
- it 'assembles cluster, facet and server volumes' do
35
- @server.composite_volumes.length.should == 5
36
- @cluster.volumes.length.should == 4
37
- @facet.volumes.length.should == 1
38
- @server.volumes.length.should == 1
39
- end
40
-
41
- it 'composites server attributes onto a volume defined in the facet' do
42
- vol = @server.composite_volumes[:data]
43
- vol.to_hash.should == {
44
- :name => :data,
45
- :tags => {},
46
- :snapshot_id => "snap-d9c1edb1",
47
- :size => 50,
48
- :keep => true,
49
- :device => "/dev/sdi",
50
- :mount_point => "/data/db",
51
- :mount_options => "defaults,nouuid,noatime",
52
- :fs_type => "xfs",
53
- :availability_zone => "us-east-1d"
54
- }
55
- end
56
-
57
- it 'makes block_device_mapping for non-ephemeral storage' do
58
- vol = @server.composite_volumes[:data]
59
- vol.block_device_mapping.should == {
60
- "DeviceName" => "/dev/sdi",
61
- "Ebs.SnapshotId" => "snap-d9c1edb1",
62
- "Ebs.VolumeSize" => 50,
63
- "Ebs.DeleteOnTermination" => "false"
64
- }
65
- end
66
-
67
- it 'skips block_device_mapping for non-ephemeral storage if volume id is present' do
68
- vol = @facet.server(1).composite_volumes[:data]
69
- vol.block_device_mapping.should be_nil
70
- end
71
-
72
- end
73
- end
74
-
75
- describe 'launch' do
76
- describe '#fog_launch_description' do
77
- it 'has right attributes' do
78
-
79
- hsh = @server.fog_launch_description
80
- hsh.delete(:user_data)
81
- hsh.should == {
82
- :image_id => "ami-08f40561",
83
- :flavor_id => "m1.large",
84
- :groups => ["webserver_demo-redis_client", "webserver_demo-dbnode", "default", "ssh", "nfs_client", "webserver_demo"],
85
- :key_name => :webserver_demo,
86
- :tags => {:cluster=>:webserver_demo, :facet=>:dbnode, :index=>0},
87
- :block_device_mapping => [
88
- {"DeviceName"=>"/dev/sdi", "Ebs.SnapshotId"=>"snap-d9c1edb1", "Ebs.VolumeSize"=>50, "Ebs.DeleteOnTermination"=>"false"},
89
- {"DeviceName"=>"/dev/sdb", "VirtualName"=>"ephemeral0"},
90
- {"DeviceName"=>"/dev/sdc", "VirtualName"=>"ephemeral1"},
91
- {"DeviceName"=>"/dev/sdd", "VirtualName"=>"ephemeral2"},
92
- {"DeviceName"=>"/dev/sde", "VirtualName"=>"ephemeral3"},
93
- ],
94
- :availability_zone => "us-east-1d",
95
- :monitoring => nil
96
- }
97
- end
98
-
99
- it 'has right user_data' do
100
- hsh = @server.fog_launch_description
101
- user_data_hsh = JSON.parse( hsh[:user_data] )
102
- user_data_hsh.keys.should == ["chef_server", "validation_client_name", "validation_key", "attributes"]
103
- user_data_hsh["attributes"].keys.sort.should == [
104
- "cluster_name", "facet_name", "facet_index",
105
- "node_name",
106
- "webnode_count",
107
- ]
108
- end
109
- end
110
-
111
- end
112
- end
data/spec/ironfan_spec.rb DELETED
@@ -1,193 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- require IRONFAN_DIR("lib/ironfan")
4
-
5
- describe "ironfan" do
6
- describe 'successfuly runs example' do
7
-
8
- describe 'webserver_demo:' do
9
- before :all do
10
- @cluster = get_example_cluster(:webserver_demo)
11
- @cluster.resolve!
12
- end
13
-
14
- it 'loads successfuly' do
15
- @cluster.should be_a(Ironfan::Cluster)
16
- @cluster.name.should == :webserver_demo
17
- end
18
-
19
- it 'cluster is right' do
20
- @cluster.to_hash.should == {
21
- :name => :webserver_demo,
22
- :run_list => ["role[base_role]", "role[chef_client]", "role[ssh]", "role[nfs_client]", "role[big_package]", "role[webserver_demo_cluster]"],
23
- :chef_attributes => { :webnode_count => 6 },
24
- :facet_name => "webserver_demo_cluster",
25
- }
26
- end
27
-
28
- it 'defaults cluster' do
29
- defaults_cluster = Ironfan.cluster(:defaults)
30
- cloud_hash = defaults_cluster.cloud.to_hash
31
- [:security_groups, :user_data].each{|k| cloud_hash.delete k }
32
- cloud_hash.should == {
33
- :availability_zones => ['us-east-1d'],
34
- :region => "us-east-1",
35
- :flavor => "m1.small",
36
- :image_name => "lucid",
37
- :backing => "ebs",
38
- :disable_api_termination => false,
39
- :public_ip => false,
40
- :bootstrap_distro => "ubuntu10.04-ironfan",
41
- }
42
- end
43
-
44
- it 'cluster cloud is right' do
45
- cloud_hash = @cluster.cloud.to_hash
46
- [:security_groups, :user_data].each{|k| cloud_hash.delete k }
47
- cloud_hash.should == {
48
- :availability_zones => ['us-east-1d'],
49
- :region => "us-east-1",
50
- :flavor => "t1.micro",
51
- :image_name => "maverick",
52
- :backing => "instance",
53
- :disable_api_termination => false,
54
- :public_ip => false,
55
- :bootstrap_distro => "ubuntu10.04-ironfan",
56
- :keypair => :webserver_demo,
57
- }
58
- end
59
-
60
- it 'facet cloud is right' do
61
- cloud_hash = @cluster.facet(:webnode).cloud.to_hash
62
- [:security_groups, :user_data].each{|k| cloud_hash.delete k }
63
- cloud_hash.should == {
64
- :backing => "ebs",
65
- }
66
- end
67
-
68
- it 'webnode facets are right' do
69
- @cluster.facets.length.should == 3
70
- fct = @cluster.facet(:webnode)
71
- fct.to_hash.should == {
72
- :name => :webnode,
73
- :run_list => ["role[nginx]", "role[redis_client]", "role[mysql_client]", "role[elasticsearch_client]", "role[awesome_website]", "role[webserver_demo_webnode]"],
74
- :chef_attributes => {:split_testing=>{:group=>"A"}},
75
- :facet_role => "webserver_demo_webnode",
76
- :instances => 6,
77
- }
78
- end
79
-
80
- it 'dbnode facets are right' do
81
- fct = @cluster.facet(:dbnode)
82
- fct.to_hash.should == {
83
- :name => :dbnode,
84
- :run_list => ["role[mysql_server]", "role[redis_client]", "role[webserver_demo_dbnode]" ],
85
- :chef_attributes => {},
86
- :facet_role => "webserver_demo_dbnode",
87
- :instances => 2,
88
- }
89
- fct.cloud.flavor.should == 'c1.xlarge'
90
- fct.server(0).cloud.flavor.should == 'm1.large'
91
- end
92
-
93
- it 'esnode facets are right' do
94
- fct = @cluster.facet(:esnode)
95
- fct.to_hash.should == {
96
- :name => :esnode,
97
- :run_list => ["role[nginx]", "role[redis_server]", "role[elasticsearch_datanode]", "role[elasticsearch_httpnode]", "role[webserver_demonode]"],
98
- :chef_attributes => {},
99
- :facet_role => "webserver_demonode",
100
- :instances => 1,
101
- }
102
- fct.cloud.flavor.should == 'm1.large'
103
- end
104
-
105
- it 'cluster security groups are right' do
106
- gg = @cluster.security_groups
107
- gg.keys.should == ['default', 'ssh', 'nfs_client', 'webserver_demo']
108
- end
109
-
110
- it 'facet webnode security groups are right' do
111
- gg = @cluster.facet(:webnode).security_groups
112
- gg.keys.sort.should == ["default", "webserver_demo", "webserver_demo-awesome_website", "webserver_demo-redis_client", "webserver_demo-webnode", "nfs_client", "ssh"]
113
- gg['webserver_demo-awesome_website'].range_authorizations.should == [[80..80, "0.0.0.0/0", "tcp"], [443..443, "0.0.0.0/0", "tcp"]]
114
- end
115
-
116
- it 'facet dbnode security groups are right' do
117
- gg = @cluster.facet(:dbnode).security_groups
118
- gg.keys.sort.should == ["default", "webserver_demo", "webserver_demo-dbnode", "webserver_demo-redis_client", "nfs_client", "ssh"]
119
- end
120
-
121
- it 'facet esnode security groups are right' do
122
- gg = @cluster.facet(:esnode).security_groups
123
- gg.keys.sort.should == ["default", "webserver_demo", "webserver_demo-esnode", "webserver_demo-redis_server", "nfs_client", "ssh"]
124
- gg['webserver_demo-redis_server'][:name].should == "webserver_demo-redis_server"
125
- gg['webserver_demo-redis_server'][:description].should == "ironfan generated group webserver_demo-redis_server"
126
- gg['webserver_demo-redis_server'].group_authorizations.should == [['webserver_demo-redis_client', nil]]
127
- end
128
-
129
- it 'has servers' do
130
- @cluster.servers.map(&:fullname).should == [
131
- "webserver_demo-dbnode-0", "webserver_demo-dbnode-1",
132
- "webserver_demo-esnode-0",
133
- "webserver_demo-webnode-0", "webserver_demo-webnode-1", "webserver_demo-webnode-2", "webserver_demo-webnode-3", "webserver_demo-webnode-4", "webserver_demo-webnode-5"
134
- ]
135
- end
136
-
137
- describe 'resolving servers gets right' do
138
- before do
139
- @server = @cluster.slice(:webnode, 5).first
140
- @server.cloud.stub!(:validation_key).and_return("I_AM_VALID")
141
- @server.resolve!
142
- end
143
-
144
- it 'attributes' do
145
- @server.to_hash.should == {
146
- :name => 'webserver_demo-webnode-5',
147
- :run_list => ["role[base_role]", "role[chef_client]", "role[ssh]", "role[nfs_client]", "role[big_package]", "role[webserver_demo_cluster]", "role[nginx]", "role[redis_client]", "role[mysql_client]", "role[elasticsearch_client]", "role[awesome_website]", "role[webserver_demo_webnode]"],
148
- :instances => 6,
149
- :chef_attributes => {
150
- :split_testing => {:group=>"B"},
151
- :webnode_count => 6,
152
- :node_name => "webserver_demo-webnode-5",
153
- :cluster_name => :webserver_demo, :facet_name => :webnode, :facet_index => 5,
154
- },
155
- }
156
- end
157
-
158
- it 'security groups' do
159
- @server.security_groups.keys.sort.should == ['default', 'webserver_demo', 'webserver_demo-awesome_website', 'webserver_demo-redis_client', 'webserver_demo-webnode', 'nfs_client', 'ssh']
160
- end
161
- it 'run list' do
162
- @server.run_list.should == ["role[base_role]", "role[chef_client]", "role[ssh]", "role[nfs_client]", "role[big_package]", "role[webserver_demo_cluster]", "role[nginx]", "role[redis_client]", "role[mysql_client]", "role[elasticsearch_client]", "role[awesome_website]", "role[webserver_demo_webnode]"]
163
- end
164
-
165
- it 'user_data' do
166
- @server.cloud.user_data.should == {
167
- "chef_server" => "https://api.opscode.com/organizations/infochimps",
168
- "validation_client_name" => "chef-validator",
169
- "validation_key" => "I_AM_VALID",
170
- }
171
- end
172
-
173
- it 'cloud settings' do
174
- hsh = @server.cloud.to_hash
175
- hsh.delete(:security_groups)
176
- hsh.delete(:user_data)
177
- hsh.should == {
178
- :availability_zones => ["us-east-1c"],
179
- :region => "us-east-1",
180
- :flavor => "t1.micro",
181
- :image_name => "maverick",
182
- :backing => "ebs",
183
- :disable_api_termination => false,
184
- :public_ip => false,
185
- :bootstrap_distro => "ubuntu10.04-ironfan",
186
- :keypair => :webserver_demo,
187
- }
188
- end
189
-
190
- end
191
- end
192
- end
193
- end