Exemplo n.º 1
0
        public async Task CreateServerGroup_AndAssociateAServerTest()
        {
            ServerGroupDefinition definition = _testData.BuildServerGroup();

            Trace.WriteLine($"Creating server group named: {definition.Name}");
            ServerGroup serverGroup = await _testData.CreateServerGroup(definition);

            Trace.WriteLine("Verifying server group matches requested definition...");
            Assert.NotNull(serverGroup);
            Assert.Equal(definition.Name, serverGroup.Name);
            Assert.Equal(definition.Policies, serverGroup.Policies);

            Trace.WriteLine("Creating a server associated with the group...");
            ServerCreateDefinition serverDefinition = _testData.BuildServer();

            serverDefinition.SchedulerHints = new SchedulerHints();
            serverDefinition.SchedulerHints.Add("group", serverGroup.Id);
            var server = await _testData.CreateServer(serverDefinition);

            await server.WaitUntilActiveAsync();

            Trace.WriteLine("Verifying the server is a member of the group...");
            serverGroup = await _compute.GetServerGroupAsync(serverGroup.Id);

            Assert.Contains(server.Id, serverGroup.Members);

            Trace.WriteLine("Deleting the server group...");
            await serverGroup.DeleteAsync();

            var groups = await _compute.ListServerGroupsAsync();

            Assert.DoesNotContain(serverGroup.Id, groups.Select(x => x.Id));
        }
Exemplo n.º 2
0
        public async Task FindSnapshotsTest()
        {
            Trace.WriteLine("Creating a test server...");
            var server = await _testData.CreateServer();

            await server.WaitUntilActiveAsync();

            Trace.WriteLine("Snapshotting server...");
            var snapshot = await server.SnapshotAsync(new SnapshotServerRequest(server.Name + "SNAPSHOT"));

            _testData.Register(snapshot);

            Trace.WriteLine("Getting snapshot details...");
            var results = await _compute.ListImagesAsync(new ImageListOptions { Type = ImageType.Snapshot });

            Assert.NotNull(results);
            Assert.All(results, x => Assert.Equal(ImageType.Snapshot, x.Type));
            Assert.Contains(results, image => image.Id == snapshot.Id);
        }
Exemplo n.º 3
0
        public async Task AttachVolumeTest()
        {
            var server = await _testData.CreateServer();

            await server.WaitUntilActiveAsync();

            var volume = await _testData.CreateVolume();

            await volume.WaitUntilAvailableAsync();

            var serverVolume = await server.AttachVolumeAsync(new ServerVolumeDefinition(volume.Id));

            _testData.Register(serverVolume);
            await volume.WaitForStatusAsync(VolumeStatus.InUse);

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

            serverVolume = volume.Attachments.FirstOrDefault();

            Assert.NotNull(serverVolume);
            Assert.Equal(server.Id, serverVolume.ServerId);
            Assert.Equal(volume.Id, serverVolume.VolumeId);
        }
Exemplo n.º 4
0
        public async Task CreateServerTest()
        {
            var definition = _testData.BuildServer();

            Trace.WriteLine($"Creating server named: {definition.Name}");
            var server = await _testData.CreateServer(definition);

            await server.WaitUntilActiveAsync();

            Trace.WriteLine("Verifying server matches requested definition...");
            Assert.NotNull(server);
            Assert.Equal(definition.Name, server.Name);
            Assert.NotNull(server.Flavor);
            Assert.Equal(definition.FlavorId, server.Flavor.Id);
            Assert.NotNull(server.AdminPassword);
            Assert.NotNull(server.Image);
            Assert.Equal(definition.ImageId, server.Image.Id);
            Assert.Equal(server.Status, ServerStatus.Active);
            Assert.NotNull(server.AvailabilityZone);
            Assert.NotNull(server.Created);
            Assert.NotNull(server.LastModified);
            Assert.NotNull(server.Launched);
            Assert.NotNull(server.DiskConfig);
            Assert.NotNull(server.HostId);
            Assert.NotNull(server.PowerState);
            Assert.NotNull(server.VMState);
            Assert.NotNull(server.SecurityGroups);

            var history = await server.ListActionSummariesAsync();

            Assert.NotNull(history);
            var createRef = history.FirstOrDefault(a => a.Name == "create");

            Assert.NotNull(createRef);
            Assert.NotNull(createRef.Id);
            Assert.NotNull(createRef.Name);
            Assert.NotNull(createRef.ServerId);
            Assert.NotNull(createRef.UserId);

            var createAction = await createRef.GetActionAsync();

            Assert.NotNull(createAction);
            Assert.NotNull(createAction.Id);
            Assert.NotNull(createAction.Name);
            Assert.NotNull(createAction.Events);
        }