Пример #1
0
        public void TestGetConfigCoreSiteCluster()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var          resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);
                const string dnsname       = "hdisdk-configtest";

                var spec = GetClusterSpecHelpers.GetPaasClusterSpec();

                client.Clusters.Create(resourceGroup, dnsname, spec);

                var configs = client.Clusters.GetClusterConfigurations(resourceGroup, dnsname, "core-site");

                Assert.Equal(2, configs.Configuration.Count);

                client.Clusters.Delete(resourceGroup, dnsname);
            }
        }
Пример #2
0
        public void TestCreateWindowsClusterWithStandardTier()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                var cluster = GetClusterSpecHelpers.GetPaasClusterSpec();
                cluster.Properties.ClusterTier = Tier.Standard;
                const string dnsname = "hdisdk-IaasClusterStandardTierTest";

                var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);

                Assert.Equal(dnsname, createresponse.Cluster.Name);
                var clusterResponse = client.Clusters.Get(resourceGroup, dnsname);
                Assert.Equal(createresponse.Cluster.Properties.ClusterTier, Tier.Standard);
                HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsname, client);
                var result = client.Clusters.Delete(resourceGroup, dnsname);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
                Assert.Equal(result.State, AsyncOperationState.Succeeded);
            }
        }
Пример #3
0
        //[Fact]
        public void TestCustomCreateEnableDisableConnectivity()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                var          cluster = GetClusterSpecHelpers.GetCustomCreateParametersPaas();
                const string dnsname = "hdisdk-testcluster1";

                var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
                Assert.Equal(dnsname, createresponse.Cluster.Name);

                var getresponse = client.Clusters.Get(resourceGroup, dnsname);

                client.Clusters.DisableHttp(resourceGroup, dnsname);
                getresponse = client.Clusters.Get(resourceGroup, dnsname);

                client.Clusters.EnableHttp(resourceGroup, dnsname, "hadoopuser", "Akasja2!1a");
                getresponse = client.Clusters.Get(resourceGroup, dnsname);

                var result = client.Clusters.Delete(resourceGroup, dnsname);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
                Assert.Equal(result.State, AsyncOperationState.Succeeded);
            }
        }
Пример #4
0
        public void TestCreateWindowsClusterWithPremiumTier()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();
                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);
                var cluster = GetClusterSpecHelpers.GetPaasClusterSpec();
                cluster.Properties.ClusterTier = Tier.Premium;
                const string dnsname = "hdisdk-WindowsClusterPremiumTest";
                try
                {
                    client.Clusters.Create(resourceGroup, dnsname, cluster);
                }
                catch (CloudException ex)
                {
                    Assert.Equal(ex.Response.StatusCode, HttpStatusCode.BadRequest);
                }
            }
        }
Пример #5
0
        public void TestCreateDataLakeClusterUsingClusterCreateParametersExtended()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                //get clients
                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                //create resourcegroup
                var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                //set variables
                const string dnsname = "hdisdk-datalake5";

                var spec = GetDataLakeClusterParametersExtended();

                var createresponse = client.Clusters.Create(resourceGroup, dnsname, spec);

                //TODO: Assert if data lake configurations are set once shefali adds GetConfigurations support
                var getresponse = client.Clusters.Get(resourceGroup, dnsname);
                Assert.Equal(createresponse.Cluster.Properties.CreatedDate, getresponse.Cluster.Properties.CreatedDate);
                Assert.Equal(createresponse.Cluster.Name, getresponse.Cluster.Name);

                OperationResource result = client.Clusters.Delete(resourceGroup, dnsname);
            }
        }
