1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

initial import

* take the liberty of correcting Aws naming
This commit is contained in:
Josh Lane 2014-12-30 14:25:09 -08:00
parent 095fa8763f
commit d48d376e9c
1261 changed files with 72105 additions and 5 deletions

View file

@ -0,0 +1,69 @@
Shindo.tests("Fog::AWS[:beanstalk] | application", ['aws', 'beanstalk']) do
pending if Fog.mocking?
@application_opts = {
:name => uniq_id('fog-test-app'),
:description => 'A nice description.'
}
model_tests(Fog::AWS[:beanstalk].applications, @application_opts, false) do
test("#attributes") do
@instance.name == @application_opts[:name] &&
@instance.description == @application_opts[:description]
end
test("#events") do
# There should be some events now.
@instance.events.length > 0
end
version_name = uniq_id('fog-test-ver')
@instance.versions.create(
:application_name => @instance.name,
:label => version_name
)
test("#versions") do
# We should have one version.
@instance.versions.length == 1
end
template_name = uniq_id('fog-test-template')
@instance.templates.create(
:application_name => @instance.name,
:name => template_name,
:solution_stack_name => '32bit Amazon Linux running Tomcat 7'
)
test('#templates') do
# We should have one template now.
@instance.templates.length == 1
end
environment_name = uniq_id('fog-test-env')
environment = @instance.environments.create(
:application_name => @instance.name,
:name => environment_name,
:version_label => version_name,
:solution_stack_name => '32bit Amazon Linux running Tomcat 7'
)
# Go ahead an terminate immediately.
environment.destroy
# Create an environment
test("#environments") do
# We should have one environment now.
@instance.environments.length == 1
end
# Must wait for termination before destroying application
tests("waiting for test environment to terminate").succeeds do
environment.wait_for { terminated? }
end
end
end

View file

@ -0,0 +1,7 @@
Shindo.tests("Fog::AWS[:beanstalk] | applications", ['aws', 'beanstalk']) do
pending if Fog.mocking?
collection_tests(Fog::AWS[:beanstalk].applications, {:name => uniq_id('fog-test-app')}, false)
end

View file

@ -0,0 +1,131 @@
Shindo.tests("Fog::AWS[:beanstalk] | environment", ['aws', 'beanstalk']) do
pending if Fog.mocking?
@beanstalk = Fog::AWS[:beanstalk]
@application_name = uniq_id('fog-test-app')
@environment_name = uniq_id('fog-test-env')
@version_names = []
# Create two unique version names
2.times {
@version_names << uniq_id('fog-test-version')
}
@application = @beanstalk.applications.create({:name => @application_name})
@versions = []
@version_names.each { |name|
@versions << @beanstalk.versions.create({
:label => name,
:application_name => @application_name,
})
}
@environment_opts = {
:application_name => @application_name,
:name => @environment_name,
:version_label => @version_names[0],
:solution_stack_name => '32bit Amazon Linux running Tomcat 7'
}
# Note: These model tests can take quite a bit of time to run, about 10 minutes typically.
model_tests(@beanstalk.environments, @environment_opts, false) do
# Wait for initial ready before next tests.
tests("#ready?").succeeds do
@instance.wait_for { ready? }
end
tests("#healthy?").succeeds do
@instance.wait_for { healthy? }
end
test("#events") do
# There should be some events now.
@instance.events.length > 0
end
test("#version") do
@instance.version.label == @version_names[0]
end
test("#version= string") do
# Set to version 2
@instance.version = @version_names[1]
count = 0
if @instance.version.label == @version_names[1]
@instance.events.each { |event|
if event.message == "Environment update is starting."
count = count + 1
end
}
end
count == 1
end
tests("#ready? after version= string").succeeds do
@instance.wait_for { ready? }
end
test("#version= version object") do
# reset back to first version using version object
@instance.version = @versions[0]
count = 0
if @instance.version.label == @version_names[0]
@instance.events.each { |event|
if event.message == "Environment update is starting."
count = count + 1
end
}
end
# Pass if we have two environment updating events
count == 2
end
tests("#ready? after version= version object").succeeds do
@instance.wait_for { ready? }
end
test('#restart_app_server') do
@instance.restart_app_server
passed = false
@instance.events.each { |event|
if event.message == "restartAppServer is starting."
passed = true
end
}
passed
end
test('#rebuild') do
@instance.rebuild
passed = false
@instance.events.each { |event|
if event.message == "rebuildEnvironment is starting."
passed = true
end
}
passed
end
# Wait for ready or next tests may fail
tests("#ready? after rebuild").succeeds do
@instance.wait_for { ready? }
end
end
# Wait for instance to terminate before deleting application
tests('#terminated?').succeeds do
@instance.wait_for { terminated? }
end
# delete application
@application.destroy
end

View file

@ -0,0 +1,34 @@
Shindo.tests("Fog::AWS[:beanstalk] | environments", ['aws', 'beanstalk']) do
pending if Fog.mocking?
@beanstalk = Fog::AWS[:beanstalk]
@application_name = uniq_id('fog-test-app')
@environment_name = uniq_id('fog-test-env')
@version_name = uniq_id('fog-test-version')
# Create an application/version to use for testing.
@version = @beanstalk.versions.create({
:label => @version_name,
:application_name => @application_name,
:auto_create_application => true
})
@application = @beanstalk.applications.get(@application_name)
@environment_opts = {
:application_name => @application_name,
:name => @environment_name,
:version_label => @version_name,
:solution_stack_name => '32bit Amazon Linux running Tomcat 7'
}
collection_tests(@beanstalk.environments, @environment_opts, false)
# Wait for instance to terminate before deleting application
@instance.wait_for { terminated? }
# delete application
@application.destroy
end

