コード例 #1
0
        public async Task ICannotSubmitAHttpDisableConnectivityRequestToAnUnsupportedClusterVersion()
        {
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();
            var client = ServiceLocator.Instance.Locate <IHDInsightClientFactory>()
                         .Create(new HDInsightCertificateCredential(credentials.SubscriptionId, credentials.Certificate));
            var clusterDetails = GetRandomCluster();

            try
            {
                var manager    = ServiceLocator.Instance.Locate <IHDInsightManagementPocoClientFactory>();
                var pocoClient = manager.Create(credentials, GetAbstractionContext(), false);

                clusterDetails.Version = "1.6.0.0.LargeSKU-amd64-134231";
                client.CreateCluster(clusterDetails);


                // Try disabling first
                var opId = await pocoClient.DisableHttp(clusterDetails.Name, clusterDetails.Location);
            }
            catch (HttpLayerException clientEx)
            {
                Assert.IsTrue(clientEx.Message.Contains("connectivity changes are not supported for this cluster version"));
                Help.DoNothing(clientEx);
            }
            finally
            {
                client.DeleteCluster(clusterDetails.Name);
            }
        }
コード例 #2
0
        public async Task ICannotPerformA_CreateContainersOnUnregisterdSubscription_Using_RestClient()
        {
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();

            // Unregisters location
            var location = "North Europe";

            DeleteClusters(credentials, location);
            var client = ServiceLocator.Instance.Locate <ISubscriptionRegistrationClientFactory>().Create(credentials, GetAbstractionContext(), false);

            if (await client.ValidateSubscriptionLocation(location))
            {
                await client.UnregisterSubscriptionLocation(location);
            }
            Assert.IsFalse(await client.ValidateSubscriptionLocation(location), "Subscription location '{0}' is still registered.", location);

            try
            {
                // Creates the cluster
                var    restClient = ServiceLocator.Instance.Locate <IHDInsightManagementRestClientFactory>().Create(credentials, GetAbstractionContext(), false);
                var    cluster    = GetRandomCluster();
                string payload    = new PayloadConverter().SerializeClusterCreateRequest(cluster);
                await restClient.CreateContainer(cluster.Name, location, payload);

                Assert.Fail("Expected exception.");
            }
            catch (HttpLayerException e)
            {
                Assert.AreEqual(HttpStatusCode.NotFound, e.RequestStatusCode);
                // Error looks like The cloud service with name [namespace] was not found.
                Assert.IsTrue(e.RequestContent.Contains("The cloud service with name"));
                Assert.IsTrue(e.RequestContent.Contains("was not found."));
            }
        }
コード例 #3
0
        [Timeout(30 * 60 * 1000)]  // ms
        public void CreateDeleteContainer_SyncClient_AgainstManualEnvironment()
        {
            // Dissables the simulator
            this.ApplyIndividualTestMockingOnly();

            // Sets the simulator
            var runManager = ServiceLocator.Instance.Locate <IServiceLocationIndividualTestManager>();

            runManager.Override <IConnectionCredentialsFactory>(new AlternativeEnvironmentConnectionCredentialsFactory());

            // Creates the client
            if (IntegrationTestBase.TestCredentials.AlternativeEnvironment == null)
            {
                Assert.Inconclusive("Alternative Azure Endpoint wasn't set up");
            }
            var client = new HDInsightSyncClient(
                IntegrationTestBase.TestCredentials.AlternativeEnvironment.SubscriptionId,
                IntegrationTestBase.GetValidCredentials().Certificate);

            client.PollingInterval = TimeSpan.FromSeconds(1);

            // Runs the test
            TestValidAdvancedCluster(
                client.ListContainers,
                client.ListContainer,
                client.CreateContainer,
                client.DeleteContainer);
        }
コード例 #4
0
        public DynamicPackageData(Version currentAppVersion, IntegrationTestBase integrationTest)
            : base(currentAppVersion, integrationTest, false, false)
        {
            Data = new PackageDataContractRoot();

            MonitorRegister(Data);
        }