Пример #6
0
        //[Fact]
        public void TestIaasCreateGetDeleteCluster()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                var          cluster = GetClusterSpecHelpers.GetIaasClusterSpec();
                const string dnsname = "hdisdk-iaascluster";

                var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
                Assert.Equal(cluster.Location, createresponse.Cluster.Location);
                Assert.Equal(cluster.Properties.ClusterDefinition.ClusterType, createresponse.Cluster.Properties.ClusterDefinition.ClusterType);
                //Assert.Equal(cluster.Properties.ClusterVersion, createresponse.Cluster.Properties.ClusterVersion);
                Assert.Null(createresponse.Cluster.Properties.ClusterDefinition.Configurations);
                Assert.Equal(createresponse.StatusCode, HttpStatusCode.OK);

                var getresponse = client.Clusters.Get(resourceGroup, dnsname);
                Assert.Equal(createresponse.Cluster.Properties.ComputeProfile.Roles.Count, getresponse.Cluster.Properties.ComputeProfile.Roles.Count);
                Assert.Equal(createresponse.Cluster.Properties.CreatedDate, getresponse.Cluster.Properties.CreatedDate);

                var result = client.Clusters.Delete(resourceGroup, dnsname);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
                Assert.Equal(result.State, AsyncOperationState.Succeeded);
            }
        }
Пример #7
0
        public void TestCreateHumboldtClusterWithCustomVMSizes()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                var          cluster = GetClusterSpecHelpers.GetCustomVmSizesCreateParametersIaas();
                const string dnsname = "hdisdk-iaasclusternew-customvmsizes-2";

                var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
                Assert.Equal(dnsname, createresponse.Cluster.Name);

                client.Clusters.Get(resourceGroup, dnsname);

                var result = client.Clusters.Delete(resourceGroup, dnsname);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
                Assert.Equal(result.State, AsyncOperationState.Succeeded);
            }
        }
        //[Fact]
        public void TestResizeCluster()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var          resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);
                const string dnsname       = "hdisdk-resizetest";

                var spec = GetClusterSpecHelpers.GetPaasClusterSpec();

                client.Clusters.Create(resourceGroup, dnsname, spec);

                var cluster = client.Clusters.Get(resourceGroup, dnsname);

                var resizeParams = new ClusterResizeParameters
                {
                    TargetInstanceCount = 2
                };

                client.Clusters.Resize(resourceGroup, dnsname, resizeParams);

                cluster = client.Clusters.Get(resourceGroup, dnsname);

                client.Clusters.Delete(resourceGroup, dnsname);
            }
        }
        //[Fact]
        public void TestInvalidResizeClusterOperations()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var          resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);
                const string dnsname       = "hdisdk-resize2";

                var spec = GetClusterSpecHelpers.GetPaasClusterSpec();

                client.Clusters.Create(resourceGroup, dnsname, spec);

                ResizeWithMissingTargetInstanceCount(client, resourceGroup, dnsname);
                ResizeToSameInstanceCount(client, resourceGroup, dnsname);
                ResizeWithOngoingResize(client, resourceGroup, dnsname);
            }
        }
        public void TestCreateLinuxSparkClusterWithComponentVersion()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                var cluster = GetClusterSpecHelpers.GetCustomCreateParametersSparkIaas();
                cluster.ClusterTier = Tier.Standard;
                const string dnsname = "hdisdk-SparkLinuxClusterComponentVersionTest";

                var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
                Assert.Equal(dnsname, createresponse.Cluster.Name);

                client.Clusters.Get(resourceGroup, dnsname);
                Assert.NotNull(createresponse.Cluster.Properties.ClusterDefinition.ComponentVersion);

                HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsname, client);
                var result = client.Clusters.Delete(resourceGroup, dnsname);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
                Assert.Equal(result.State, AsyncOperationState.Succeeded);
            }
        }
Пример #11
0
        public void TestDisableEnableHttpCustomCode()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var          resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);
                const string dnsname       = "hdisdk-httptest3";

                var spec = GetClusterSpecHelpers.GetPaasClusterSpec();

                client.Clusters.Create(resourceGroup, dnsname, spec);

                var httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname);
                Assert.True(httpSettings.HttpUserEnabled);

                client.Clusters.DisableHttp(resourceGroup, dnsname);
                httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname);
                Assert.False(httpSettings.HttpUserEnabled);

                client.Clusters.EnableHttp(resourceGroup, dnsname, "admin", "Password1!");
                httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname);
                Assert.True(httpSettings.HttpUserEnabled);

                client.Clusters.Delete(resourceGroup, dnsname);
            }
        }