View file

@ -0,0 +1,47 @@
Shindo.tests("Fog::AWS[:beanstalk] | template", ['aws', 'beanstalk']) do
pending if Fog.mocking?
@beanstalk = Fog::AWS[:beanstalk]
@application_name = uniq_id('fog-test-app')
@template_name = uniq_id('fog-test-template')
@template_description = 'A nice description'
@application = @beanstalk.applications.create({:name => @application_name})
@template_opts = {
:application_name => @application_name,
:name => @template_name,
:description => @template_description,
:solution_stack_name => '32bit Amazon Linux running Tomcat 7'
}
model_tests(@beanstalk .templates, @template_opts, false) do
test("#attributes") do
@instance.name == @template_name &&
@instance.description == @template_description &&
@instance.application_name == @application_name &&
@instance.solution_stack_name == @template_opts[:solution_stack_name]
end
test("#options") do
options = @instance.options
passed = false
if options.each { |option|
# See if we recognize at least one option
if option["Name"] == 'LoadBalancerHTTPPort' && option["Namespace"] == 'aws:elb:loadbalancer'
passed = true
end
}
end
passed
end
end
# delete application
@application.destroy
end

View file

@ -0,0 +1,62 @@
Shindo.tests("Fog::AWS[:beanstalk] | templates", ['aws', 'beanstalk']) do
pending if Fog.mocking?
@beanstalk = Fog::AWS[:beanstalk]
@application_name = uniq_id('fog-test-app')
@template_name = uniq_id('fog-test-template')
@template_description = 'A nice description'
@application = @beanstalk.applications.create({:name => @application_name})
params = {
:application_name => @application_name,
:name => @template_name,
:description => @template_description,
:solution_stack_name => '32bit Amazon Linux running Tomcat 7'
}
collection = @beanstalk.templates
tests('success') do
tests("#new(#{params.inspect})").succeeds do
pending if Fog.mocking?
collection.new(params)
end
tests("#create(#{params.inspect})").succeeds do
pending if Fog.mocking?
@instance = collection.create(params)
end
tests("#all").succeeds do
pending if Fog.mocking?
collection.all
end
tests("#get(#{@application_name}, #{@template_name})").succeeds do
pending if Fog.mocking?
collection.get(@application_name, @template_name)
end
if !Fog.mocking?
@instance.destroy
end
end
tests('failure') do
tests("#get(#{@application_name}, #{@template_name})").returns(nil) do
pending if Fog.mocking?
collection.get(@application_name, @template_name)
end
end
# delete application
@application.destroy
end

View file

@ -0,0 +1,66 @@
Shindo.tests("Fog::AWS[:beanstalk] | version", ['aws', 'beanstalk']) do
pending if Fog.mocking?
@beanstalk = Fog::AWS[:beanstalk]
@application_name = uniq_id('fog-test-app')
@version_name = uniq_id('fog-test-version')
@version_description = 'A nice description'
@application = @beanstalk.applications.create({:name => @application_name})
@version_opts = {
:application_name => @application_name,
:label => @version_name,
:description => @version_description
}
model_tests(@beanstalk.versions, @version_opts, false) do
test("attributes") do
@instance.label == @version_name &&
@instance.description == @version_description &&
@instance.application_name == @application_name
end
test("#events") do
# There should be some events now.
@instance.events.length > 0
end
test("#update description") do
new_description = "A completely new description."
@instance.description = new_description
@instance.update
passed = false
if @instance.description == new_description
# reload version from Aws to verify save is committed to server, not just on local object
if @beanstalk.versions.get(@application_name, @version_name).description == new_description
passed = true
end
end
passed
end
test("#update description empty") do
@instance.description = '' # Set to empty to nil out
@instance.update
passed = false
if @instance.description == nil
# reload version from Aws to verify save is committed to server, not just on local object
if @beanstalk.versions.get(@application_name, @version_name).description == nil
passed = true
end
end
passed
end
end
# delete application
@application.destroy
end

View file

@ -0,0 +1,60 @@
Shindo.tests("Fog::AWS[:beanstalk] | versions", ['aws', 'beanstalk']) do
pending if Fog.mocking?
@beanstalk = Fog::AWS[:beanstalk]
@application_name = uniq_id('fog-test-app')
@version_name = uniq_id('fog-test-version')
@version_description = 'A nice description'
@application = @beanstalk.applications.create({:name => @application_name})
params = {
:application_name => @application_name,
:label => @version_name,
:description => @version_description
}
collection = @beanstalk.versions
tests('success') do
tests("#new(#{params.inspect})").succeeds do
pending if Fog.mocking?
collection.new(params)
end
tests("#create(#{params.inspect})").succeeds do
pending if Fog.mocking?
@instance = collection.create(params)
end
tests("#all").succeeds do
pending if Fog.mocking?
collection.all
end
tests("#get(#{@application_name}, #{@version_name})").succeeds do
pending if Fog.mocking?
collection.get(@application_name, @version_name)
end
if !Fog.mocking?
@instance.destroy
end
end
tests('failure') do
tests("#get(#{@application_name}, #{@version_name})").returns(nil) do
pending if Fog.mocking?
collection.get(@application_name, @version_name)
end
end
# delete application
@application.destroy
end