コード例 #5
0
        private void DownloadAndInstallMsiProgramPackage(string appName, string packageFileName, [CallerMemberName] string caller = null)
        {
            try
            {
                this.LoginAdminIfNeeded();

                WebDriverWait wait = new WebDriverWait(this.Driver, TimeSpan.FromSeconds(15));

                this.ClickOnManageProgramMenu(appName);

                IWebElement link = wait.Until(ExpectedConditions.ElementIsVisible(By.Id(Strings.Id.DownloadProgramLink)));



                IntegrationTestBase.Log($"Clicking on download URL to store file in {DownloadPath}");

                FileInfo file = this.ActAndWaitForFileDownload(() => link.ClickWrapper(this.Driver), packageFileName, TimeSpan.FromSeconds(80)
                                                               , DownloadPath);

                IntegrationTestBase.Log($"File downloaded {file.FullName}. ");

                this.InstallMsi3AndVerify(file);

                IntegrationTestBase.Log($"Deleting downloaded file {file.FullName}. ");

                file.Delete();
            }
            catch (Exception ex)
            {
                this.HandleError(ex, caller);
            }
        }
コード例 #6
0
 public async Task ICanPerformA_DeleteContainerInvalidLocationInternal_Using_PocoClientAbstraction()
 {
     IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();
     await ServiceLocator.Instance.Locate <IHDInsightManagementPocoClientFactory>()
     .Create(credentials, GetAbstractionContext(), false)
     .DeleteContainer(TestCredentials.WellKnownCluster.DnsName, "Nowhere");
 }
コード例 #7
0
ファイル: RdpTests.cs プロジェクト: mumou/azure-sdk-for-net
        public async Task ICanAddAndDeleteRDPUser()
        {
            IHDInsightSubscriptionCredentials credentials = IntegrationTestBase.GetValidCredentials();
            IHDInsightClient client = HDInsightClient.Connect(credentials);

            ClusterCreateParametersV2 clusterCreationDetails = GetRandomCluster();

            clusterCreationDetails.Version = "1.6";
            ClusterDetails clusterDetails = client.CreateCluster(clusterCreationDetails);

            // add a rdp user - rdp is OFF by default, hence we enable it first
            string userName = "******";
            string password = GetRandomValidPassword();

            client.EnableRdp(clusterDetails.Name, clusterDetails.Location, userName, password, DateTime.UtcNow.AddHours(1));

            ClusterDetails cluster = await client.GetClusterAsync(clusterDetails.Name);

            Assert.AreEqual(userName, cluster.RdpUserName, "Rdp user name has not been updated");

            // now disable the rdp user
            await client.DisableRdpAsync(clusterDetails.Name, clusterDetails.Location);

            cluster = await client.GetClusterAsync(clusterDetails.Name);

            Assert.IsFalse(String.IsNullOrEmpty(cluster.Name), "Cluster user name is empty, maybe cluster was not created.");
            Assert.IsTrue(String.IsNullOrEmpty(cluster.RdpUserName), "Rdp user name has not been cleared");

            // delete the cluster
            if (!string.Equals(clusterDetails.Name, IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName))
            {
                client.DeleteCluster(clusterDetails.Name);
            }
        }
コード例 #8
0
        public async Task ICanHandleA_AuthenticationError_Using_HttpClientAbstraction()
        {
            //         Given I want to use an X509 Cert for authentication
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();

            //           And I have an Http Client
            using (var client = ServiceLocator.Instance.Locate <IHttpClientAbstractionFactory>().Create(credentials.Certificate, false))
            {
                //       And I set the uri to the base of Azure Services
                client.RequestUri = new Uri(credentials.Endpoint, new Uri(Guid.Empty.ToString(), UriKind.Relative));
                client.RequestHeaders.Add("x-ms-version", "2012-08-01");
                client.RequestHeaders.Add("accept", "application/xml");

                //       And I set the method to Get
                client.Method = HttpMethod.Get;

                //      When I call Client.SendAsync
                var responseTask = client.SendAsync();
                var response     = await responseTask;
                //  Then I should receive a response
                Assert.IsNotNull(response);
                Console.WriteLine(response.StatusCode);
                Console.WriteLine(response.Content);

                //   And the response should have been successful.
                Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode);
                //   And the content should contain the error
                Assert.AreNotEqual(string.Empty, response.Content);
            }
        }