Пример #12
0
        public void TestCreateDuplicateCluster()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                var          cluster = GetClusterSpecHelpers.GetPaasClusterSpec();
                const string dnsname = "hdisdk-clusterdupe";

                var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
                Assert.Equal(dnsname, createresponse.Cluster.Name);

                try
                {
                    client.Clusters.Create(resourceGroup, dnsname, cluster);
                }
                catch (CloudException ex)
                {
                    Assert.Equal(ex.Response.StatusCode, HttpStatusCode.Conflict);
                }

                OperationResource result = client.Clusters.Delete(resourceGroup, dnsname);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
                Assert.Equal(result.State, AsyncOperationState.Succeeded);
            }
        }
Пример #13
0
        public void TestEnableDisableDisableHttp()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var          resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);
                const string dnsname       = "hdisdk-httptest3";

                var spec = GetClusterSpecHelpers.GetPaasClusterSpec();

                var cluster = client.Clusters.Create(resourceGroup, dnsname, spec);

                string errorMessage = cluster.Cluster.Properties.ErrorInfos.Any()
                    ? cluster.Cluster.Properties.ErrorInfos[0].Message
                    : String.Empty;

                Assert.True(cluster.Cluster.Properties.ClusterState.Equals("Running", StringComparison.OrdinalIgnoreCase),
                            String.Format("Cluster Creation Failed ErrorInfo: {0}", errorMessage));

                HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsname, client);

                var httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname);
                Assert.True(httpSettings.HttpUserEnabled);

                var httpParams = new HttpSettingsParameters
                {
                    HttpUserEnabled = false,
                };

                client.Clusters.ConfigureHttpSettings(resourceGroup, dnsname, httpParams);
                httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname);
                Assert.False(httpSettings.HttpUserEnabled);

                client.Clusters.ConfigureHttpSettings(resourceGroup, dnsname, httpParams);

                httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname);
                Assert.False(httpSettings.HttpUserEnabled);

                client.Clusters.Delete(resourceGroup, dnsname);
            }
        }
Пример #14
0
        public void TestEnableEnableHttp()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var          resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);
                const string dnsname       = "hdisdk-httptest3";

                var spec = GetClusterSpecHelpers.GetPaasClusterSpec();

                client.Clusters.Create(resourceGroup, dnsname, spec);

                var httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname);

                Assert.True(httpSettings.HttpUserEnabled);

                var httpParams = new HttpSettingsParameters
                {
                    HttpUserEnabled = true,
                    HttpUsername    = "******",
                    HttpPassword    = "******"
                };

                try
                {
                    client.Clusters.ConfigureHttpSettings(resourceGroup, dnsname, httpParams);
                }
                catch (CloudException ex)
                {
                    Assert.Equal(ex.Response.StatusCode, HttpStatusCode.Conflict);
                }
                httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname);
                Assert.True(httpSettings.HttpUserEnabled);

                var result = client.Clusters.Delete(resourceGroup, dnsname);
                //Assert.Equal(result.StatusCode, HttpStatusCode.NoContent);
            }
        }
Пример #15
0
        public void TestDisableEnableRdpCustomCode()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                //get clients
                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                //create resourcegroup
                var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                //set variables
                const string dnsname = "hdisdk-rdpcluster0";

                var spec = GetClusterSpecHelpers.GetPaasClusterSpec();

                //test
                var cluster = client.Clusters.Create(resourceGroup, dnsname, spec);
                Assert.True(
                    cluster.Cluster.Properties.ConnectivityEndpoints.Any(
                        c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase)));

                HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsname, client);

                client.Clusters.DisableRdp(resourceGroup, dnsname);
                cluster = client.Clusters.Get(resourceGroup, dnsname);
                Assert.False(
                    cluster.Cluster.Properties.ConnectivityEndpoints.Any(
                        c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase)));

                client.Clusters.EnableRdp(resourceGroup, dnsname, "rdpuser", "Password1!", new DateTime(2018, 10, 12));
                cluster = client.Clusters.Get(resourceGroup, dnsname);
                Assert.True(
                    cluster.Cluster.Properties.ConnectivityEndpoints.Any(
                        c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase)));

                client.Clusters.Delete(resourceGroup, dnsname);
            }
        }
