Skip to content
Browse files

Remove all defunct tests and start fresh.

  • Loading branch information...
1 parent b2635e3 commit 55c014c8db115b594f9a8a0b770cd80fcb140ebe @fractaloop fractaloop committed
View
3 .rspec
@@ -1,3 +1,2 @@
--color
---format documentation
---drb
+--format documentation
View
4 Rakefile
@@ -64,9 +64,7 @@ Jeweler::RubygemsDotOrgTasks.new
#
# RSpec -- testing
#
-RSpec::Core::RakeTask.new(:spec) do |spec|
- spec.pattern = FileList['spec/**/*_spec.rb']
-end
+RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:rcov) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
View
4 lib/chef/knife/cluster_proxy.rb
@@ -48,7 +48,7 @@ class ClusterProxy < Ironfan::Script
:default => '6666'
def relevant?(server)
- server.sshable?
+ server.machine.running?
end
def perform_execution(target)
@@ -62,7 +62,7 @@ def perform_execution(target)
def command_for_target(svr)
config[:attribute] ||= Chef::Config[:knife][:ssh_address_attribute] || "fqdn"
config[:ssh_user] ||= Chef::Config[:knife][:ssh_user]
- config[:identity_file] ||= svr.cloud.ssh_identity_file
+ config[:identity_file] ||= svr.server.cloud.ssh_identity_file
config[:host_key_verify] ||= Chef::Config[:knife][:host_key_verify] || (not config[:no_host_key_verify]) # pre-vs-post 0.10.4
address = svr.public_hostname
View
25 spec/ironfan/cluster_spec.rb
@@ -1,13 +1,22 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
-require IRONFAN_DIR("lib/ironfan")
+require 'ironfan'
-describe Ironfan::Cluster do
- describe 'discover!' do
- let(:cluster){ get_example_cluster(:monkeyballs) }
-
- it 'enumerates chef nodes' do
- cluster.discover!
+describe Ironfan::Dsl::Cluster do
+ describe 'run lists' do
+ subject do
+ Ironfan.cluster 'foo' do
+ environment :dev
+
+ role :systemwide
+
+ facet :bar do
+ instances 1
+ role :nfs_client, :first
+ end
+ end
end
+
+ its(:run_list) { should eql ["role[systemwide]"] }
end
end
View
69 spec/ironfan/facet_spec.rb
@@ -1,69 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-
-require IRONFAN_DIR("lib/ironfan")
-
-describe Ironfan::Facet do
- let(:cluster){ Ironfan.cluster(:gibbon) }
- let(:facet){
- cluster.facet(:namenode) do
- instances 5
- end
- }
-
- describe 'slicing' do
- it 'has servers' do
- facet.indexes.should == [0, 1, 2, 3, 4]
- facet.valid_indexes.should == [0, 1, 2, 3, 4]
- facet.server(3){ name(:bob) }
- svrs = facet.servers
- svrs.length.should == 5
- svrs.map{|svr| svr.name }.should == ["gibbon-namenode-0", "gibbon-namenode-1", "gibbon-namenode-2", :bob, "gibbon-namenode-4"]
- end
-
- it 'servers have bogosity if out of range' do
- facet.server(69).should be_bogus
- facet.servers.select(&:bogus?).map(&:facet_index).should == [69]
- facet.indexes.should == [0, 1, 2, 3, 4, 69]
- facet.valid_indexes.should == [0, 1, 2, 3, 4]
- end
-
- it 'returns all on nil or "", but [] means none' do
- facet.server(69)
- facet.slice('' ).map(&:facet_index).should == [0, 1, 2, 3, 4, 69]
- facet.slice(nil).map(&:facet_index).should == [0, 1, 2, 3, 4, 69]
- facet.slice([] ).map(&:facet_index).should == []
- end
-
- it 'slice returns all by default' do
- facet.server(69)
- facet.slice().map(&:facet_index).should == [0, 1, 2, 3, 4, 69]
- end
-
- it 'with an array returns specified indexes (bogus or not) in sorted order' do
- facet.server(69)
- facet.slice( [3, 1, 0] ).map(&:facet_index).should == [0, 1, 3]
- facet.slice( [3, 1, 69, 0] ).map(&:facet_index).should == [0, 1, 3, 69]
- end
-
- it 'with an array does not create new dummy servers' do
- facet.server(69)
- facet.slice( [3, 1, 69, 0, 75, 123] ).map(&:facet_index).should == [0, 1, 3, 69]
- facet.has_server?(75).should be_false
- facet.has_server?(69).should be_true
- end
-
- it 'with a string, converts to intervals' do
- facet.slice('1' ).map(&:facet_index).should == [1]
- facet.slice('5' ).map(&:facet_index).should == []
- facet.slice('1-1' ).map(&:facet_index).should == [1]
- facet.slice('0-1' ).map(&:facet_index).should == [0,1]
- facet.slice('0-1,3-4').map(&:facet_index).should == [0,1,3,4]
- facet.slice('0-1,69' ).map(&:facet_index).should == [0,1,69]
- facet.slice('0-2,1-3').map(&:facet_index).should == [0,1,2,3]
- facet.slice('3-1' ).map(&:facet_index).should == []
- facet.slice('2-5' ).map(&:facet_index).should == [2,3,4]
- facet.slice(1).map(&:facet_index).should == [1]
- end
-
- end
-end
View
19 spec/ironfan/server_slice_spec.rb
@@ -1,19 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-require IRONFAN_DIR("lib/ironfan")
-
-describe Ironfan::ServerSlice do
- before do
- @slice = Ironfan.slice('webserver_demo')
- end
-
- describe 'attributes' do
- it 'security groups' do
- @slice.security_groups.keys.sort.should == [
- "default",
- "webserver_demo", "webserver_demo-awesome_website", "webserver_demo-dbnode", "webserver_demo-esnode",
- "webserver_demo-redis_client", "webserver_demo-redis_server",
- "webserver_demo-webnode", "nfs_client", "ssh"
- ]
- end
- end
-end
View
112 spec/ironfan/server_spec.rb
@@ -1,112 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-require IRONFAN_DIR("lib/ironfan")
-
-describe Ironfan::Server do
- include_context 'dummy_chef'
-
- Ironfan::Server.class_eval do
- def chef_node
- Chef::Node.new
- end
- end
-
- Ironfan::DryRunnable.class_eval do
- def unless_dry_run
- puts "Not doing that"
- end
- end
-
- before do
- Ironfan::Server.stub!(:chef_node).and_return( "HI" )
- Chef::Config.stub!(:validation_key).and_return("I_AM_VALID")
-
- foo = Ironfan::Server.new(Ironfan::Facet.new(Ironfan::Cluster.new('hi'),'there'),0)
- puts foo.inspect
- puts foo.chef_node
- @cluster = get_example_cluster('webserver_demo')
- @cluster.resolve!
- @facet = @cluster.facet(:dbnode)
- @server = @facet.server(0)
- end
-
- describe 'volumes' do
- describe '#composite_volumes' do
- it 'assembles cluster, facet and server volumes' do
- @server.composite_volumes.length.should == 5
- @cluster.volumes.length.should == 4
- @facet.volumes.length.should == 1
- @server.volumes.length.should == 1
- end
-
- it 'composites server attributes onto a volume defined in the facet' do
- vol = @server.composite_volumes[:data]
- vol.to_hash.should == {
- :name => :data,
- :tags => {},
- :snapshot_id => "snap-d9c1edb1",
- :size => 50,
- :keep => true,
- :device => "/dev/sdi",
- :mount_point => "/data/db",
- :mount_options => "defaults,nouuid,noatime",
- :fs_type => "xfs",
- :availability_zone => "us-east-1d"
- }
- end
-
- it 'makes block_device_mapping for non-ephemeral storage' do
- vol = @server.composite_volumes[:data]
- vol.block_device_mapping.should == {
- "DeviceName" => "/dev/sdi",
- "Ebs.SnapshotId" => "snap-d9c1edb1",
- "Ebs.VolumeSize" => 50,
- "Ebs.DeleteOnTermination" => "false"
- }
- end
-
- it 'skips block_device_mapping for non-ephemeral storage if volume id is present' do
- vol = @facet.server(1).composite_volumes[:data]
- vol.block_device_mapping.should be_nil
- end
-
- end
- end
-
- describe 'launch' do
- describe '#fog_launch_description' do
- it 'has right attributes' do
-
- hsh = @server.fog_launch_description
- hsh.delete(:user_data)
- hsh.should == {
- :image_id => "ami-08f40561",
- :flavor_id => "m1.large",
- :groups => ["webserver_demo-redis_client", "webserver_demo-dbnode", "default", "ssh", "nfs_client", "webserver_demo"],
- :key_name => :webserver_demo,
- :tags => {:cluster=>:webserver_demo, :facet=>:dbnode, :index=>0},
- :block_device_mapping => [
- {"DeviceName"=>"/dev/sdi", "Ebs.SnapshotId"=>"snap-d9c1edb1", "Ebs.VolumeSize"=>50, "Ebs.DeleteOnTermination"=>"false"},
- {"DeviceName"=>"/dev/sdb", "VirtualName"=>"ephemeral0"},
- {"DeviceName"=>"/dev/sdc", "VirtualName"=>"ephemeral1"},
- {"DeviceName"=>"/dev/sdd", "VirtualName"=>"ephemeral2"},
- {"DeviceName"=>"/dev/sde", "VirtualName"=>"ephemeral3"},
- ],
- :availability_zone => "us-east-1d",
- :monitoring => nil
- }
- end
-
- it 'has right user_data' do
- hsh = @server.fog_launch_description
- user_data_hsh = JSON.parse( hsh[:user_data] )
- user_data_hsh.keys.should == ["chef_server", "validation_client_name", "validation_key", "attributes"]
- user_data_hsh["attributes"].keys.sort.should == [
- "cluster_name", "facet_name", "facet_index",
- "node_name",
- "webnode_count",
- ]
- end
- end
-
- end
-end
View
193 spec/ironfan_spec.rb
@@ -1,193 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-
-require IRONFAN_DIR("lib/ironfan")
-
-describe "ironfan" do
- describe 'successfuly runs example' do
-
- describe 'webserver_demo:' do
- before :all do
- @cluster = get_example_cluster(:webserver_demo)
- @cluster.resolve!
- end
-
- it 'loads successfuly' do
- @cluster.should be_a(Ironfan::Cluster)
- @cluster.name.should == :webserver_demo
- end
-
- it 'cluster is right' do
- @cluster.to_hash.should == {
- :name => :webserver_demo,
- :run_list => ["role[base_role]", "role[chef_client]", "role[ssh]", "role[nfs_client]", "role[big_package]", "role[webserver_demo_cluster]"],
- :chef_attributes => { :webnode_count => 6 },
- :facet_name => "webserver_demo_cluster",
- }
- end
-
- it 'defaults cluster' do
- defaults_cluster = Ironfan.cluster(:defaults)
- cloud_hash = defaults_cluster.cloud.to_hash
- [:security_groups, :user_data].each{|k| cloud_hash.delete k }
- cloud_hash.should == {
- :availability_zones => ['us-east-1d'],
- :region => "us-east-1",
- :flavor => "m1.small",
- :image_name => "lucid",
- :backing => "ebs",
- :disable_api_termination => false,
- :public_ip => false,
- :bootstrap_distro => "ubuntu10.04-ironfan",
- }
- end
-
- it 'cluster cloud is right' do
- cloud_hash = @cluster.cloud.to_hash
- [:security_groups, :user_data].each{|k| cloud_hash.delete k }
- cloud_hash.should == {
- :availability_zones => ['us-east-1d'],
- :region => "us-east-1",
- :flavor => "t1.micro",
- :image_name => "maverick",
- :backing => "instance",
- :disable_api_termination => false,
- :public_ip => false,
- :bootstrap_distro => "ubuntu10.04-ironfan",
- :keypair => :webserver_demo,
- }
- end
-
- it 'facet cloud is right' do
- cloud_hash = @cluster.facet(:webnode).cloud.to_hash
- [:security_groups, :user_data].each{|k| cloud_hash.delete k }
- cloud_hash.should == {
- :backing => "ebs",
- }
- end
-
- it 'webnode facets are right' do
- @cluster.facets.length.should == 3
- fct = @cluster.facet(:webnode)
- fct.to_hash.should == {
- :name => :webnode,
- :run_list => ["role[nginx]", "role[redis_client]", "role[mysql_client]", "role[elasticsearch_client]", "role[awesome_website]", "role[webserver_demo_webnode]"],
- :chef_attributes => {:split_testing=>{:group=>"A"}},
- :facet_role => "webserver_demo_webnode",
- :instances => 6,
- }
- end
-
- it 'dbnode facets are right' do
- fct = @cluster.facet(:dbnode)
- fct.to_hash.should == {
- :name => :dbnode,
- :run_list => ["role[mysql_server]", "role[redis_client]", "role[webserver_demo_dbnode]" ],
- :chef_attributes => {},
- :facet_role => "webserver_demo_dbnode",
- :instances => 2,
- }
- fct.cloud.flavor.should == 'c1.xlarge'
- fct.server(0).cloud.flavor.should == 'm1.large'
- end
-
- it 'esnode facets are right' do
- fct = @cluster.facet(:esnode)
- fct.to_hash.should == {
- :name => :esnode,
- :run_list => ["role[nginx]", "role[redis_server]", "role[elasticsearch_datanode]", "role[elasticsearch_httpnode]", "role[webserver_demonode]"],
- :chef_attributes => {},
- :facet_role => "webserver_demonode",
- :instances => 1,
- }
- fct.cloud.flavor.should == 'm1.large'
- end
-
- it 'cluster security groups are right' do
- gg = @cluster.security_groups
- gg.keys.should == ['default', 'ssh', 'nfs_client', 'webserver_demo']
- end
-
- it 'facet webnode security groups are right' do
- gg = @cluster.facet(:webnode).security_groups
- gg.keys.sort.should == ["default", "webserver_demo", "webserver_demo-awesome_website", "webserver_demo-redis_client", "webserver_demo-webnode", "nfs_client", "ssh"]
- gg['webserver_demo-awesome_website'].range_authorizations.should == [[80..80, "0.0.0.0/0", "tcp"], [443..443, "0.0.0.0/0", "tcp"]]
- end
-
- it 'facet dbnode security groups are right' do
- gg = @cluster.facet(:dbnode).security_groups
- gg.keys.sort.should == ["default", "webserver_demo", "webserver_demo-dbnode", "webserver_demo-redis_client", "nfs_client", "ssh"]
- end
-
- it 'facet esnode security groups are right' do
- gg = @cluster.facet(:esnode).security_groups
- gg.keys.sort.should == ["default", "webserver_demo", "webserver_demo-esnode", "webserver_demo-redis_server", "nfs_client", "ssh"]
- gg['webserver_demo-redis_server'][:name].should == "webserver_demo-redis_server"
- gg['webserver_demo-redis_server'][:description].should == "ironfan generated group webserver_demo-redis_server"
- gg['webserver_demo-redis_server'].group_authorizations.should == [['webserver_demo-redis_client', nil]]
- end
-
- it 'has servers' do
- @cluster.servers.map(&:fullname).should == [
- "webserver_demo-dbnode-0", "webserver_demo-dbnode-1",
- "webserver_demo-esnode-0",
- "webserver_demo-webnode-0", "webserver_demo-webnode-1", "webserver_demo-webnode-2", "webserver_demo-webnode-3", "webserver_demo-webnode-4", "webserver_demo-webnode-5"
- ]
- end
-
- describe 'resolving servers gets right' do
- before do
- @server = @cluster.slice(:webnode, 5).first
- @server.cloud.stub!(:validation_key).and_return("I_AM_VALID")
- @server.resolve!
- end
-
- it 'attributes' do
- @server.to_hash.should == {
- :name => 'webserver_demo-webnode-5',
- :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]"],
- :instances => 6,
- :chef_attributes => {
- :split_testing => {:group=>"B"},
- :webnode_count => 6,
- :node_name => "webserver_demo-webnode-5",
- :cluster_name => :webserver_demo, :facet_name => :webnode, :facet_index => 5,
- },
- }
- end
-
- it 'security groups' do
- @server.security_groups.keys.sort.should == ['default', 'webserver_demo', 'webserver_demo-awesome_website', 'webserver_demo-redis_client', 'webserver_demo-webnode', 'nfs_client', 'ssh']
- end
- it 'run list' do
- @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]"]
- end
-
- it 'user_data' do
- @server.cloud.user_data.should == {
- "chef_server" => "https://api.opscode.com/organizations/infochimps",
- "validation_client_name" => "chef-validator",
- "validation_key" => "I_AM_VALID",
- }
- end
-
- it 'cloud settings' do
- hsh = @server.cloud.to_hash
- hsh.delete(:security_groups)
- hsh.delete(:user_data)
- hsh.should == {
- :availability_zones => ["us-east-1c"],
- :region => "us-east-1",
- :flavor => "t1.micro",
- :image_name => "maverick",
- :backing => "ebs",
- :disable_api_termination => false,
- :public_ip => false,
- :bootstrap_distro => "ubuntu10.04-ironfan",
- :keypair => :webserver_demo,
- }
- end
-
- end
- end
- end
-end
View
37 spec/spec_helper.rb
@@ -1,42 +1,7 @@
-require 'rubygems' unless defined?(Gem)
-require 'bundler'
-begin
- Bundler.setup(:default, :development)
-rescue Bundler::BundlerError => e
- $stderr.puts e.message
- $stderr.puts "Run `bundle install` to install missing gems"
- exit e.status_code
-end
-
-require 'rspec'
+$:.unshift File.expand_path('../../lib', __FILE__)
require 'chef'
require 'chef/knife'
require 'fog'
-unless defined?(IRONFAN_DIR)
- IRONFAN_DIR = File.expand_path(File.dirname(__FILE__)+'/..')
- def IRONFAN_DIR(*paths) File.join(IRONFAN_DIR, *paths); end
- # load from vendored libraries, if present
- Dir[IRONFAN_DIR("vendor/*/lib")].each{|dir| p dir ; $LOAD_PATH.unshift(File.expand_path(dir)) } ; $LOAD_PATH.uniq!
-end
-
Fog.mock!
Fog::Mock.delay = 0
-
-CHEF_CONFIG_FILE = File.expand_path(IRONFAN_DIR('spec/test_config.rb')) unless defined?(CHEF_CONFIG_FILE)
-Chef::Config.from_file(CHEF_CONFIG_FILE)
-
-# Requires custom matchers & macros, etc from files in ./spec_helper/
-Dir[IRONFAN_DIR("spec/spec_helper/*.rb")].each {|f| require f}
-
-def load_example_cluster(name)
- require(IRONFAN_DIR('clusters', "#{name}.rb"))
-end
-def get_example_cluster name
- load_example_cluster(name)
- Ironfan.cluster(name)
-end
-
-# Configure rspec
-RSpec.configure do |config|
-end

0 comments on commit 55c014c

Please sign in to comment.
Something went wrong with that request. Please try again.