mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
A set of smoke tests for GCE.
This commit is contained in:
parent
814a59f679
commit
01f4c0f7bf
6 changed files with 122 additions and 0 deletions
17
lib/fog/google/Rakefile
Normal file
17
lib/fog/google/Rakefile
Normal file
|
@ -0,0 +1,17 @@
|
|||
namespace :google do
|
||||
namespace :smoke do
|
||||
|
||||
desc "Smoke tests for Google Compute Engine."
|
||||
task :compute do
|
||||
require 'fog'
|
||||
|
||||
puts "These smoke tests assume you have a file at ~/.fog which has your credentials for connecting to GCE."
|
||||
|
||||
Dir.glob("./examples/*.rb").each do |file|
|
||||
puts "Running #{file}:"
|
||||
require file
|
||||
test()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
9
lib/fog/google/examples/bootstrap.rb
Executable file
9
lib/fog/google/examples/bootstrap.rb
Executable file
|
@ -0,0 +1,9 @@
|
|||
def test
|
||||
connection = Fog::Compute.new({ :provider => "Google" })
|
||||
|
||||
server = connection.servers.bootstrap
|
||||
server.wait_for { sshable? }
|
||||
|
||||
raise "Could not bootstrap sshable server." unless server.ssh("whoami")
|
||||
raise "Cloud note delete server." unless server.destroy
|
||||
end
|
35
lib/fog/google/examples/create.rb
Executable file
35
lib/fog/google/examples/create.rb
Executable file
|
@ -0,0 +1,35 @@
|
|||
def test
|
||||
connection = Fog::Compute.new({ :provider => "Google" })
|
||||
|
||||
server = connection.servers.create(defaults = {
|
||||
:name => "fog-smoke-test-#{Time.now.to_i}",
|
||||
:image_name => "debian-7-wheezy-v20130522",
|
||||
:machine_type => "n1-standard-1",
|
||||
:zone_name => "us-central1-a",
|
||||
:private_key_path => File.expand_path("~/.ssh/id_rsa"),
|
||||
:public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
|
||||
:user => ENV['USER'],
|
||||
})
|
||||
|
||||
# My own wait_for because it hides errors
|
||||
duration = 0
|
||||
interval = 5
|
||||
timeout = 600
|
||||
start = Time.now
|
||||
until server.sshable? || duration > timeout
|
||||
# puts duration
|
||||
# puts " ----- "
|
||||
# p server.reload
|
||||
# p "ready?: #{server.ready?}"
|
||||
# p "public_ip_address: #{server.public_ip_address.inspect}"
|
||||
# p "public_key: #{server.public_key.inspect}"
|
||||
# p "metadata: #{server.metadata.inspect}"
|
||||
# p "sshable?: #{server.sshable?}"
|
||||
|
||||
sleep(interval.to_f)
|
||||
duration = Time.now - start
|
||||
end
|
||||
|
||||
raise "Could not bootstrap sshable server." unless server.ssh("whoami")
|
||||
raise "Cloud note delete server." unless server.destroy
|
||||
end
|
19
lib/fog/google/examples/eric-fail.rb
Executable file
19
lib/fog/google/examples/eric-fail.rb
Executable file
|
@ -0,0 +1,19 @@
|
|||
def test
|
||||
connection = Fog::Compute.new({ :provider => "Google" })
|
||||
|
||||
server = connection.servers.create(defaults = {
|
||||
:name => "fog-smoke-test-#{Time.now.to_i}",
|
||||
:image_name => "debian-7-wheezy-v20130617",
|
||||
:machine_type => "n1-standard-1",
|
||||
:zone_name => "us-central1-a",
|
||||
:private_key_path => File.expand_path("~/.ssh/id_rsa"),
|
||||
:public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
|
||||
:username => 'root',
|
||||
:metadata => {'foo' => 'bar'}
|
||||
})
|
||||
sleep(30)
|
||||
|
||||
raise "Could not reload created server." unless server.reload
|
||||
raise "Could not create sshable server." unless server.ssh("whoami")
|
||||
raise "Cloud note delete server." unless server.destroy
|
||||
end
|
23
lib/fog/google/examples/launch_micro_instance.rb
Executable file
23
lib/fog/google/examples/launch_micro_instance.rb
Executable file
|
@ -0,0 +1,23 @@
|
|||
def test
|
||||
connection = Fog::Compute.new({ :provider => "Google" })
|
||||
time = Time.now.utc.to_i
|
||||
disk = CONNECTION.disks.create({:name => 'foggydisk', :size => 10, :zone_name => 'us-central1-a', :image_name => 'centos-6-v20130522'})
|
||||
|
||||
disk.wait_for { disk.ready? }
|
||||
puts 'disk ready'
|
||||
disk = disk.get_as_boot_disk(true)
|
||||
params = {
|
||||
:name => "fog-smoke-test-#{Time.now.to_i}",
|
||||
:machine_type => "f1-micro",
|
||||
:zone_name => "us-central1-a",
|
||||
:disks => [ disk ],
|
||||
:kernel => 'gce-v20130522',
|
||||
:user => ENV['USER']
|
||||
}
|
||||
|
||||
server = CONNECTION.servers.bootstrap params
|
||||
|
||||
raise "Could not bootstrap sshable server." unless server.ssh("whoami")
|
||||
raise "Could not delete server." unless server.destroy
|
||||
raise "Could not delete disk." unless disk.destroy
|
||||
end
|
19
lib/fog/google/examples/metadata.rb
Executable file
19
lib/fog/google/examples/metadata.rb
Executable file
|
@ -0,0 +1,19 @@
|
|||
def test
|
||||
connection = Fog::Compute.new({ :provider => "Google" })
|
||||
server = connection.servers.create(defaults = {
|
||||
:name => "fog-#{Time.now.to_i}",
|
||||
:image_name => "debian-7-wheezy-v20130522",
|
||||
:machine_type => "n1-standard-1",
|
||||
:zone_name => "us-central1-a",
|
||||
:private_key_path => File.expand_path("~/.ssh/id_rsa"),
|
||||
:public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
|
||||
})
|
||||
|
||||
server.wait_for { ready? }
|
||||
|
||||
server.metadata["test"] = "foo"
|
||||
|
||||
raise "Metadata was not set." unless server.metadata["test"] == "foo"
|
||||
raise "Could not delete server." unless server.destroy
|
||||
raise "Could not delete disk." unless disk.destroy
|
||||
end
|
Loading…
Add table
Reference in a new issue