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)); }
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); }
public async Task SecurityGroupTest() { var definition = _testData.BuildSecurityGroup(); Trace.WriteLine($"Creating security group named: {definition.Name}"); var securityGroup = await _testData.CreateSecurityGroup(definition); Trace.WriteLine("Verifying security group matches requested definition..."); Assert.NotNull(securityGroup); Assert.Equal(definition.Name, securityGroup.Name); Assert.Equal(definition.Description, securityGroup.Description); Trace.WriteLine("Creatinga server associated with the security group..."); var serverDefinition = _testData.BuildServer(); serverDefinition.SecurityGroups.Add(new SecurityGroupReference()); Trace.WriteLine("Updating the security group..."); string updatedName = securityGroup.Name + "UPDATED"; securityGroup.Name = updatedName; await securityGroup.UpdateAsync(); Assert.Equal(updatedName, securityGroup.Name); Trace.WriteLine("Verifying the updated security group matches..."); securityGroup = await _compute.GetSecurityGroupAsync(securityGroup.Id); Assert.NotNull(securityGroup); Assert.Equal(updatedName, securityGroup.Name); Assert.Equal(definition.Description, securityGroup.Description); Trace.WriteLine("Deleting the security group..."); await securityGroup.DeleteAsync(); await Assert.ThrowsAsync <FlurlHttpException>(() => _compute.GetSecurityGroupAsync(securityGroup.Id)); }