2013-06-01 01:20:09 +00:00
|
|
|
module AWS
|
|
|
|
class FakeELB
|
|
|
|
def initialize
|
|
|
|
end
|
|
|
|
|
|
|
|
class LoadBalancer
|
2013-06-04 02:08:56 +00:00
|
|
|
attr_reader :name
|
|
|
|
|
2013-06-01 01:20:09 +00:00
|
|
|
def initialize(name, options = {})
|
2013-06-04 02:08:56 +00:00
|
|
|
@name = name
|
2013-06-01 01:20:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def instances
|
|
|
|
@instances ||= InstanceCollection.new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-04 01:51:01 +00:00
|
|
|
class LoadBalancerCollection < Array
|
|
|
|
def initialize
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-03 23:19:03 +00:00
|
|
|
class InstanceCollection < Array
|
2013-06-01 01:20:09 +00:00
|
|
|
def initialize
|
|
|
|
end
|
|
|
|
|
2013-06-03 23:19:03 +00:00
|
|
|
def register(*instances)
|
|
|
|
self.concat instances
|
|
|
|
end
|
|
|
|
|
|
|
|
def deregister(*instances)
|
|
|
|
instances.each do |i|
|
|
|
|
self.delete i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-01 01:20:09 +00:00
|
|
|
def health
|
|
|
|
@health ||= [
|
|
|
|
{
|
|
|
|
instance: AWS::FakeEC2::Instance.new,
|
|
|
|
description: 'N/A',
|
|
|
|
state: 'InService',
|
|
|
|
reason_code: 'N/A'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
instance: AWS::FakeEC2::Instance.new,
|
|
|
|
description: 'Instance has failed at least the UnhealthyThreshold number of health checks consecutively.',
|
|
|
|
state: 'OutOfService',
|
|
|
|
reason_code: 'Instance'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|