Пример #16
0
        //[Fact]
        public void TestListClustersByResourceGroup()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var resourceGroup1 = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);
                var resourceGroup2 = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                const string dnsname1 = "hdisdk-paas01";
                const string dnsname2 = "hdisdk-paas02";
                const string dnsname3 = "hdisdk-paas03";

                var paasSpec = GetClusterSpecHelpers.GetPaasClusterSpec();

                Parallel.Invoke(
                    () => client.Clusters.Create(resourceGroup1, dnsname1, paasSpec),
                    () => client.Clusters.Create(resourceGroup1, dnsname2, paasSpec),
                    () => client.Clusters.Create(resourceGroup2, dnsname3, paasSpec)
                    );

                var listresponse1 = client.Clusters.ListByResourceGroup(resourceGroup1);
                //Assert.Equal(listresponse1.Clusters.Count, 2);
                //Assert.True(listresponse1.Clusters.Any(c => c.Name.Equals(dnsname1)));
                //Assert.True(listresponse1.Clusters.Any(c => c.Name.Equals(dnsname2)));

                var listresponse2 = client.Clusters.ListByResourceGroup(resourceGroup2);
                //Assert.Equal(listresponse2.Clusters.Count, 1);
                //Assert.True(listresponse2.Clusters.Any(c => c.Name.Equals(dnsname3)));

                client.Clusters.Delete(resourceGroup1, dnsname1);
                client.Clusters.Delete(resourceGroup1, dnsname2);
                client.Clusters.Delete(resourceGroup2, dnsname3);
            }
        }
        public void TestRunningScriptActionsOnDisabledSub()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                // need to use static name , so tests work in playback mode
                var dnsName = "hdiscriptactionffc11783-ae94-4189-9b05-513a9f5783f4";

                string scriptName = "script" + Guid.NewGuid().ToString().Substring(0, 10);

                var clusterCreateParams = CreateClusterToValidateScriptActions(resourceGroup, dnsName, client);

                var executeScriptActionParamsPersisted = GetExecuteScriptActionParams(true, scriptName, InstallGiraph);

                try
                {
                    var response = client.Clusters.ExecuteScriptActions(resourceGroup, dnsName, executeScriptActionParamsPersisted);

                    Assert.True(false, "Failed to reject script actions request for a disabled sub");
                }
                catch (Hyak.Common.CloudException ex)
                {
                    Assert.Equal(HttpStatusCode.BadRequest, ex.Response.StatusCode);

                    Assert.True(ex.Message.Contains("Script actions on running cluster is not supported for this subscription"));
                }
                finally
                {
                    client.Clusters.Delete(resourceGroup, dnsName);
                }
            }
        }
Пример #18
0
        public void TestListEmptyResourceGroup()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                var listResult = client.Clusters.ListByResourceGroup(resourceGroup);
                Assert.NotNull(listResult);
                Assert.Equal(listResult.Clusters.Count, 0);

                resourceManagementClient.ResourceGroups.Delete(resourceGroup);
            }
        }
