spec/poolparty/spec_helper.rb in poolparty-0.2.69 vs spec/poolparty/spec_helper.rb in poolparty-0.2.84
- old
+ new
@@ -14,10 +14,28 @@
ENV["POOL_SPEC"] = nil
include PoolParty
extend PoolParty
+def are_too_many_instances_running?
+end
+def are_any_nodes_exceeding_minimum_runtime?
+end
+def are_too_few_instances_running?
+end
+
+class TestClass < PoolParty::Cloud::Cloud
+ include CloudResourcer
+ attr_accessor :parent
+ def initialize(&block)
+ super :test_cloud, nil, &block
+ end
+ def keypair
+ "fake_keypair"
+ end
+end
+
def setup
PoolParty::Messenger.stub!(:messenger_send!).and_return false
end
def setup_cl
@@ -49,39 +67,61 @@
end
def read_file(path)
require "open-uri"
open(path).read
end
+def sample_instances_list
+ @sample_instances_lister ||= [
+ {:ip => "127.0.0.1", :name => "master", :launching_time => 2.days.ago},
+ {:ip => "127.0.0.2", :name => "node1", :launching_time => 2.days.ago}
+ ]
+end
+def sample_instances
+ sample_instances_list.map {|h| PoolParty::Remote::RemoteInstance.new(h) }
+end
def stub_list_from_local_for(o)
@list =<<-EOS
master 192.168.0.1
node1 192.168.0.2
EOS
@file = "filename"
@file.stub!(:read).and_return @list
o.stub!(:get_working_listing_file).and_return @file
o.stub!(:open).and_return @file
-
+
@ris = @list.split(/\n/).map {|line| PoolParty::Remote::RemoteInstance.new(line) }
end
def stub_remoter_for(o)
- o.stub!(:ec2).and_return EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "even more not a key")
+ o.stub!(:ec2).and_return EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "even more not a key")
+ o.stub!(:list_of_running_instances).and_return sample_instances
end
def stub_list_from_remote_for(o, launch_stub=true)
stub_remoter_for(o)
- @sample_instances_list = [{:ip => "127.0.0.1", :name => "master"}, {:ip => "127.0.0.2", :name => "node1"}]
- @ris = @sample_instances_list.map {|h| PoolParty::Remote::RemoteInstance.new(h) }
o.stub!(:access_key).and_return "NOT A KEY"
o.stub!(:secret_access_key).and_return "NOT A SECRET"
# o.stub!(:list_from_remote).and_return ris
# o.stub!(:remote_instances_list).once.and_return ris
# o.stub!(:master).and_return @ris[0]
- o.stub!(:launch_new_instance!).and_return true if launch_stub
+ o.stub!(:launch_new_instance!).and_return sample_instances.first if launch_stub
stub_list_of_instances_for(o)
+ stub_remoting_methods_for(o)
end
-
+def stub_remoting_methods_for(o)
+ o.stub!(:keypair).and_return "fake_keypair"
+ o.stub!(:keypair_path).and_return "~/.ec2/fake_keypair"
+ o.stub!(:other_clouds).and_return []
+ o.stub!(:expand_when).and_return "cpu > 10"
+ o.stub!(:copy_file_to_storage_directory).and_return true
+ o.stub!(:rsync_storage_files_to).and_return true
+ o.stub!(:minimum_runnable_options).and_return []
+ o.stub!(:build_and_store_new_config_file).and_return true
+ o.stub!(:process_clean_reconfigure_for!).and_return true
+ o.stub!(:before_install).and_return true
+ o.stub!(:process_install).and_return true
+ o.stub!(:after_install).and_return true
+end
def stub_list_of_instances_for(o)
# o.stub!(:list_of_running_instances).once.and_return running_remote_instances
o.stub!(:keypair).and_return "fake_keypair"
o.stub!(:describe_instances).and_return response_list_of_instances
end
@@ -107,10 +147,12 @@
end
def add_stub_instance_to(o, num, status="running")
reset_response!
response_list_of_instances << stub_instance(num, status)
+ sample_instances_list << stub_instance(num, status)
stub_list_of_instances_for o
+ stub_remoter_for(o)
end
def ris
@ris ||= response_list_of_instances.collect {|h| PoolParty::Remote::RemoteInstance.new(h) }
end
def remove_stub_instance_from(o, num)
\ No newline at end of file