コード例 #9
0
        public async Task ICanPerformA_Put_Using_HttpClientAbstraction()
        {
            //         Given I want to use an X509 Cert for authentication
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();

            //           And I have an Http Client
            using (var client = ServiceLocator.Instance.Locate <IHttpClientAbstractionFactory>().Create(credentials.Certificate, false))
            {
                //       And I set the uri for the request object
                client.RequestUri = new Uri("http://httpbin.org/put");
                //       And I set the method to Post
                client.Method = HttpMethod.Put;
                //       And I set the content to "Hello World"
                client.Content = new StringContent("Hello World");

                //      When I call Client.SendAsync
                var responseTask = client.SendAsync();
                var response     = await responseTask;
                //  Then I should receive a response
                Assert.IsNotNull(response);
                Console.WriteLine(response.StatusCode);
                Console.WriteLine(response.Content);
                //   And the response should have been successful.
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
                //   And the content should have a non zero length
                Assert.AreNotEqual(0, response.Content.Length);
                //   And the content should contain "Hello World"
                Assert.IsTrue(response.Content.Contains("\"data\": \"Hello World\""));
            }
        }
コード例 #10
0
        public async Task ICanHandleA_ErrorStatus_Using_HttpClientAbstraction()
        {
            //         Given I want to use an X509 Cert for authentication
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();

            //           And I have an Http Client
            using (var client = ServiceLocator.Instance.Locate <IHttpClientAbstractionFactory>().Create(credentials.Certificate, false))
            {
                //       And I set the uri for a http that will trigger a 404 (NotFound)
                client.RequestUri = new Uri("http://httpbin.org/status/404");
                client.RequestHeaders.Add("x-ms-version", "2012-08-01");
                client.RequestHeaders.Add("accept", "application/xml");

                //      When I call Client.SendAsync
                var responseTask = client.SendAsync();
                var response     = await responseTask;
                //  Then I should receive a response
                Assert.IsNotNull(response);
                Console.WriteLine(response.StatusCode);
                Console.WriteLine(response.Content);
                //   And the response should have been unsuccessful.
                Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
                //   And the content should be empty
                Assert.AreEqual(string.Empty, response.Content);
            }
        }
コード例 #11
0
        public async Task ICannotPerformA_RepeatedUnregistration_Using_SubscriptionRegistrationAbstraction()
        {
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();
            string location = "North Europe";

            DeleteClusters(credentials, location);

            // Need to delete clusters, otherwise unregister will no-op
            var client = ServiceLocator.Instance.Locate <ISubscriptionRegistrationClientFactory>().Create(credentials, GetAbstractionContext(), false);

            try
            {
                await client.UnregisterSubscriptionLocation("North Europe");

                await client.UnregisterSubscriptionLocation("North Europe");

                Assert.Fail("Expected exception.");
            }
            catch (HttpLayerException e)
            {
                Assert.AreEqual(HttpStatusCode.NotFound, e.RequestStatusCode);
                // Error looks like The cloud service with name [namespace] was not found.
                Assert.IsTrue(e.RequestContent.Contains("The cloud service with name"));
                Assert.IsTrue(e.RequestContent.Contains("was not found."));
            }

            Assert.IsFalse(await client.ValidateSubscriptionLocation(location));
        }
コード例 #12
0
        [Timeout(5 * 60 * 1000)] // ms
        public async Task ICanPerformA_BasicCreateDeleteContainersOnUnregisteredLocation_Using_PocoClient()
        {
            // ADD SUBSCRIPTION VALIDATOR
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();

            // Unregisters subscription (just in case)
            var location           = "North Europe";
            var registrationClient = ServiceLocator.Instance.Locate <ISubscriptionRegistrationClientFactory>().Create(credentials, GetAbstractionContext(), false);

            if (await registrationClient.ValidateSubscriptionLocation(location))
            {
                await registrationClient.UnregisterSubscriptionLocation(location);
            }

            var storageAccountsInLocation = from creationDetails in IntegrationTestBase.TestCredentials.Environments
                                            where creationDetails.Location == location
                                            select creationDetails;
            var storageAccount = storageAccountsInLocation.FirstOrDefault();

            Assert.IsNotNull(storageAccount, "could not find any storage accounts in location {0}", location);

            var cluster = GetRandomCluster();

            cluster.Location = location;
            cluster.DefaultStorageAccountName = storageAccount.DefaultStorageAccount.Name;
            cluster.DefaultStorageAccountKey  = storageAccount.DefaultStorageAccount.Key;
            cluster.DefaultStorageContainer   = storageAccount.DefaultStorageAccount.Container;
            await ValidateCreateClusterSucceeds(cluster);
        }
