Class: Torpedo::Orchestration::Stacks
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- Torpedo::Orchestration::Stacks
- Defined in:
- lib/torpedo/orchestration/stacks.rb
Constant Summary collapse
- @@stack =
nil
- @@image_ref =
nil
- @@flavor_ref =
nil
Instance Method Summary collapse
- #setup ⇒ Object
- #test_001_setup ⇒ Object
- #test_002_create_stack ⇒ Object
- #test_003_update_stack ⇒ Object
Instance Method Details
#setup ⇒ Object
16 17 18 19 |
# File 'lib/torpedo/orchestration/stacks.rb', line 16 def setup @conn=Helper::get_connection @compute_conn=Torpedo::Compute::Helper::get_connection end |
#test_001_setup ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/torpedo/orchestration/stacks.rb', line 21 def test_001_setup assert KEYPAIR_ENABLED == true, "Keyairs should be enabled when running Orchestration tests." begin @@image_ref = Torpedo::Compute::Servers.image_ref if @@image_ref.nil? then @@image_ref = Torpedo::Compute::Helper::get_image_ref(@compute_conn) end rescue Exception => e fail("Failed get image ref: #{e.}") end begin @@flavor_ref = Torpedo::Compute::Servers.flavor_ref if @@flavor_ref.nil? then @@flavor_ref = Torpedo::Compute::Helper::get_flavor_ref(@compute_conn) end rescue Exception => e fail("Failed get flavor ref: #{e.}") end end |
#test_002_create_stack ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/torpedo/orchestration/stacks.rb', line 44 def test_002_create_stack template = File.join(File.dirname(__FILE__), "test_server.hot") keypair_name = Torpedo::Compute::Keypairs.key_pair.name stack_opts = { :template => IO.read(template), :timeout_mins => (STACK_CREATE_TIMEOUT/60), :parameters => { :server_name => 'torpedo', :key_name => keypair_name, :image => @@image_ref, :flavor => @@flavor_ref } } stack_data = @conn.create_stack('torpedo', stack_opts).body['stack'] stack = @conn.stacks.get(stack_data['id']) @@stack = stack assert_equal "CREATE_IN_PROGRESS", stack.stack_status begin timeout(STACK_CREATE_TIMEOUT) do until stack.stack_status == 'CREATE_COMPLETE' do if stack.stack_status =~ /FAILED/ then fail('Failure status detected when creating stack!') end stack = @conn.stacks.get(stack.id) sleep 1 end end rescue Timeout::Error => te fail('Timeout creating stack.') end end |
#test_003_update_stack ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/torpedo/orchestration/stacks.rb', line 80 def test_003_update_stack template = File.join(File.dirname(__FILE__), "test_server.hot") keypair_name = Torpedo::Compute::Keypairs.key_pair.name stack_opts = { :template => IO.read(template), # update just the stack timeout :timeout_mins => (STACK_CREATE_TIMEOUT/60)+1, :parameters => { :server_name => 'torpedo', :key_name => keypair_name, :image => @@image_ref, :flavor => @@flavor_ref } } @conn.update_stack(@@stack.id, @@stack.stack_name, stack_opts).body['stack'] stack = @conn.stacks.get(@@stack.id) assert_equal "UPDATE_IN_PROGRESS", stack.stack_status begin timeout(STACK_CREATE_TIMEOUT) do until stack.stack_status == 'UPDATE_COMPLETE' do if stack.stack_status =~ /FAILED/ then fail('Failure status detected when updating stack!') end stack = @conn.stacks.get(stack.id) sleep 1 end end rescue Timeout::Error => te fail('Timeout updating stack.') end end |