コード例 #1
0
        public async Task ContainerServiceCreateManagedServiceTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                InitializeClients(context);

                string location = ContainerServiceTestUtilities.GetLocationFromProvider(resourceManagementClient);

                var resourceGroup = resourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(ContainerServiceTestUtilities.ResourceGroupPrefix);
                    resourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                string clusterName = TestUtilities.GenerateName();

                // Create a managed AKS cluster
                ManagedCluster managedClusterResult = await ContainerServiceTestUtilities.CreateManagedCluster(
                    context,
                    ResourceManagementClient,
                    ContainerServiceClient,
                    location,
                    clusterName,
                    resourceGroup);

                Assert.NotNull(managedClusterResult);
                Assert.Equal(clusterName, managedClusterResult.Name);
                Assert.Equal(ContainerServiceTestUtilities.DnsPrefix, managedClusterResult.DnsPrefix);

                // Clean up our Azure resources
                ResourceManagementClient.ResourceGroups.DeleteAsync(resourceGroup).Wait();
            }
        }
コード例 #2
0
        public async Task ContainerServiceListOrchestratorsTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                InitializeClients(context);

                var location = ContainerServiceTestUtilities.GetLocationFromProvider(ResourceManagementClient);

                var orchestratorsListResult = await ContainerServiceClient.ContainerServices.ListOrchestratorsAsync(location);

                Assert.NotNull(orchestratorsListResult);
                Assert.True(orchestratorsListResult.Orchestrators.Count > 0);
            }
        }
コード例 #3
0
 protected void InitializeClients(MockContext context)
 {
     if (!m_initialized)
     {
         lock (m_lock)
         {
             if (!m_initialized)
             {
                 resourceManagementClient = ContainerServiceTestUtilities.GetResourceManagementClient(context, new RecordedDelegatingHandler {
                     StatusCodeToReturn = HttpStatusCode.OK
                 });
                 containerServiceClient = ContainerServiceTestUtilities.GetContainerServiceManagementClient(context, new RecordedDelegatingHandler {
                     StatusCodeToReturn = HttpStatusCode.OK
                 });
             }
         }
     }
 }
コード例 #4
0
        public async Task ContainerServiceDeleteServiceTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                InitializeClients(context);

                string location = ContainerServiceTestUtilities.GetLocationFromProvider(resourceManagementClient);

                var resourceGroup = resourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(ContainerServiceTestUtilities.ResourceGroupPrefix);
                    resourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                string clusterName = TestUtilities.GenerateName();

                // Create a managed AKS cluster
                ManagedCluster managedClusterResult = await ContainerServiceTestUtilities.CreateManagedCluster(
                    context,
                    ResourceManagementClient,
                    ContainerServiceClient,
                    location,
                    clusterName,
                    resourceGroup);

                // Wait for 10 seconds a sanity check
                TestUtilities.Wait(10000);

                // Delete the cluster
                containerServiceClient.ManagedClusters.DeleteAsync(resourceGroup, clusterName).Wait();

                // List clusters by resource group
                var managedService = await containerServiceClient.ManagedClusters.ListByResourceGroupAsync(resourceGroup);

                Assert.True(!managedService.IsAny());

                // Clean up our Azure resources
                ResourceManagementClient.ResourceGroups.DeleteAsync(resourceGroup).Wait();
            }
        }
コード例 #5
0
        public async Task ContainerServiceGetCredentialsTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                InitializeClients(context);

                string location = ContainerServiceTestUtilities.GetLocationFromProvider(resourceManagementClient);

                var resourceGroup = resourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(ContainerServiceTestUtilities.ResourceGroupPrefix);
                    resourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                string clusterName = TestUtilities.GenerateName();

                // Create a managed AKS cluster
                ManagedCluster managedClusterResult = await ContainerServiceTestUtilities.CreateManagedCluster(
                    context,
                    ResourceManagementClient,
                    ContainerServiceClient,
                    location,
                    clusterName,
                    resourceGroup);

                // Fetch admin credentials
                var adminCredentials = await containerServiceClient.ManagedClusters.ListClusterAdminCredentialsAsync(resourceGroup, clusterName);

                Assert.True(adminCredentials.Kubeconfigs.Count > 0);

                // Fetch user credentials
                var userCredentials = await containerServiceClient.ManagedClusters.ListClusterUserCredentialsAsync(resourceGroup, clusterName);

                Assert.True(userCredentials.Kubeconfigs.Count > 0);

                // Clean up our Azure resources
                ResourceManagementClient.ResourceGroups.DeleteAsync(resourceGroup).Wait();
            }
        }
コード例 #6
0
        public async Task ContainerServiceUpdateServiceTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                InitializeClients(context);

                string location = ContainerServiceTestUtilities.GetLocationFromProvider(resourceManagementClient);

                var resourceGroup = resourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(ContainerServiceTestUtilities.ResourceGroupPrefix);
                    resourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                string clusterName = TestUtilities.GenerateName();

                // Create a managed AKS cluster
                ManagedCluster managedClusterResult = await ContainerServiceTestUtilities.CreateManagedCluster(
                    context,
                    ResourceManagementClient,
                    ContainerServiceClient,
                    location,
                    clusterName,
                    resourceGroup);

                // Alter the number of agents and invoke update
                managedClusterResult.AgentPoolProfiles[0].Count = 2;

                var updatedCluster = await ContainerServiceClient.ManagedClusters.CreateOrUpdateAsync(resourceGroup, clusterName, managedClusterResult);

                Assert.Equal(2, updatedCluster.AgentPoolProfiles[0].Count);
                Assert.Equal(clusterName, managedClusterResult.Name);

                // Clean up our Azure resources
                ResourceManagementClient.ResourceGroups.DeleteAsync(resourceGroup).Wait();
            }
        }