コード例 #13
0
        public async Task GetProviderPropertiesPerformsARetryWhenAnAttemptDoesNotSucced()
        {
            var manager    = ServiceLocator.Instance.Locate <IServiceLocationSimulationManager>().MockingLevel = ServiceLocationMockingLevel.ApplyIndividualTestMockingOnly;
            var individual = ServiceLocator.Instance.Locate <IServiceLocationIndividualTestManager>();

            dynamic xml = DynaXmlBuilder.Create(false, Formatting.None);

            xml.xmlns("http://schemas.microsoft.com/windowsazure")
            .Root
            .b
            .ResourceProviderProperty
            .b
            .Key("Test")
            .Value("Value")
            .d
            .d
            .End();
            var content = xml.ToString();
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();
            var client = ServiceLocator.Instance.Locate <IRdfeServiceRestClientFactory>().Create(credentials, GetAbstractionContext(), false);

            this.AddHttpResponse(new HttpResponseMessageAbstraction(HttpStatusCode.InternalServerError, new HttpResponseHeadersAbstraction(), "Server Problem"));
            this.AddHttpResponse(new HttpResponseMessageAbstraction(HttpStatusCode.OK, new HttpResponseHeadersAbstraction(), content));

            var properties = await client.GetResourceProviderProperties();

            Assert.AreEqual(2, this.attempts);
            Assert.AreEqual(0, this.responses.Count);
            Assert.AreEqual("Test", properties.First().Key);
            Assert.AreEqual("Value", properties.First().Value);
            Assert.AreEqual(1, properties.Count());
        }
コード例 #14
0
        public virtual void WaitForJobWithId()
        {
            var hiveJobDefinition = new HiveJobCreateParameters()
            {
                JobName = "show tables jobDetails",
                Query   = "show tables"
            };

            var cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();

            using (var runspace = this.GetPowerShellRunspace())
            {
                var results = runspace.NewPipeline()
                              .AddCommand(CmdletConstants.NewAzureHDInsightHiveJobDefinition)
                              .WithParameter(CmdletConstants.JobName, hiveJobDefinition.JobName)
                              .WithParameter(CmdletConstants.Query, hiveJobDefinition.Query)
                              .AddCommand(CmdletConstants.StartAzureHDInsightJob)
                              .WithParameter(CmdletConstants.Cluster, cluster.ConnectionUrl)
                              .WithParameter(CmdletConstants.Credential, IntegrationTestBase.GetPSCredential(cluster.HttpUserName, cluster.HttpPassword))
                              .Invoke();
                Assert.AreEqual(1, results.Results.Count);
                var job = results.Results.First().BaseObject as Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.DataObjects.AzureHDInsightJob;

                results = runspace.NewPipeline()
                          .AddCommand(CmdletConstants.WaitAzureHDInsightJob)
                          .WithParameter(CmdletConstants.Credential, IntegrationTestBase.GetPSCredential(cluster.HttpUserName, cluster.HttpPassword))
                          .WithParameter(CmdletConstants.JobId, job.JobId)
                          .WithParameter(CmdletConstants.Cluster, job.Cluster)
                          .Invoke();
                var completedJob = results.Results.ToEnumerable <AzureHDInsightJob>().FirstOrDefault();
                Assert.IsNotNull(completedJob);
                Assert.AreEqual(job.JobId, completedJob.JobId);
                Assert.AreEqual("Completed", completedJob.State);
            }
        }
コード例 #15
0
        private void ValidateSequencePage(IWebElement table, WebDriverWait wait)
        {
            Retrier.RetryAsync(() =>
            {
                table    = wait.Until(ExpectedConditions.ElementIsVisible(By.Id(Strings.Id.ViewUsageTable)));
                var elms = table.FindElements(By.TagName("tr"));
                IntegrationTestBase.Log($"View usage table row count: {elms.Count}");
                Assert.IsTrue(elms.Count > 1, "View usage table does not have at least one row");
            }, TimeSpan.FromMilliseconds(1000), 30).GetAwaiter().GetResult();

            var rows = table.FindElements(By.TagName("tr"));

            if (rows.Count > 1)
            {
                var cells = rows[1].FindElements(By.TagName("td"));

                var link = cells[1].FindElement(By.TagName("a"));

                link.ClickWrapper(this.Driver);

                Retrier.RetryAsync(() =>
                {
                    var sequenceTable = wait.Until(ExpectedConditions.ElementIsVisible(By.Id(Strings.Id.SequenceHistoryTable)));
                    var sequenceRows  = sequenceTable.FindElements(By.TagName("tr"));
                    Assert.IsTrue(sequenceRows.Count > 1, $"Sequence table does not contain sequence elements. [{sequenceTable.Text}]"); //includes header
                }, TimeSpan.FromMilliseconds(1000), 30).GetAwaiter().GetResult();
            }
        }