Пример #19
0
        public void TestCreateDataLakeClusterUsingClusterParameters()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                //get clients
                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                //create resourcegroup
                var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                //set variables
                const string dnsname = "hdisdk-datalake5";

                var clusterCreateParams = GetDataLakeClusterParameters();

                var createresponse = client.Clusters.Create(resourceGroup, dnsname, clusterCreateParams);
                Assert.Equal(dnsname, createresponse.Cluster.Name);

                //TODO: Assert if data lake configurations are set once shefali adds GetConfigurations support
                var getresponse = client.Clusters.Get(resourceGroup, dnsname);
                Assert.Equal(createresponse.Cluster.Properties.CreatedDate, getresponse.Cluster.Properties.CreatedDate);
                Assert.Equal(createresponse.Cluster.Name, getresponse.Cluster.Name);

                // Assert cluster state
                Assert.Equal(createresponse.Cluster.Properties.ClusterState, "Error"); // due to invalid script action
                Assert.Equal(createresponse.Cluster.Properties.ErrorInfos.Count, 1);

                // delete the cluster
                var result = client.Clusters.Delete(resourceGroup, dnsname);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
                Assert.Equal(result.State, AsyncOperationState.Succeeded);
            }
        }
        public void TestAdJoinedIaasCreateGetDeleteCluster()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient, "East US 2");

                var          cluster = GetClusterSpecHelpers.GetAdJoinedCreateParametersIaas();
                const string dnsname = "HdiSdk-AdJoinedIaasCluster";

                var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
                Assert.Equal(cluster.Location, createresponse.Cluster.Location);
                Assert.Equal(cluster.ClusterType, createresponse.Cluster.Properties.ClusterDefinition.ClusterType);
                Assert.Null(createresponse.Cluster.Properties.ClusterDefinition.Configurations);
                Assert.Equal(createresponse.StatusCode, HttpStatusCode.OK);
                Assert.Equal(createresponse.Cluster.Properties.ProvisioningState, HDInsightClusterProvisioningState.Succeeded);
                Assert.Equal(createresponse.Cluster.Properties.ClusterState, "Running");

                var getresponse = client.Clusters.Get(resourceGroup, dnsname);
                Assert.Equal(createresponse.Cluster.Properties.ComputeProfile.Roles.Count, getresponse.Cluster.Properties.ComputeProfile.Roles.Count);
                Assert.Equal(createresponse.Cluster.Properties.CreatedDate, getresponse.Cluster.Properties.CreatedDate);
                Assert.Equal(createresponse.Cluster.Properties.SecurityProfile.DirectoryType, getresponse.Cluster.Properties.SecurityProfile.DirectoryType);
                Assert.Equal(createresponse.Cluster.Properties.SecurityProfile.Domain, getresponse.Cluster.Properties.SecurityProfile.Domain);
                Assert.Equal(createresponse.Cluster.Properties.SecurityProfile.DomainUsername, getresponse.Cluster.Properties.SecurityProfile.DomainUsername);
                Assert.Equal(createresponse.Cluster.Properties.SecurityProfile.OrganizationalUnitDN, getresponse.Cluster.Properties.SecurityProfile.OrganizationalUnitDN);
                Assert.Equal(createresponse.Cluster.Properties.SecurityProfile.DirectoryType, getresponse.Cluster.Properties.SecurityProfile.DirectoryType);

                var result = client.Clusters.Delete(resourceGroup, dnsname);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
                Assert.Equal(result.State, AsyncOperationState.Succeeded);
            }
        }
Пример #21
0
        public void TestScriptActionsAPIOnNonExistentCluster()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                // need to use static name , so tests work in playback mode
                var dnsName = "hdiscriptaction8acbd2ae-670a-4c99-87ff-7324f079ed36";

                var executeScriptActionParams = GetExecuteScriptActionParams(true, "script" + Guid.NewGuid().ToString().Substring(0, 10), InstallGiraph);

                var exception = Assert.Throws <CloudException>(() => client.Clusters.ExecuteScriptActions(resourceGroup, dnsName, executeScriptActionParams));

                Assert.Equal(HttpStatusCode.NotFound, exception.Response.StatusCode);

                var listException = Assert.Throws <CloudException>(() => client.Clusters.ListPersistedScripts(resourceGroup, dnsName));

                Assert.Equal(HttpStatusCode.NotFound, listException.Response.StatusCode);

                var listHistory = Assert.Throws <CloudException>(() => client.Clusters.ListScriptExecutionHistory(resourceGroup, dnsName));

                Assert.Equal(HttpStatusCode.NotFound, listHistory.Response.StatusCode);

                var listExecutionDetail = Assert.Throws <CloudException>(() => client.Clusters.GetScriptExecutionDetail(resourceGroup, dnsName, 24));

                Assert.Equal(HttpStatusCode.NotFound, listHistory.Response.StatusCode);
            }
        }
Пример #22
0
        public void TestGetNonexistentCluster()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                try
                {
                    client.Clusters.Get(resourceGroup, "nonexistentcluster");
                }
                catch (CloudException ex)
                {
                    Assert.Equal(ex.Response.StatusCode, HttpStatusCode.NotFound);
                }
            }
        }
