Exemplo n.º 1
0
        public async Task VolumesTest()
        {
            var volume = await _testData.CreateVolume();

            await volume.WaitUntilAvailableAsync();

            Assert.NotNull(volume.Id);
            Assert.NotNull(volume.Name);
            Assert.Null(volume.Description);
            Assert.Null(volume.SourceSnapshotId);
            Assert.Empty(volume.Attachments);

            var volumeDetails = await _compute.GetVolumeAsync(volume.Id);

            Assert.Equal(volume.Id, volumeDetails.Id);
            Assert.Equal(volume.Name, volumeDetails.Name);
            Assert.Equal(volume.Description, volumeDetails.Description);
            Assert.Equal(volumeDetails.SourceSnapshotId, volumeDetails.SourceSnapshotId);
            Assert.Empty(volumeDetails.Attachments);

            var results = await _compute.ListVolumesAsync();

            Assert.NotNull(results);
            Assert.Contains(volume.Id, results.Select(x => x.Id));
        }
Exemplo n.º 2
0
        public async Task ServerVolumesTest()
        {
            var server = await _testData.CreateServer();

            await server.WaitUntilActiveAsync();

            Trace.WriteLine($"Created server named: {server.Name}");

            Trace.WriteLine("Creating a test volume...");
            var volume = await _testData.CreateVolume();

            Identifier volumeId = volume.Id;

            _testData.BlockStorage.StorageProvider.WaitForVolumeAvailable(volumeId);

            Trace.WriteLine("Attaching the volume...");
            await server.AttachVolumeAsync(new ServerVolumeDefinition(volumeId));

            _testData.BlockStorage.StorageProvider.WaitForVolumeState(volumeId, VolumeState.InUse, new[] { VolumeState.Error });

            var volumeRef = server.AttachedVolumes.FirstOrDefault();

            Assert.NotNull(volumeRef);

            Trace.WriteLine("Verifying volume was attached successfully...");
            var attachedVolumes = await server.ListVolumesAsync();

            var attachedVolume = attachedVolumes.FirstOrDefault(v => v.Id == volumeId);

            Assert.NotNull(attachedVolume);

            Trace.WriteLine("Retrieving attached volume details...");
            var serverVolume = await volumeRef.GetServerVolumeAsync();

            Assert.Equal(volumeId, serverVolume.VolumeId);
            Assert.Equal(server.Id, serverVolume.ServerId);

            Trace.WriteLine("Detaching the volume...");
            await volumeRef.DetachAsync();

            Assert.DoesNotContain(server.AttachedVolumes, v => v.Id == volumeId);
            _testData.BlockStorage.StorageProvider.WaitForVolumeAvailable(volumeId);
        }