コード例 #16
0
        protected void LoginIfNeeded(string userName, string password)
        {
            if (!this.IsLoggedIn())
            {
                this.Driver.Navigate().GoToUrl(this.GetAbsoluteUrl("Account/Login"));
            }

            if (this.Driver.Url.IndexOf("Login", StringComparison.InvariantCultureIgnoreCase) != -1 &&

                this.Driver.FindElement(By.Id(Strings.Id.LoginForm)) != null)
            {
                IntegrationTestBase.Log("Trying to log in...");
                IWebElement login = this.Driver.FindElement(By.Id(Strings.Id.Email));

                if (login != null)
                {
                    IWebElement pass = this.Driver.FindElement(By.Id(Strings.Id.Password));
                    login.SendKeys(userName);
                    pass.SendKeys(password);
                    IWebElement submit = this.Driver.FindElement(By.Id(Strings.Id.SubmitLogin));
                    submit.ClickWrapper(this.Driver);
                    this.GoToAdminHomePage();
                    this.RecognizeAdminDashboardPage();
                }
            }
            else
            {
                IntegrationTestBase.Log("Skipping logging in");
            }
        }
コード例 #17
0
        public async Task NegativeTest_InvalidAsvConfig_Using_PocoClientAbstraction()
        {
            var cluster = GetRandomCluster();
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();

            cluster.DefaultStorageAccountKey = "invalid";

            try
            {
                await ServiceLocator.Instance.Locate <IHDInsightManagementPocoClientFactory>().Create(credentials, GetAbstractionContext(), false).CreateContainer(cluster);
            }
            catch (ConfigurationErrorsException e)
            {
                // NEIN: This needs to validate at least one parameter of the exception.
                Console.WriteLine("THIS TEST SUCCEDED because the expected negative result was found");
                Console.WriteLine("ASV Validation failed. Details: {0}", e.ToString());
                return;
            }
            catch (Exception e)
            {
                Assert.Fail("Expected exception 'ConfigurationErrorsException'; found '{0}'. Message:{1}", e.GetType(), e.Message);
            }

            Assert.Fail("ASV Validation should have failed.");
        }
コード例 #18
0
 public async Task ICanPerformA_DeleteNonExistingContainerInternal_Using_PocoClientAbstraction()
 {
     IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();
     await ServiceLocator.Instance.Locate <IHDInsightManagementPocoClientFactory>()
     .Create(credentials, GetAbstractionContext(), false)
     .DeleteContainer(GetRandomClusterName(), "East US");
 }
コード例 #19
0
        public async Task ICanHandleA_ClientTimeout_Using_HttpClientAbstraction()
        {
            try
            {
                //         Given I want to use an X509 Cert for authentication
                IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();
                //           And I have an Http Client
                using (var client = ServiceLocator.Instance.Locate <IHttpClientAbstractionFactory>().Create(credentials.Certificate, false))
                {
                    //       And I set the uri for a http that will take 30 sec to complete
                    client.RequestUri = new Uri("http://httpbin.org/delay/30000");
                    client.RequestHeaders.Add("x-ms-version", "2012-08-01");
                    client.RequestHeaders.Add("accept", "application/xml");

                    //       And I set the client timeout to a value << 30 sec
                    client.Timeout = TimeSpan.FromMilliseconds(1);

                    //      The call Client.SendAsync to trigger exception
                    var responseTask = client.SendAsync();
                    var response     = await responseTask;
                    Console.WriteLine(response.Content);
                    Console.WriteLine(response.ToString());
                    Console.WriteLine(response.StatusCode);
                }
            }
            catch (TimeoutException ex)
            {
                Assert.IsTrue(ex.Message.Contains("operation timed out"));
            }
        }