Пример #23
0
        public void TestCreateDefaultFsDataLakeClusterUsingClusterParameters()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                //get clients
                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                //create resourcegroup
                var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                //set variables
                const string dnsname = "hdisdk-defaultfsdatalake1";

                var clusterCreateParams = GetDefaultFsDatalakeClusterParameters();

                var createresponse = client.Clusters.Create(resourceGroup, dnsname, clusterCreateParams);
                Assert.Equal(dnsname, createresponse.Cluster.Name);
                Assert.Equal("Running", createresponse.Cluster.Properties.ClusterState);

                var getresponse = client.Clusters.Get(resourceGroup, dnsname);
                Assert.Equal(createresponse.Cluster.Properties.CreatedDate, getresponse.Cluster.Properties.CreatedDate);
                Assert.Equal(createresponse.Cluster.Name, getresponse.Cluster.Name);

                // delete the cluster
                var result = client.Clusters.Delete(resourceGroup, dnsname);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
                Assert.Equal(result.State, AsyncOperationState.Succeeded);
            }
        }
Пример #24
0
        public void TestCreateWithEmptyParameters()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
                var resourceGroup            = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                try
                {
                    client.Clusters.Create(resourceGroup, "fakecluster", new ClusterCreateParametersExtended());
                }
                catch (CloudException ex)
                {
                    Assert.Equal(ex.Response.StatusCode, HttpStatusCode.BadRequest);
                }
            }
        }
Пример #25
0
        public void TestDisableEnableRdp()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                //get clients
                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                //create resourcegroup
                var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                //set variables
                const string dnsname = "hdisdk-rdp1";

                var spec = GetClusterSpecHelpers.GetPaasClusterSpec();

                var rdpdisable = new RDPSettingsParameters
                {
                    OsProfile = new OsProfile
                    {
                        WindowsOperatingSystemProfile = new WindowsOperatingSystemProfile
                        {
                            RdpSettings = null
                        }
                    }
                };
                var rdpenable = new RDPSettingsParameters
                {
                    OsProfile = new OsProfile
                    {
                        WindowsOperatingSystemProfile = new WindowsOperatingSystemProfile
                        {
                            RdpSettings = new RdpSettings
                            {
                                ExpiryDate = new DateTime(2016, 10, 20),
                                Password   = "******",
                                UserName   = "******"
                            }
                        }
                    }
                };

                //test
                var cluster = client.Clusters.Create(resourceGroup, dnsname, spec);
                //Assert.True(
                //    cluster.Cluster.Properties.ConnectivityEndpoints.Any(
                //        c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase)));

                client.Clusters.ConfigureRdpSettings(resourceGroup, dnsname, rdpdisable);
                cluster = client.Clusters.Get(resourceGroup, dnsname);
                Assert.False(
                    cluster.Cluster.Properties.ConnectivityEndpoints.Any(
                        c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase)));

                client.Clusters.ConfigureRdpSettings(resourceGroup, dnsname, rdpenable);
                cluster = client.Clusters.Get(resourceGroup, dnsname);
                Assert.True(
                    cluster.Cluster.Properties.ConnectivityEndpoints.Any(
                        c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase)));

                client.Clusters.Delete(resourceGroup, dnsname);
            }
        }
