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 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); }
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 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); }