コード例 #20
0
        private async Task ValidateCreateClusterSucceeds(ClusterCreateParametersV2 cluster, Action <ClusterDetails> postCreateValidation)
        {
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();

            using (var client = ServiceLocator.Instance.Locate <IHDInsightManagementPocoClientFactory>().Create(credentials, GetAbstractionContext(), false))
            {
                client.CreateContainer(cluster).Wait();
                await client.WaitForClusterInConditionOrError(null, cluster.Name, cluster.Location, TimeSpan.FromMinutes(30), HDInsightClient.DefaultPollingInterval, GetAbstractionContext(), this.CreatingStates);

                var task = client.ListContainer(cluster.Name);
                task.WaitForResult();
                var container = task.Result;
                Assert.IsNotNull(container);
                if (container.Error.IsNotNull())
                {
                    Assert.Fail("The Container was not expected to return an error but returned ({0}) ({1})", container.Error.HttpCode, container.Error.Message);
                }

                if (postCreateValidation != null)
                {
                    postCreateValidation(container);
                }

                await client.DeleteContainer(cluster.Name);

                await client.WaitForClusterNullOrError(cluster.Name, cluster.Location, TimeSpan.FromMinutes(10), IntegrationTestBase.GetAbstractionContext().CancellationToken);

                Assert.IsNull(container.Error);
                Assert.IsNull(client.ListContainer(cluster.Name).WaitForResult());
            }
        }
コード例 #21
0
        protected IWebElement TryFindAppMenu(string appName)
        {
            WebDriverWait wait    = new WebDriverWait(this.Driver, TimeSpan.FromSeconds(15));
            IWebElement   element = this.Driver.TryFind(By.Id($"{appName}_menu"));

            if (element == null || !element.Displayed)
            {
                var devTeamElement = this.Driver.TryFind(By.Id($"{Strings.Id.AppsList}_TelimenaSystemDevTeam"));
                wait.Until(ExpectedConditions.ElementToBeClickable(devTeamElement));
                devTeamElement.ClickWrapper(this.Driver);
                IntegrationTestBase.Log($"{appName}_menu was not visible. Clicked on team node to expand.");
            }

            element = this.Driver.TryFind(By.Id($"{appName}_menu"));
            if (element != null)
            {
                IntegrationTestBase.Log($"Found {appName}_menu button");
            }
            else
            {
                IntegrationTestBase.Log($"Did not find {appName}_menu button");
            }

            return(element);
        }
コード例 #22
0
        protected void ClickOnProgramMenuButton(string appName, string buttonSuffix)
        {
            try
            {
                Retrier.RetryAsync(() =>
                {
                    WebDriverWait wait  = new WebDriverWait(this.Driver, TimeSpan.FromSeconds(15));
                    IWebElement element = this.Driver.TryFind(By.Id($"{appName}_menu"));

                    IntegrationTestBase.Log($"Found { appName}_menu button");

                    var prgMenu = wait.Until(ExpectedConditions.ElementToBeClickable(element));
                    prgMenu.ClickWrapper(this.Driver);
                    IntegrationTestBase.Log($"Clicked { appName}_menu button");


                    IWebElement link = this.Driver.TryFind(By.Id(appName + buttonSuffix));
                    IntegrationTestBase.Log($"Found { appName}{buttonSuffix} button");

                    link = wait.Until(ExpectedConditions.ElementToBeClickable(link));

                    link.ClickWrapper(this.Driver);
                }, TimeSpan.FromMilliseconds(500), 3).GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException($"Failed to click on button {buttonSuffix} for app {appName}.", ex);
            }
        }
コード例 #23
0
        public void UserSuppliedVersionTooHigh()
        {
            var userVersion = new Version(HDInsightSDKSupportedVersions.MaxVersion.Major, HDInsightSDKSupportedVersions.MaxVersion.Minor + 1, 0, 0);
            var client      = new VersionFinderClient(IntegrationTestBase.GetValidCredentials(), GetAbstractionContext(), false);

            Assert.AreEqual(client.GetVersionStatus(userVersion), VersionStatus.ToolsUpgradeRequired);
        }
コード例 #24
0
        public void UserSuppliedVersionValid_LowLimit()
        {
            var userVersion = new Version(HDInsightSDKSupportedVersions.MinVersion.Major, HDInsightSDKSupportedVersions.MinVersion.Minor, 0, 0);
            var client      = new VersionFinderClient(IntegrationTestBase.GetValidCredentials(), GetAbstractionContext(), false);

            Assert.AreEqual(client.GetVersionStatus(userVersion), VersionStatus.Compatible);
        }