Пример #26
0
        public void TestScriptActionsOnRunningCluster()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

                // need to use static name, so tests work in playback mode
                var dnsName = "hdiscriptaction733a2822-b098-443f-95b8-2e35f261a5c2";

                try
                {
                    // need to use static name , so tests work in playback mode
                    string scriptName = "script6de8a1ea-4";

                    var clusterCreateParams = CreateClusterToValidateScriptActions(resourceGroup, dnsName, client);

                    var executeScriptActionParamsPersisted = GetExecuteScriptActionParams(true, scriptName, InstallGiraph);

                    var response = client.Clusters.ExecuteScriptActions(resourceGroup, dnsName, executeScriptActionParamsPersisted);

                    Assert.Equal(AsyncOperationState.Succeeded, response.State);

                    var scriptActionsList = client.Clusters.ListPersistedScripts(resourceGroup, dnsName);

                    // validate that scripts are persisted
                    Assert.Equal(1, scriptActionsList.PersistedScriptActions.Count);
                    Assert.Equal(scriptActionsList.PersistedScriptActions[0].Name, executeScriptActionParamsPersisted.ScriptActions[0].Name);
                    Assert.Equal(scriptActionsList.PersistedScriptActions[0].Uri, executeScriptActionParamsPersisted.ScriptActions[0].Uri);
                    Assert.Equal(scriptActionsList.PersistedScriptActions[0].Roles.Count, executeScriptActionParamsPersisted.ScriptActions[0].Roles.Count);

                    Assert.True(scriptActionsList.PersistedScriptActions[0].ApplicationName == null);

                    // DELETE a script action
                    client.Clusters.DeletePersistedScript(resourceGroup, dnsName, scriptActionsList.PersistedScriptActions[0].Name);

                    //Do a get after delete, to validate that scripts have been deleted
                    scriptActionsList = client.Clusters.ListPersistedScripts(resourceGroup, dnsName);

                    Assert.Equal(0, scriptActionsList.PersistedScriptActions.Count);

                    var listHistoryResponse = client.Clusters.ListScriptExecutionHistory(resourceGroup, dnsName);

                    ValidateHistoryDetail(listHistoryResponse.RuntimeScriptActionDetail[0], false, scriptName);

                    // Get execution details of a single execution
                    var executionDetailedResponse = client.Clusters.GetScriptExecutionDetail(resourceGroup, dnsName, listHistoryResponse.RuntimeScriptActionDetail[0].ScriptExecutionId);

                    //validate a single execution detail with debug information
                    ValidateHistoryDetail(executionDetailedResponse.RuntimeScriptActionDetail, true, scriptName);

                    // Run Ad hoc execution
                    var executeScriptActionParamsAdHoc = GetExecuteScriptActionParams(false, "script" + Guid.NewGuid().ToString().Substring(0, 10), InstallGiraph);

                    var adHocExecutionResponse = client.Clusters.ExecuteScriptActions(resourceGroup, dnsName, executeScriptActionParamsAdHoc);

                    Assert.Equal(AsyncOperationState.Succeeded, adHocExecutionResponse.State);

                    var historyResponse = client.Clusters.ListScriptExecutionHistory(resourceGroup, dnsName);

                    //promote a script from ad hoc execution
                    var promoteResponse = client.Clusters.PromoteScript(resourceGroup, dnsName, historyResponse.RuntimeScriptActionDetail[0].ScriptExecutionId);

                    Assert.Equal(HttpStatusCode.OK, promoteResponse.StatusCode);

                    string failingScriptUri = "http://bing.com";

                    //this is set only for RECORD mode, playback this uri doesnt matter
                    if (HDInsightManagementTestUtilities.IsRecordMode())
                    {
                        failingScriptUri = string.Format(FailingScriptLocationFormat, clusterCreateParams.DefaultStorageInfo.StorageAccountName, FailingScriptLocationContainer);
                    }

                    var executeScriptActionParams = GetExecuteScriptActionParams(true, scriptName, failingScriptUri);

                    var result = client.Clusters.ExecuteScriptActions(resourceGroup, dnsName, executeScriptActionParams);
                    Assert.Equal(result.StatusCode, HttpStatusCode.OK);
                    Assert.Equal(result.State, AsyncOperationState.Failed);
                    Assert.Equal(result.ErrorInfo.Message, "ScriptExecutionFailed");

                    var scriptActionParams = GetExecuteScriptActionParams(true, "script" + Guid.NewGuid().ToString().Substring(0, 10), InstallGiraph);

                    var result2 = client.Clusters.ExecuteScriptActions(resourceGroup, dnsName, scriptActionParams.ScriptActions, true);

                    Assert.Equal(result2.StatusCode, HttpStatusCode.OK);
                    Assert.Equal(result2.State, AsyncOperationState.Succeeded);
                }
                finally
                {
                    //cleanup
                    client.Clusters.Delete(resourceGroup, dnsName);
                }
            }
        }