Example #1
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);
            }
        }
        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);
            }
        }
Example #3
0
        private ClusterCreateParameters CreateClusterToValidateScriptActions(string resourceGroup, string dnsName, HDInsightManagementClient client)
        {
            var clusterCreateParams = GetClusterSpecHelpers.GetCustomCreateParametersIaas();

            client.Clusters.Create(resourceGroup, dnsName, clusterCreateParams);

            HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsName, client);

            // upload only in record mode
            if (HDInsightManagementTestUtilities.IsRecordMode())
            {
                //upload failing script to the cluster  default storage account
                var defaultStorageAccount = clusterCreateParams.DefaultStorageInfo as AzureStorageInfo;
                var storageAccountName    = defaultStorageAccount.StorageAccountName.Split('.')[0];
                var creds = new StorageCredentials(storageAccountName, defaultStorageAccount.StorageAccountKey);

                var storageAccount = new CloudStorageAccount(creds, true);
                var blobClient     = storageAccount.CreateCloudBlobClient();
                var container      = blobClient.GetContainerReference(FailingScriptLocationContainer);
                container.CreateIfNotExists();
                var blockBlob = container.GetBlockBlobReference("failingscriptaction.sh");

                using (var fileStream = System.IO.File.OpenRead(@"TestData/FailingScriptAction.sh"))
                {
                    blockBlob.UploadFromStream(fileStream);
                }
            }

            return(clusterCreateParams);
        }
Example #4
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);
            }
        }
Example #5
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);
            }
        }