Skip to content

Container instances/groups management client#3580

Closed
ScottHolden wants to merge 4 commits intoAzure:psSdkJson6from
ScottHolden:containerInstances
Closed

Container instances/groups management client#3580
ScottHolden wants to merge 4 commits intoAzure:psSdkJson6from
ScottHolden:containerInstances

Conversation

@ScottHolden
Copy link
Copy Markdown
Contributor

Generated the ContinerInstances client along with a base set of scenario tests.

This rest api spec was already merged, so generated it straight off there :)


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

SDK Generation Guidelines

  • [] If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
  • The generate.cmd file for the SDK has been updated with the version of AutoRest, as well as the commitid of your swagger spec or link to the swagger spec, used to generate the code.
  • The *.csproj and AssemblyInfo.cs files have been updated with the new version of the SDK.

@azuresdkci
Copy link
Copy Markdown
Contributor

Can one of the admins verify this patch?

1 similar comment
@azuresdkci
Copy link
Copy Markdown
Contributor

Can one of the admins verify this patch?

@msftclas
Copy link
Copy Markdown

@ScottHolden,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

@shahabhijeet
Copy link
Copy Markdown
Contributor

@sauryadas @rgardler Can one of you review this PR for Container instance.

@shahabhijeet
Copy link
Copy Markdown
Contributor

@ScottHolden can you point me to the REST API spec that you had the PR opened?
Also what is the reason to generate the SDK? Is the latest SDK lagging behind the current REST API Spec?

@ScottHolden
Copy link
Copy Markdown
Contributor Author

Hi @shahabhijeet ,
This was merged into the rest spec back in Azure/azure-rest-api-specs#1480

The .NET SDK did not have this client, thus it was created from scratch.

Let me know if you need any more info :)

@shahabhijeet
Copy link
Copy Markdown
Contributor

@sauryadas can you approve this PR?

{
public const string DefaultTestPrefix = "defaulttestprefix-";
public const string DefaultResourceGroupPrefix = "testresourcegroup-";
public const string DefaultLocationId = "japaneast";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public const string DefaultLocationId = "japaneast"; [](start = 2, length = 52)

@scott@nullops.io No need. Just use location.

public const string DefaultTestPrefix = "defaulttestprefix-";
public const string DefaultResourceGroupPrefix = "testresourcegroup-";
public const string DefaultLocationId = "japaneast";
public const string DefaultLocation = "Japan East";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Japan East"; [](start = 40, length = 13)

Is it possible to use "westus" instead?

{
throw new KeyNotFoundException(string.Format("Generated name not found for calling method: {0}", methodName), e);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just use TestUtilities.GenerateName

ResourceGroup resourceGroup = context.CreateResourceGroup("containergroupcrd-", containerInstanceLocation);
ContainerInstanceManagementClient containerClient = context.GetClient<ContainerInstanceManagementClient>();

string containerGroupName = context.GenerateName("containergroup");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context.GenerateName [](start = 32, length = 20)

Just use TestUtilities.GenerateName

string containerGroupName = context.GenerateName("containergroup");
string containerOsType = "Linux";

string containerName = "test1";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"test1" [](start = 27, length = 7)

Can you also use TestUtilities.GenerateName to generate a random name?

ContainerInstanceManagementClient containerClient = context.GetClient<ContainerInstanceManagementClient>();

string containerGroupName = context.GenerateName("containergroup");
string containerOsType = "Linux";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Linux" [](start = 29, length = 7)

Use OperatingSystemTypes.Linux

Assert.NotNull(createdContainerGroup);
Assert.Equal(containerGroupName, createdContainerGroup.Name);
Assert.Equal(containerOsType, createdContainerGroup.OsType);
Assert.Equal(1, createdContainerGroup.Containers.Count);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also verify the there is public IP address assigned.

Assert.Equal(1, getContainer.Ports.Count);
Assert.Equal(containerPort, getContainer.Ports.First().Port);
Assert.Equal(containerCpu, getContainer.Resources.Requests.Cpu);
Assert.Equal(containerMemoryInGB, getContainer.Resources.Requests.MemoryInGB);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap all the assertion into a helper method.

IPage<ContainerGroup> listSubContainerGroup = containerClient.ContainerGroups.List();
Assert.NotNull(listRgContainerGroup);
Assert.True(listRgContainerGroup.Count() >= 1);
Assert.True(listRgContainerGroup.Any(x => containerGroupID.Equals(x?.Id)));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a test case in which you create 2 container group. When listing all, you should get both. When listing by resource group, you should only get one.

Assert.Equal(containerMemoryInGB, createdContainer.Resources.Requests.MemoryInGB);

// Wait till the container group is ready before proceeding
ContainerGroupUtilities.WaitTillProvisioningStateSucceeded(containerClient, resourceGroup.Name, containerGroupName);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really necessary. You can call get or list before reach succeeded provisioning state.


namespace ContainerInstance.Tests.Utilities
{
class ContainerInstanceTestUtilities
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ContainerInstanceTestUtilities [](start = 10, length = 30)

Seems not used anywhere? Remove this class?

<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
<PackageReference Include="WindowsAzure.Storage" Version="8.1.4" />
</ItemGroup>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove. All not needed.


string containerGroupName = context.GenerateName("containergroup");
string containerOsType = "Linux";
string containerName = "test1";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the other scenario tests. Use built in function to generate name.

Copy link
Copy Markdown
Contributor

@yolocs yolocs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Scott, thanks for contributing. Left several comments.

Copy link
Copy Markdown
Contributor

@shahabhijeet shahabhijeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ScottHolden thank you for your valuable contribution. This is helpful.
Please make changes suggested in the PR

<TargetFrameworks>netcoreapp1.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Utilities\ContainerInstanceTestUtilities.cs" />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ScottHolden this is not needed. I know VS might have added it, can you remove it. VS will include code files by default in all sub directories.

</ItemGroup>

<ItemGroup>
<Folder Include="SessionRecords\" />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ScottHolden can you clean up these itemgroup, you do not need a separate directory itemgroup for SessionRecords

@shahabhijeet
Copy link
Copy Markdown
Contributor

@ScottHolden this PR has not addressed the feedback and the below PR is ready to be merged
#3615
Closing this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants