public void Should_Delete_Test_Snapshot() { var provider = new CloudBlockStorageProvider(); var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity); if (snapshotListResponse != null && snapshotListResponse.Any()) { var testSnapshot = snapshotListResponse.FirstOrDefault(x => x.DisplayName == snapshotDisplayName); if (testSnapshot == null) { Assert.Fail("Could not find test snapshot to delete."); } var deleteSnapshotResult = provider.DeleteSnapshot(testSnapshot.Id, identity: _testIdentity); if (deleteSnapshotResult) { var snapshotDeleteDetails = provider.WaitForSnapshotDeleted(testSnapshot.Id, identity: _testIdentity); Assert.IsTrue(snapshotDeleteDetails); } else { Assert.Fail("Test snapshot was not deleted."); } } else { Assert.Fail("No snapshots present to test delete."); } }
public CloudBlockStorageOrphanedSnapshotsNode(CloudBlockStorageProvider provider) { if (provider == null) throw new ArgumentNullException("provider"); _provider = provider; }
public static IBlockStorageProvider CreateBlockStorageProvider() { var provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity, Bootstrapper.Settings.DefaultRegion, CreateIdentityProvider(), null); SetUserAgent(provider); return(provider); }
public void Should_Return_Volume_Type_List() { var provider = new CloudBlockStorageProvider(); var volumeTypeListResponse = provider.ListVolumeTypes(identity: _testIdentity); Assert.IsNotNull(volumeTypeListResponse); Assert.IsTrue(volumeTypeListResponse.Any()); }
public void Should_Create_Volume_Only_Required_Parameters() { var provider = new CloudBlockStorageProvider(); var volumeCreatedResponse = provider.CreateVolume(100, identity: _testIdentity); Assert.IsNotNull(volumeCreatedResponse); }
public void TestShowSnapshot() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable <Snapshot> snapshots = provider.ListSnapshots(); Assert.IsNotNull(snapshots); if (!snapshots.Any()) { Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any snapshots."); } Console.WriteLine("Snapshots"); foreach (Snapshot snapshot in snapshots) { Assert.IsNotNull(snapshot); Assert.IsFalse(string.IsNullOrEmpty(snapshot.Id)); Snapshot showSnapshot = provider.ShowSnapshot(snapshot.Id); Assert.IsNotNull(showSnapshot); Assert.AreEqual(snapshot.CreatedAt, showSnapshot.CreatedAt); Assert.AreEqual(snapshot.DisplayDescription, showSnapshot.DisplayDescription); Assert.AreEqual(snapshot.DisplayName, showSnapshot.DisplayName); Assert.AreEqual(snapshot.Id, showSnapshot.Id); Assert.AreEqual(snapshot.Size, showSnapshot.Size); //Assert.AreEqual(snapshot.Status, showSnapshot.Status); Assert.AreEqual(snapshot.VolumeId, showSnapshot.VolumeId); } }
public void Should_Create_Volume_Full_Parameters() { var provider = new CloudBlockStorageProvider(); var volumeCreatedResponse = provider.CreateVolume(100, volumeDisplayDescription, volumeDisplayName, null, "SATA", null, _testIdentity); Assert.IsNotNull(volumeCreatedResponse); }
public void TestShowVolume() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable <Volume> volumes = provider.ListVolumes(); Assert.IsNotNull(volumes); if (!volumes.Any()) { Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any configured volumes."); } foreach (Volume volume in volumes) { Assert.IsNotNull(volume); Assert.IsFalse(string.IsNullOrEmpty(volume.Id)); Volume showVolume = provider.ShowVolume(volume.Id); Assert.IsNotNull(showVolume); Assert.AreEqual(volume.AvailabilityZone, showVolume.AvailabilityZone); Assert.AreEqual(volume.CreatedAt, showVolume.CreatedAt); Assert.AreEqual(volume.DisplayDescription, showVolume.DisplayDescription); Assert.AreEqual(volume.DisplayName, showVolume.DisplayName); Assert.AreEqual(volume.Id, showVolume.Id); Assert.AreEqual(volume.Size, showVolume.Size); Assert.AreEqual(volume.SnapshotId, showVolume.SnapshotId); Assert.IsNotNull(volume.Status); Assert.AreEqual(volume.VolumeType, showVolume.VolumeType); } }
public void Should_Delete_Test_Volume() { var provider = new CloudBlockStorageProvider(); var volumeListResponse = provider.ListVolumes(identity: _testIdentity); if (volumeListResponse != null && volumeListResponse.Any()) { var testVolume = volumeListResponse.FirstOrDefault(x => x.DisplayName == volumeDisplayName); if (testVolume == null) { Assert.Fail("Could not find test volume to delete."); } var deleteVolumeResult = provider.DeleteVolume(testVolume.Id, identity: _testIdentity); if (deleteVolumeResult) { var volumeWaitForDeletedResult = provider.WaitForVolumeDeleted(testVolume.Id, identity: _testIdentity); Assert.IsTrue(volumeWaitForDeletedResult); } else { Assert.Fail("Test volume was not deleted."); } } else { Assert.Fail("No volumes present to test delete."); } }
public void Should_Return_Snapshot_List() { var provider = new CloudBlockStorageProvider(); var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity); Assert.IsNotNull(snapshotListResponse); Assert.IsTrue(snapshotListResponse.Any()); }
public ComputeTestDataManager(ComputeService compute) { _compute = compute; _testData = new HashSet<object>(); var identityProvider = TestIdentityProvider.GetIdentityProvider(); var blockStorage = new CloudBlockStorageProvider(null, "RegionOne", identityProvider, null); BlockStorage = new BlockStorageTestDataManager(blockStorage); }
public CloudBlockStorageVolumeNode(CloudBlockStorageProvider provider, Volume volume) { if (provider == null) throw new ArgumentNullException("provider"); if (volume == null) throw new ArgumentNullException("volume"); this._provider = provider; this._volume = volume; }
public CloudBlockStorageSnapshotNode(CloudBlockStorageProvider provider, Snapshot snapshot) { if (provider == null) throw new ArgumentNullException("provider"); if (snapshot == null) throw new ArgumentNullException("snapshot"); this._provider = provider; this._snapshot = snapshot; }
public ComputeTestDataManager(ComputeService compute) { _compute = compute; _testData = new HashSet <object>(); var identityProvider = TestIdentityProvider.GetIdentityProvider(); var blockStorage = new CloudBlockStorageProvider(null, "RegionOne", identityProvider, null); BlockStorage = new BlockStorageTestDataManager(blockStorage); }
public void Should_Cleanup_CloudBlockStorage_Environment() { var provider = new CloudBlockStorageProvider(); var volumeListResponse = provider.ListVolumes(identity: _testIdentity); if (volumeListResponse == null || !volumeListResponse.Any()) { return; } var testVolumeList = volumeListResponse.Where(x => x.DisplayName == volumeDisplayName); if (!testVolumeList.Any()) { return; } var snapshotList = provider.ListSnapshots(identity: _testIdentity); if (snapshotList != null && snapshotList.Any()) { foreach (var testVolume in testVolumeList) { var testVolumeSnapshots = snapshotList.Where(x => x.VolumeId == testVolume.Id); if (testVolumeSnapshots.Any()) { foreach (var testSnapshot in testVolumeSnapshots) { var deleteSnapshotResult = provider.DeleteSnapshot(testSnapshot.Id, identity: _testIdentity); if (deleteSnapshotResult) { var snapshotDeleteDetails = provider.WaitForSnapshotDeleted(testSnapshot.Id, identity: _testIdentity); Assert.IsTrue(snapshotDeleteDetails); } else { Assert.Fail(string.Format("Snapshot (Volume ID: {0} -- Snapshot ID:{1}) could not be deleted.", testVolume.Id, testSnapshot.Id)); } } } } } foreach (var testVolume in testVolumeList) { var deleteVolumeResults = provider.DeleteVolume(testVolume.Id, identity: _testIdentity); Assert.IsTrue(deleteVolumeResults); var volumeWaitForDeletedResult = provider.WaitForVolumeDeleted(testVolume.Id, identity: _testIdentity); Assert.IsTrue(volumeWaitForDeletedResult); } }
public void TestAttachServerVolume() { IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity); IBlockStorageProvider blockStorageProvider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); VolumeType volumeType = UserBlockStorageTests.GetSsdVolumeTypeOrDefault(blockStorageProvider); string volumeName = UserBlockStorageTests.UnitTestVolumePrefix + Path.GetRandomFileName(); Volume volume = blockStorageProvider.CreateVolume(UserBlockStorageTests.MinimumVolumeSize, displayName: volumeName, volumeType: volumeType != null ? volumeType.Id : null); Assert.AreEqual(VolumeState.Available, blockStorageProvider.WaitForVolumeAvailable(volume.Id).Status); /* AttachServerVolume */ ServerVolume serverVolume = provider.AttachServerVolume(_server.Id, volume.Id); Assert.IsNotNull(serverVolume); Assert.IsFalse(string.IsNullOrEmpty(serverVolume.Id)); Assert.AreEqual(_server.Id, serverVolume.ServerId); Assert.AreEqual(volume.Id, serverVolume.VolumeId); Assert.AreEqual(VolumeState.InUse, blockStorageProvider.WaitForVolumeState(volume.Id, VolumeState.InUse, new[] { VolumeState.Available, VolumeState.Error }).Status); /* ListServerVolumes */ ServerVolume[] serverVolumes = provider.ListServerVolumes(_server.Id).ToArray(); Assert.IsNotNull(serverVolumes); Assert.AreEqual(1, serverVolumes.Length); Assert.AreEqual(serverVolume.Id, serverVolumes[0].Id); Assert.AreEqual(serverVolume.ServerId, serverVolumes[0].ServerId); Assert.AreEqual(serverVolume.VolumeId, serverVolumes[0].VolumeId); /* GetServerVolumeDetails */ ServerVolume volumeDetails = provider.GetServerVolumeDetails(_server.Id, volume.Id); Assert.IsNotNull(volumeDetails); Assert.AreEqual(serverVolume.Id, volumeDetails.Id); Assert.AreEqual(serverVolume.ServerId, volumeDetails.ServerId); Assert.AreEqual(serverVolume.VolumeId, volumeDetails.VolumeId); bool detach = provider.DetachServerVolume(_server.Id, volume.Id); Assert.IsTrue(detach); ServerVolume[] remainingVolumes = provider.ListServerVolumes(_server.Id).ToArray(); Assert.AreEqual(0, remainingVolumes.Length); Assert.AreEqual(VolumeState.Available, blockStorageProvider.WaitForVolumeAvailable(volume.Id).Status); bool deleted = blockStorageProvider.DeleteVolume(volume.Id); Assert.IsTrue(blockStorageProvider.WaitForVolumeDeleted(volume.Id)); }
public void CleanupTestVolumes() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable<Volume> volumes = provider.ListVolumes(); foreach (Volume volume in volumes) { if (string.IsNullOrEmpty(volume.DisplayName)) continue; if (!volume.DisplayName.StartsWith(UnitTestVolumePrefix)) continue; Console.WriteLine("Deleting unit test volume... {0} ({1})", volume.DisplayName, volume.Id); provider.DeleteVolume(volume.Id); } }
public void TestListVolumes() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable<Volume> volumes = provider.ListVolumes(); Assert.IsNotNull(volumes); if (!volumes.Any()) Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any configured volumes."); Console.WriteLine("Volumes"); foreach (Volume volume in volumes) { Assert.IsNotNull(volume); Assert.IsFalse(string.IsNullOrEmpty(volume.Id)); Console.WriteLine(JsonConvert.SerializeObject(volume, Formatting.Indented)); } }
public void Should_Return_Single_Volume_Type() { var provider = new CloudBlockStorageProvider(); var volumeTypeListResponse = provider.ListVolumeTypes(identity: _testIdentity); if (volumeTypeListResponse != null && volumeTypeListResponse.Any()) { var firstVolumeTypeInList = volumeTypeListResponse.First(); var singleVolumeTypeResponse = provider.DescribeVolumeType(firstVolumeTypeInList.Id, identity: _testIdentity); Assert.IsNotNull(singleVolumeTypeResponse); Assert.IsTrue(singleVolumeTypeResponse.Id == firstVolumeTypeInList.Id); } else { Assert.Fail("No volumes types present to query."); } }
public void TestListVolumeTypes() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable <VolumeType> volumeTypes = provider.ListVolumeTypes(); Assert.IsNotNull(volumeTypes); if (!volumeTypes.Any()) { Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any volume types."); } Console.WriteLine("Volume Types"); foreach (VolumeType volumeType in volumeTypes) { Assert.IsNotNull(volumeType); Console.WriteLine(JsonConvert.SerializeObject(volumeType, Formatting.Indented)); } }
public void TestListSnapshots() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable <Snapshot> snapshots = provider.ListSnapshots(); Assert.IsNotNull(snapshots); if (!snapshots.Any()) { Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any snapshots."); } Console.WriteLine("Snapshots"); foreach (Snapshot snapshot in snapshots) { Assert.IsNotNull(snapshot); Assert.IsFalse(string.IsNullOrEmpty(snapshot.Id)); Console.WriteLine(JsonConvert.SerializeObject(snapshot, Formatting.Indented)); } }
public void TestBasicVolumeFeatures() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); string displayName = UnitTestVolumePrefix + Path.GetRandomFileName(); Volume result = provider.CreateVolume(MinimumVolumeSize, displayName: displayName); Assert.IsNotNull(result); Assert.IsNotNull(result.Id); Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented)); Volume updated = provider.WaitForVolumeAvailable(result.Id); Assert.IsNotNull(updated); Assert.AreEqual(result.Id, updated.Id); Assert.AreEqual(VolumeState.Available, updated.Status); bool deleted = provider.DeleteVolume(result.Id); Assert.IsTrue(deleted); deleted = provider.WaitForVolumeDeleted(result.Id); Assert.IsTrue(deleted); try { provider.ShowVolume(result.Id); Assert.Fail("Expected an exception after a volume is deleted."); } catch (ItemNotFoundException) { // this makes the most sense } catch (UserNotAuthorizedException) { // this is allowed by the interface, and some providers could report it for security reasons } catch (ResponseException) { // this is allowed by the interface } }
public void CleanupTestSnapshots() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable <Snapshot> snapshots = provider.ListSnapshots(); foreach (Snapshot snapshot in snapshots) { if (string.IsNullOrEmpty(snapshot.DisplayName)) { continue; } if (!snapshot.DisplayName.StartsWith(UnitTestSnapshotPrefix)) { continue; } Console.WriteLine("Deleting unit test snapshot... {0} ({1})", snapshot.DisplayName, snapshot.Id); provider.DeleteSnapshot(snapshot.Id); } }
public void TestDescribeVolumeType() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable <VolumeType> volumeTypes = provider.ListVolumeTypes(); Assert.IsNotNull(volumeTypes); if (!volumeTypes.Any()) { Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any volume types."); } foreach (VolumeType volumeType in volumeTypes) { Assert.IsNotNull(volumeType); Assert.IsFalse(string.IsNullOrEmpty(volumeType.Id)); VolumeType type = provider.DescribeVolumeType(volumeType.Id); Assert.IsNotNull(type); Assert.AreEqual(volumeType.Id, type.Id); Assert.AreEqual(volumeType.Name, type.Name); } }
public void Should_Create_Snapshot_Only_Required_Parameters() { var provider = new CloudBlockStorageProvider(); var volumeListResponse = provider.ListVolumes(identity: _testIdentity); if (volumeListResponse != null && volumeListResponse.Any()) { var testVolume = volumeListResponse.FirstOrDefault(x => x.DisplayName == volumeDisplayName); if (testVolume == null) { Assert.Fail("Could not find test volume to create snapshot."); } var snapshotCreatedResponse = provider.CreateSnapshot(testVolume.Id, identity: _testIdentity); Assert.IsNotNull(snapshotCreatedResponse); } else { Assert.Fail("No volumes present to create a snapshot."); } }
public void CleanupTestVolumes() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable <Volume> volumes = provider.ListVolumes(); foreach (Volume volume in volumes) { if (string.IsNullOrEmpty(volume.DisplayName)) { continue; } if (!volume.DisplayName.StartsWith(UnitTestVolumePrefix)) { continue; } Console.WriteLine("Deleting unit test volume... {0} ({1})", volume.DisplayName, volume.Id); provider.DeleteVolume(volume.Id); } }
public void Should_Wait_Until_Test_Volume_Becomes_Available_Or_Exceeds_Timeout_For_Becoming_Available() { var provider = new CloudBlockStorageProvider(); var volumeListResponse = provider.ListVolumes(identity: _testIdentity); if (volumeListResponse != null && volumeListResponse.Any()) { var testVolume = volumeListResponse.FirstOrDefault(x => x.DisplayName == volumeDisplayName); if (testVolume == null) { Assert.Fail("Could not find test volume to query for Available status."); } var volumeDetails = provider.WaitForVolumeAvailable(testVolume.Id, identity: _testIdentity); Assert.IsNotNull(volumeDetails); Assert.AreEqual(VolumeState.Available, volumeDetails.Status); } else { Assert.Fail("No volumes present to obtain Available status."); } }
public void Should_Return_Test_Volume() { var provider = new CloudBlockStorageProvider(); var volumeListResponse = provider.ListVolumes(identity: _testIdentity); if (volumeListResponse != null && volumeListResponse.Any()) { var testVolume = volumeListResponse.FirstOrDefault(x => x.DisplayName == volumeDisplayName); if (testVolume == null) { Assert.Fail("Could not retrieve test volume."); } var singleVolumeResponse = provider.ShowVolume(testVolume.Id, identity: _testIdentity); Assert.IsNotNull(singleVolumeResponse); Assert.IsTrue(singleVolumeResponse.Id == testVolume.Id); } else { Assert.Fail("No volumes present to query."); } }
public void Should_Return_Test_Snapshot() { var provider = new CloudBlockStorageProvider(); var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity); if (snapshotListResponse != null && snapshotListResponse.Any()) { var testSnapshot = snapshotListResponse.FirstOrDefault(x => x.DisplayName == snapshotDisplayName); if (testSnapshot == null) { Assert.Fail("Could not retrieve test snapshot"); } var singleSnapshotResponse = provider.ShowSnapshot(testSnapshot.Id, identity: _testIdentity); Assert.IsNotNull(singleSnapshotResponse); Assert.IsTrue(singleSnapshotResponse.Id == testSnapshot.Id); } else { Assert.Fail("No snapshots present to query."); } }
public void Should_Wait_Until_Test_Snapshot_Becomes_Available_Or_Exceeds_Timeout_For_Becoming_Available() { var provider = new CloudBlockStorageProvider(); var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity); if (snapshotListResponse != null && snapshotListResponse.Any()) { var testSnapshot = snapshotListResponse.FirstOrDefault(x => x.DisplayName == snapshotDisplayName); if (testSnapshot == null) { Assert.Fail("Could not find test snapshot to query for Available status."); } var snapshotDetails = provider.WaitForSnapshotAvailable(testSnapshot.Id, identity: _testIdentity); Assert.IsNotNull(snapshotDetails); Assert.AreEqual(SnapshotState.Available, snapshotDetails.Status); } else { Assert.Fail("No snapshots present to obtain Available status."); } }
public void TestBasicSnapshotFeatures() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); // // Volume setup... // string volumeDisplayName = UnitTestVolumePrefix + Path.GetRandomFileName(); VolumeType ssdType = GetSsdVolumeTypeOrDefault(provider); if (ssdType != null) { Console.WriteLine("Using an SSD volume to improve snapshot test performance."); } else { Console.WriteLine("No SSD volume type is available for the snapshot test... falling back to the default."); } Volume result = provider.CreateVolume(MinimumVolumeSize, displayName: volumeDisplayName, volumeType: ssdType != null ? ssdType.Id : null); Assert.IsNotNull(result); Assert.IsNotNull(result.Id); Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented)); Volume updated = provider.WaitForVolumeAvailable(result.Id); Assert.IsNotNull(updated); Assert.AreEqual(result.Id, updated.Id); Assert.AreEqual(VolumeState.Available, updated.Status); // // Snapshot testing // string snapshotDisplayName = UnitTestSnapshotPrefix + Path.GetRandomFileName(); Snapshot snapshot = provider.CreateSnapshot(result.Id, displayName: snapshotDisplayName); Assert.IsNotNull(snapshot); Assert.IsNotNull(snapshot.Id); Console.WriteLine(JsonConvert.SerializeObject(snapshot, Formatting.Indented)); Snapshot updatedSnapshot = provider.WaitForSnapshotAvailable(snapshot.Id); Assert.IsNotNull(updatedSnapshot); Assert.AreEqual(snapshot.Id, updatedSnapshot.Id); Assert.AreEqual(SnapshotState.Available, updatedSnapshot.Status); bool deleted = provider.DeleteSnapshot(snapshot.Id); Assert.IsTrue(deleted); deleted = provider.WaitForSnapshotDeleted(snapshot.Id); Assert.IsTrue(deleted); try { provider.ShowSnapshot(snapshot.Id); Assert.Fail("Expected an exception after a snapshot is deleted."); } catch (ItemNotFoundException) { // this makes the most sense } catch (UserNotAuthorizedException) { // this is allowed by the interface, and some providers could report it for security reasons } catch (ResponseException) { // this is allowed by the interface } // // Volume cleanup... // bool deletedVolume = provider.DeleteVolume(result.Id); Assert.IsTrue(deletedVolume); deletedVolume = provider.WaitForVolumeDeleted(result.Id); Assert.IsTrue(deletedVolume); }
public SnapshotProperties(CloudBlockStorageProvider provider, Snapshot snapshot) { if (provider == null) throw new ArgumentNullException("provider"); if (snapshot == null) throw new ArgumentNullException("snapshot"); _provider = provider; _snapshot = snapshot; }
public void TestDescribeVolumeType() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable<VolumeType> volumeTypes = provider.ListVolumeTypes(); Assert.IsNotNull(volumeTypes); if (!volumeTypes.Any()) Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any volume types."); foreach (VolumeType volumeType in volumeTypes) { Assert.IsNotNull(volumeType); Assert.IsFalse(string.IsNullOrEmpty(volumeType.Id)); VolumeType type = provider.DescribeVolumeType(volumeType.Id); Assert.IsNotNull(type); Assert.AreEqual(volumeType.Id, type.Id); Assert.AreEqual(volumeType.Name, type.Name); } }
public void TestListSnapshots() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable<Snapshot> snapshots = provider.ListSnapshots(); Assert.IsNotNull(snapshots); if (!snapshots.Any()) Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any snapshots."); Console.WriteLine("Snapshots"); foreach (Snapshot snapshot in snapshots) { Assert.IsNotNull(snapshot); Assert.IsFalse(string.IsNullOrEmpty(snapshot.Id)); Console.WriteLine(JsonConvert.SerializeObject(snapshot, Formatting.Indented)); } }
public void TestShowSnapshot() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable<Snapshot> snapshots = provider.ListSnapshots(); Assert.IsNotNull(snapshots); if (!snapshots.Any()) Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any snapshots."); Console.WriteLine("Snapshots"); foreach (Snapshot snapshot in snapshots) { Assert.IsNotNull(snapshot); Assert.IsFalse(string.IsNullOrEmpty(snapshot.Id)); Snapshot showSnapshot = provider.ShowSnapshot(snapshot.Id); Assert.IsNotNull(showSnapshot); Assert.AreEqual(snapshot.CreatedAt, showSnapshot.CreatedAt); Assert.AreEqual(snapshot.DisplayDescription, showSnapshot.DisplayDescription); Assert.AreEqual(snapshot.DisplayName, showSnapshot.DisplayName); Assert.AreEqual(snapshot.Id, showSnapshot.Id); Assert.AreEqual(snapshot.Size, showSnapshot.Size); //Assert.AreEqual(snapshot.Status, showSnapshot.Status); Assert.AreEqual(snapshot.VolumeId, showSnapshot.VolumeId); } }
public void TestShowVolume() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable<Volume> volumes = provider.ListVolumes(); Assert.IsNotNull(volumes); if (!volumes.Any()) Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any configured volumes."); foreach (Volume volume in volumes) { Assert.IsNotNull(volume); Assert.IsFalse(string.IsNullOrEmpty(volume.Id)); Volume showVolume = provider.ShowVolume(volume.Id); Assert.IsNotNull(showVolume); Assert.AreEqual(volume.AvailabilityZone, showVolume.AvailabilityZone); Assert.AreEqual(volume.CreatedAt, showVolume.CreatedAt); Assert.AreEqual(volume.DisplayDescription, showVolume.DisplayDescription); Assert.AreEqual(volume.DisplayName, showVolume.DisplayName); Assert.AreEqual(volume.Id, showVolume.Id); Assert.AreEqual(volume.Size, showVolume.Size); Assert.AreEqual(volume.SnapshotId, showVolume.SnapshotId); Assert.IsNotNull(volume.Status); Assert.AreEqual(volume.VolumeType, showVolume.VolumeType); } }
public void Should_Create_Snapshot_Full_Parameters() { var provider = new CloudBlockStorageProvider(); var volumeListResponse = provider.ListVolumes(identity: _testIdentity); if (volumeListResponse != null && volumeListResponse.Any()) { var testVolume = volumeListResponse.FirstOrDefault(x => x.DisplayName == volumeDisplayName); if (testVolume == null) { Assert.Fail("Could not find test volume to create snapshot."); } var snapshotCreatedResponse = provider.CreateSnapshot(testVolume.Id, true, snapshotDisplayName, snapshotDisplayDescription, identity: _testIdentity); Assert.IsNotNull(snapshotCreatedResponse); } else { Assert.Fail("No volumes present to create a snapshot."); } }
public void Should_Cleanup_CloudBlockStorage_Environment() { var provider = new CloudBlockStorageProvider(); var volumeListResponse = provider.ListVolumes(identity: _testIdentity); if (volumeListResponse == null || !volumeListResponse.Any()) return; var testVolumeList = volumeListResponse.Where(x => x.DisplayName == volumeDisplayName); if (!testVolumeList.Any()) return; var snapshotList = provider.ListSnapshots(identity: _testIdentity); if (snapshotList != null && snapshotList.Any()) { foreach (var testVolume in testVolumeList) { var testVolumeSnapshots = snapshotList.Where(x => x.VolumeId == testVolume.Id); if (testVolumeSnapshots.Any()) { foreach (var testSnapshot in testVolumeSnapshots) { var deleteSnapshotResult = provider.DeleteSnapshot(testSnapshot.Id, identity: _testIdentity); if (deleteSnapshotResult) { var snapshotDeleteDetails = provider.WaitForSnapshotDeleted(testSnapshot.Id, identity: _testIdentity); Assert.IsTrue(snapshotDeleteDetails); } else { Assert.Fail(string.Format("Snapshot (Volume ID: {0} -- Snapshot ID:{1}) could not be deleted.", testVolume.Id, testSnapshot.Id)); } } } } } foreach (var testVolume in testVolumeList) { var deleteVolumeResults = provider.DeleteVolume(testVolume.Id, identity: _testIdentity); Assert.IsTrue(deleteVolumeResults); var volumeWaitForDeletedResult = provider.WaitForVolumeDeleted(testVolume.Id, identity: _testIdentity); Assert.IsTrue(volumeWaitForDeletedResult); } }
public void TestBasicSnapshotFeatures() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); // // Volume setup... // string volumeDisplayName = UnitTestVolumePrefix + Path.GetRandomFileName(); VolumeType ssdType = GetSsdVolumeTypeOrDefault(provider); if (ssdType != null) Console.WriteLine("Using an SSD volume to improve snapshot test performance."); else Console.WriteLine("No SSD volume type is available for the snapshot test... falling back to the default."); Volume result = provider.CreateVolume(MinimumVolumeSize, displayName: volumeDisplayName, volumeType: ssdType != null ? ssdType.Id : null); Assert.IsNotNull(result); Assert.IsNotNull(result.Id); Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented)); Volume updated = provider.WaitForVolumeAvailable(result.Id); Assert.IsNotNull(updated); Assert.AreEqual(result.Id, updated.Id); Assert.AreEqual(VolumeState.Available, updated.Status); // // Snapshot testing // string snapshotDisplayName = UnitTestSnapshotPrefix + Path.GetRandomFileName(); Snapshot snapshot = provider.CreateSnapshot(result.Id, displayName: snapshotDisplayName); Assert.IsNotNull(snapshot); Assert.IsNotNull(snapshot.Id); Console.WriteLine(JsonConvert.SerializeObject(snapshot, Formatting.Indented)); Snapshot updatedSnapshot = provider.WaitForSnapshotAvailable(snapshot.Id); Assert.IsNotNull(updatedSnapshot); Assert.AreEqual(snapshot.Id, updatedSnapshot.Id); Assert.AreEqual(SnapshotState.Available, updatedSnapshot.Status); bool deleted = provider.DeleteSnapshot(snapshot.Id); Assert.IsTrue(deleted); deleted = provider.WaitForSnapshotDeleted(snapshot.Id); Assert.IsTrue(deleted); try { provider.ShowSnapshot(snapshot.Id); Assert.Fail("Expected an exception after a snapshot is deleted."); } catch (ItemNotFoundException) { // this makes the most sense } catch (UserNotAuthorizedException) { // this is allowed by the interface, and some providers could report it for security reasons } catch (ResponseException) { // this is allowed by the interface } // // Volume cleanup... // bool deletedVolume = provider.DeleteVolume(result.Id); Assert.IsTrue(deletedVolume); deletedVolume = provider.WaitForVolumeDeleted(result.Id); Assert.IsTrue(deletedVolume); }
private CloudBlockStorageOrphanedSnapshotsNode CreateOrphanedSnapshotsNode(CloudBlockStorageProvider provider) { return new CloudBlockStorageOrphanedSnapshotsNode(provider); }
public void CleanupTestSnapshots() { IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity); IEnumerable<Snapshot> snapshots = provider.ListSnapshots(); foreach (Snapshot snapshot in snapshots) { if (string.IsNullOrEmpty(snapshot.DisplayName)) continue; if (!snapshot.DisplayName.StartsWith(UnitTestSnapshotPrefix)) continue; Console.WriteLine("Deleting unit test snapshot... {0} ({1})", snapshot.DisplayName, snapshot.Id); provider.DeleteSnapshot(snapshot.Id); } }
private CloudBlockStorageVolumeNode CreateVolumeNode(CloudBlockStorageProvider provider, Volume volume) { return new CloudBlockStorageVolumeNode(provider, volume); }