コード例 #25
0
        public async Task NegativeTest_InvalidAsv_Using_PocoClient()
        {
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();
            var cluster = GetRandomCluster();

            cluster.AdditionalStorageAccounts.Add(new WabStorageAccountConfiguration(IntegrationTestBase.TestCredentials.Environments[0].AdditionalStorageAccounts[0].Name, IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Key));
            await ServiceLocator.Instance.Locate <IHDInsightManagementPocoClientFactory>().Create(credentials, GetAbstractionContext(), false).CreateContainer(cluster);
        }
コード例 #26
0
        public async Task ICanPerformA_ListCloudServices_Using_RestClientAbstraction()
        {
            IHDInsightSubscriptionCredentials credentials = IntegrationTestBase.GetValidCredentials();
            var client = ServiceLocator.Instance.Locate <IHDInsightManagementRestClientFactory>().Create(credentials, GetAbstractionContext(), false);
            var result = await client.ListCloudServices();

            Assert.IsTrue(this.ContainsContainer(TestCredentials.WellKnownCluster.DnsName, result.Content));
        }
コード例 #27
0
 public DynamicPackage(
     Version currentAppVersion,
     IntegrationTestBase integrationTest,
     bool preserveUpgrade,
     bool useLockFile)
     : base(currentAppVersion, integrationTest, preserveUpgrade, useLockFile)
 {
 }
コード例 #28
0
        public static void SaveDiagramToDisk(this IntegrationTestBase test, DiagramFile file)
        {
            var blob     = file.Content;
            var path     = Path.GetDirectoryName(test.GetType().Assembly.CodeBase).Replace("file:\\", "");
            var filePath = path + "\\" + file.FileName;

            File.WriteAllBytes(filePath, blob);
        }
コード例 #29
0
        public async Task ICanPerformA_PositiveSubscriptionValidation_Using_SubscriptionRegistrationAbstraction()
        {
            IHDInsightCertificateCredential credentials = IntegrationTestBase.GetValidCredentials();
            var client = ServiceLocator.Instance.Locate <ISubscriptionRegistrationClientFactory>().Create(credentials, GetAbstractionContext(), false);

            Assert.IsTrue(await client.ValidateSubscriptionLocation("East US 2"));
            Assert.IsFalse(await client.ValidateSubscriptionLocation("No Where"));
        }
コード例 #30
0
        /// <summary>
        /// Start a download and wait for a file to appear
        /// https://stackoverflow.com/a/46440261/1141876
        /// </summary>
        /// <param name="expectedName">If we don't know the extension, Chrome creates a temp file in download folder and we think we have the file already</param>
        protected FileInfo ActAndWaitForFileDownload(
            Action action
            , string expectedName
            , TimeSpan maximumWaitTime
            , string downloadDirectory)
        {
            var expectedPath = Path.Combine(downloadDirectory, expectedName);

            try
            {
                File.Delete(expectedPath);
            }
            catch (Exception ex)
            {
                IntegrationTestBase.Log($"Could not delete file {expectedPath }, error: {ex}");
            }
            var stopwatch = Stopwatch.StartNew();

            Assert.IsFalse(File.Exists(expectedPath));
            action();
            IntegrationTestBase.Log($"Action executed");

            var         isTimedOut             = false;
            string      filePath               = null;
            Func <bool> fileAppearedOrTimedOut = () =>
            {
                isTimedOut = stopwatch.Elapsed > maximumWaitTime;
                filePath   = Directory.GetFiles(downloadDirectory)
                             .FirstOrDefault(x => Path.GetFileName(x) == expectedName);
                if (filePath != null)
                {
                    IntegrationTestBase.Log($"File stored at {filePath}");
                }
                else
                {
                    IntegrationTestBase.Log($"File not ready yet. Elapsed: {stopwatch.Elapsed}");
                }

                return(filePath != null || isTimedOut);
            };

            do
            {
                Thread.Sleep(500);
            }while (!fileAppearedOrTimedOut());

            if (!String.IsNullOrEmpty(filePath))
            {
                Assert.AreEqual(expectedPath, filePath);
                return(new FileInfo(filePath));
            }
            if (isTimedOut)
            {
                Assert.Fail("Failed to download");
            }

            return(null);
        }