Sha256: 49510390dcb504c892a45f3ee70826f9541464435a43812a198306b5e1c14680

Contents?: true

Size: 1.96 KB

Versions: 87

Compression:

Stored size: 1.96 KB

Contents

Shindo.tests('Fog::Rackspace::BlockStorage | snapshot_tests', ['rackspace']) do
  timeout = Fog.mocking? ? 1 : 10

  snapshot_format = {
    'id' => String,
    'status' => String,
    'display_name' => Fog::Nullable::String,
    'display_description' => Fog::Nullable::String,
    'volume_id' => String,
    'size' => Integer,
    'created_at' => String
    }

  get_snapshot_format = {
    'snapshot' => snapshot_format
  }

  list_snapshot_format = {
    'snapshots' => [snapshot_format]
  }

  def snapshot_deleted?(service, snapshot_id)
    begin
      service.get_snapshot(snapshot_id)
      false
    rescue
      true
    end
  end

  service = Fog::Rackspace::BlockStorage.new

  tests('success') do
    volume = service.create_volume(100).body['volume']
    volume_id = volume['id']
    snapshot_id = nil

    until service.get_volume(volume_id).body['volume']['status'] == 'available'
      sleep timeout
    end

    tests("#create_snapshot(#{volume_id})").formats(get_snapshot_format) do
      service.create_snapshot(volume_id).body.tap do |b|
        snapshot_id = b['snapshot']['id']
      end
    end

    tests("#list_snapshots").formats(list_snapshot_format) do
      service.list_snapshots.body
    end

    tests("#get_snapshot(#{snapshot_id})").formats(get_snapshot_format) do
      service.get_snapshot(snapshot_id).body
    end

    until service.get_snapshot(snapshot_id).body['snapshot']['status'] == 'available' do
      sleep timeout
    end

    tests("#delete_snapshot(#{snapshot_id})").succeeds do
      service.delete_snapshot(snapshot_id)
    end

    until snapshot_deleted?(service, snapshot_id)
      sleep timeout
    end

    service.delete_volume(volume_id)
  end

  tests('failure') do
    tests("#create_snapshot('invalid')").raises(Fog::Rackspace::BlockStorage::NotFound) do
      service.create_snapshot('invalid')
    end

    tests("#get_snapshot('invalid')").raises(Fog::Rackspace::BlockStorage::NotFound) do
      service.get_snapshot('invalid')
    end
  end
end

Version data entries

87 entries across 85 versions & 8 rubygems

Version Path
fog-1.21.0 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.20.0.20140305101839 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.20.0.20140305101305 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.19.0.20140212012611 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-1.20.0 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.19.0.20140110004459 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.19.0.20140110003812 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.19.0.20140109202555 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.19.0.20140107192102 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.19.0.20140107142106 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.19.0.20131219203941 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.18.0.20131219193542 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-1.19.0 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.18.0.20131219033443 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.18.0.20131219032002 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.18.0.20131219030716 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.18.0.20131219022322 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.18.0.20131218202447 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.18.0.20131209091424 tests/rackspace/requests/block_storage/snapshot_tests.rb
fog-maestrodev-1.18.0.20131209090811 tests/rackspace/requests/block_storage/snapshot_tests.rb