示例#1
0
 public void _11_UploadInstallerMsi3TestAppUpdate()
 {
     try
     {
         Assert.AreEqual(Apps.ProductCodes.InstallersTestAppMsi3V2
                         , this.GetCodeFromMsi(Apps.PackageNames.InstallersTestAppMsi3V2));
         this.UploadUpdatePackage(Apps.Names.InstallersTestAppMsi3, Apps.PackageNames.InstallersTestAppMsi3V2);
         this.SetPackageAsNonBeta(Apps.PackageNames.InstallersTestAppMsi3V2);
     }
     catch (Exception ex)
     {
         this.HandleError(ex, SharedTestHelpers.GetMethodName());
     }
 }
示例#2
0
            public TestDatabase(ITestOutputHelper output)
            {
                string databaseName = $"TestDB_{DateTime.UtcNow:yyyyMMddhhmmssfffffff}";

                this.server = new Server(new ServerConnection(new SqlConnection(SharedTestHelpers.GetDefaultConnectionString())));
                this.testDb = new Database(this.server, databaseName)
                {
                    Collation = "Latin1_General_100_BIN2_UTF8",
                };

                this.ConnectionString =
                    new SqlConnectionStringBuilder(this.server.ConnectionContext.ConnectionString)
                {
                    InitialCatalog = this.testDb.Name,
                }
                .ConnectionString;

                this.output = output;
            }
示例#3
0
        public void _10_DownloadInstallerTestAppMsi3Package()
        {
            try
            {
                this.UninstallPackages(Apps.ProductCodes.InstallersTestAppMsi3V1
                                       , Apps.ProductCodes.InstallersTestAppMsi3V2);

                IntegrationTestBase.Log("Proceeding to download");

                this.DownloadAndInstallMsiProgramPackage(Apps.Keys.InstallersTestAppMsi3
                                                         , Apps.PackageNames.InstallersTestAppMsi3V1);

                IntegrationTestBase.Log("Uninstalling packages after test");
                this.UninstallPackages(Apps.ProductCodes.InstallersTestAppMsi3V1
                                       , Apps.ProductCodes.InstallersTestAppMsi3V2);
            }
            catch (Exception ex)
            {
                this.HandleError(ex, SharedTestHelpers.GetMethodName());
            }
        }
示例#4
0
        public async Task _02_HandleUpdates_NonBeta()
        {
            try
            {
                VersionTuple initialVersions = await this.GetVersionsFromApp(Apps.PackageNames.AutomaticTestsClientAppV1, SharedTestHelpers.GetMethodName()).ConfigureAwait(false);

                this.LaunchTestsAppNewInstanceAndGetResult <UpdateCheckResult>(out FileInfo appFile, Actions.HandleUpdates, Apps.Keys.AutomaticTestsClient, Apps.PackageNames.AutomaticTestsClientAppV1
                                                                               , SharedTestHelpers.GetMethodName(), waitForExit: false);
                Window updateNowMsgBox =
                    await WindowHelpers.WaitForWindowAsync(x => x.Equals("AutomaticTestsClient update installation"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                updateNowMsgBox.Get <Button>(SearchCriteria.ByText("Yes")).Click();

                Window updater = await WindowHelpers.WaitForWindowAsync(x => x.Contains("AutomaticTestsClient Updater"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                updater.Get <Button>(SearchCriteria.ByText("Install now!")).Click();

                Window doneMsg = await WindowHelpers.WaitForMessageBoxAsync(updater, "Update complete", TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                doneMsg.Get <Button>(SearchCriteria.ByText("Yes")).Click();

                Window appWarning = await WindowHelpers.WaitForWindowAsync(x => x.Equals("AutomaticTestsClient - This app requires arguments to run")
                                                                           , TimeSpan.FromMinutes(2)).ConfigureAwait(false);

                VersionTuple newVersions = await this.GetVersionFromMsgBox(appWarning).ConfigureAwait(false);

                await this.AssertVersionAreCorrect(newVersions, initialVersions, appFile, "2.").ConfigureAwait(false);


                //now just assert that the update check result is empty next time
                UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: true);

                this.AssertNoNonBetaUpdatesToInstall(result, true);
            }
            catch (Exception ex)
            {
                throw this.CleanupAndRethrow(ex);
            }
        }
示例#5
0
        public void _12_SetUpdaterForMsiInstallerApp()
        {
            try
            {
                var app            = Apps.Keys.InstallersTestAppMsi3;
                var currentUpdater = this.GetUpdaterForApp(app);

                if (currentUpdater == DefaultToolkitNames.PackageTriggerUpdaterInternalName)
                {
                    //ok
                }
                else
                {
                    this.SetUpdaterForApp(app, DefaultToolkitNames.PackageTriggerUpdaterInternalName);
                    Assert.AreEqual(DefaultToolkitNames.PackageTriggerUpdaterInternalName, this.GetUpdaterForApp(app));
                }
            }
            catch (Exception ex)
            {
                this.HandleError(ex, SharedTestHelpers.GetMethodName());
            }
        }
示例#6
0
        public async Task Test_AppUsageTable()
        {
            string   viewName = nameof(this.Test_AppUsageTable);
            FileInfo app      = this.LaunchTestsAppNewInstanceAndGetResult(out _, out TelemetryItem first, Actions.ReportViewUsage, Apps.Keys.AutomaticTestsClient, Apps.PackageNames.AutomaticTestsClientAppV1, nameof(this.Test_AppUsageTable)
                                                                           , viewName: viewName);

            Task.Delay(1000).GetAwaiter().GetResult();
            DateTime previous = await this.GetLatestUsageFromTable(SharedTestHelpers.GetMethodName()).ConfigureAwait(false);

            Task.Delay(1500).GetAwaiter().GetResult();

            var second = this.LaunchTestsAppAndGetResult <TelemetryItem>(app, Actions.ReportViewUsage, Apps.Keys.AutomaticTestsClient, viewName: viewName);

            DateTime current = await this.GetLatestUsageFromTable(SharedTestHelpers.GetMethodName()).ConfigureAwait(false);

            if (current == previous)
            {
                await Task.Delay(2000);
            }
            current = await this.GetLatestUsageFromTable(SharedTestHelpers.GetMethodName()).ConfigureAwait(false);

            Assert.IsTrue(current > previous, $"current {current} is not larger than previous {previous}");
        }
示例#7
0
        public static FileInfo ExtractApp(string fileName, string testSubfolderName, Action <string> log)
        {
            var compressedFile = GetFile(fileName);
            var targetDir      = new DirectoryInfo(Path.Combine(compressedFile.DirectoryName, testSubfolderName, compressedFile.Name + "_Extracted"));

            log($"Extracting file {compressedFile} to {targetDir.FullName}");

            try
            {
                SharedTestHelpers.DeleteDirectory(targetDir.FullName);
            }
            catch (UnauthorizedAccessException)
            {
                KillTestApps();

                SharedTestHelpers.DeleteDirectory(targetDir.FullName);
            }
            targetDir.Create();

            ZipFile.ExtractToDirectory(compressedFile.FullName, targetDir.FullName);
            log($"FINISHED Extracting file {compressedFile} to {targetDir.FullName}");

            return(targetDir.GetFiles().FirstOrDefault(x => x.Name.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)));
        }
示例#8
0
        public async Task _05_CheckAndInstallUpdates_Beta()
        {
            try
            {
                VersionTuple initialVersions = this.GetVersionsFromExtractedAppFile(Apps.PackageNames.AutomaticTestsClientAppV1, SharedTestHelpers.GetMethodName(), out FileInfo appFile);

                this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.HandleUpdatesWithBeta, Apps.Keys.AutomaticTestsClient, waitForExit: false);

                Window updateNowMsgBox =
                    await WindowHelpers.WaitForWindowAsync(x => x.Equals("AutomaticTestsClient update installation"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                updateNowMsgBox.Get <Button>(SearchCriteria.ByText("Yes")).Click();
                Log("Clicked yes");

                Window updater = await WindowHelpers.WaitForWindowAsync(x => x.Contains("AutomaticTestsClient Updater"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                updater.Get <Button>(SearchCriteria.ByText("Install now!")).Click();
                Log("Clicked Install now!");

                Window doneMsg = await WindowHelpers.WaitForMessageBoxAsync(updater, "Update complete", TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                doneMsg.Get <Button>(SearchCriteria.ByText("No")).Click();
                Log("Clicked no");

                VersionTuple newVersions = this.GetVersionsFromFile(appFile);

                this.AssertVersionAreCorrect(newVersions, initialVersions, appFile, "3.");

                //now just assert that the update check result is empty next time
                Log("Checking update info is false");
                UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: true);

                this.AssertNoNonBetaUpdatesToInstall(result, false);
            }
            catch (Exception ex)
            {
                throw this.CleanupAndRethrow(ex);
            }
        }
示例#9
0
        public async Task _03_CheckAndInstallUpdates_NonBeta()
        {
            try
            {
                VersionTuple initialVersions    = this.GetVersionsFromExtractedAppFile(Apps.PackageNames.AutomaticTestsClientAppV1, SharedTestHelpers.GetMethodName(), out FileInfo appFile);
                var          installationResult = this.LaunchTestsAppAndGetResult <UpdateInstallationResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: false);

                if (installationResult?.Exception != null)
                {
                    throw installationResult.Exception;
                }

                Window updater = await WindowHelpers.WaitForWindowAsync(x => x.Contains("AutomaticTestsClient Updater"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                this.CheckProperUpdateVersionDownloadedInUpdater(updater, "2.");


                updater.Get <Button>(SearchCriteria.ByText("Install now!")).Click();
                Log("Clicked Install now!");

                Window doneMsg = await WindowHelpers.WaitForMessageBoxAsync(updater, "Update complete", TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                doneMsg.Get <Button>(SearchCriteria.ByText("Yes")).Click();
                Log("Clicked yes");

                Window appWarning = await WindowHelpers.WaitForWindowAsync(x => x.Equals("AutomaticTestsClient - This app requires arguments to run")
                                                                           , TimeSpan.FromMinutes(2)).ConfigureAwait(false);

                VersionTuple newVersions = await this.GetVersionFromMsgBox(appWarning).ConfigureAwait(false);

                Log("Reading versions");

                this.AssertVersionAreCorrect(newVersions, initialVersions, appFile, "2.");

                //now just assert that the update check result is empty next time
                Log("Checking update info is false");

                UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: true);
                this.AssertNoNonBetaUpdatesToInstall(result, true);
            }
            catch (Exception ex)
            {
                throw this.CleanupAndRethrow(ex);
            }
        }
        public async Task _05_CheckAndInstallUpdates_Beta()
        {
            try
            {
                VersionTuple initialVersions = this.GetVersionsFromExtractedAppFile(Apps.PackageNames.AutomaticTestsClientAppV1, SharedTestHelpers.GetMethodName(), out FileInfo appFile);

                this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.HandleUpdatesWithBeta, Apps.Keys.AutomaticTestsClient, waitForExit: false);

                await this.PerformManualUpdate("AutomaticTestsClient", "3.");

                VersionTuple newVersions = this.GetVersionsFromFile(appFile);
                Log($"New versions: {newVersions.ToLog()}");

                this.AssertVersionAreCorrect(newVersions, initialVersions, appFile, "3.");

                //now just assert that the update check result is empty next time
                Log("Checking update info is false");
                UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: true);

                this.AssertNoNonBetaUpdatesToInstall(result, false);
            }
            catch (Exception ex)
            {
                this.CleanupAndLog(ex);
                throw;
            }
        }
示例#11
0
        public void TestAppWithEmbeddedTeli()
        {
            this.outputs.Clear();
            this.errors.Clear();

            this.LaunchTestsAppNewInstance(out _, Actions.ReportViewUsage, Apps.Keys.AutomaticTestsClient,
                                           Apps.PackageNames.EmbeddedAssemblyTestApp, SharedTestHelpers.GetMethodName());

            Assert.IsTrue(this.outputs.Any(x => x == "Ended with no errors"));
            this.outputs.Clear();
            this.errors.Clear();
        }
示例#12
0
        public async Task MultiInstanceQueries()
        {
            DateTime startTime = DateTime.UtcNow;
            string   prefix    = $"{startTime:HHmmss}";

            await Enumerable.Range(0, 5).ParallelForEachAsync(5, i =>
                                                              this.RunOrchestrationAsync(
                                                                  nameof(Functions.Sequence),
                                                                  instanceId: $"{prefix}.sequence.{i}"));

            // Extra delay to account for test flakiness in the GitHub CI (TODO: Why is this necessary?)
            await Task.Delay(TimeSpan.FromSeconds(1));

            DateTime sequencesFinishedTime = SharedTestHelpers.GetCurrentDatabaseTimeUtc();

            await Enumerable.Range(0, 5).ParallelForEachAsync(5, i =>
                                                              this.StartOrchestrationAsync(
                                                                  nameof(Functions.WaitForEvent),
                                                                  input: i.ToString(),
                                                                  instanceId: $"{prefix}.waiter.{i}"));

            IDurableClient client = await this.GetDurableClientAsync();

            // Create one condition object and reuse it for multiple queries
            var condition = new OrchestrationStatusQueryCondition();
            OrchestrationStatusQueryResult result;

            // Return all instances
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Equal(10, result.DurableOrchestrationState.Count());

            // Test CreatedTimeTo filter
            condition.CreatedTimeTo = startTime;
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Empty(result.DurableOrchestrationState);

            condition.CreatedTimeTo = sequencesFinishedTime;
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Equal(5, result.DurableOrchestrationState.Count());

            condition.CreatedTimeTo = DateTime.UtcNow;
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Equal(10, result.DurableOrchestrationState.Count());

            // Test CreatedTimeFrom filter
            condition.CreatedTimeFrom = DateTime.UtcNow;
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Empty(result.DurableOrchestrationState);

            condition.CreatedTimeFrom = sequencesFinishedTime;
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Equal(5, result.DurableOrchestrationState.Count());

            condition.CreatedTimeFrom = startTime;
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Equal(10, result.DurableOrchestrationState.Count());

            // Test RuntimeStatus filter
            var statusFilters = new HashSet <OrchestrationRuntimeStatus>(new[]
            {
                OrchestrationRuntimeStatus.Failed,
                OrchestrationRuntimeStatus.Pending,
                OrchestrationRuntimeStatus.Terminated
            });

            condition.RuntimeStatus = statusFilters;
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Empty(result.DurableOrchestrationState);

            statusFilters.Add(OrchestrationRuntimeStatus.Running);
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Equal(5, result.DurableOrchestrationState.Count());
            Assert.All(result.DurableOrchestrationState, state => Assert.Equal(OrchestrationRuntimeStatus.Running, state.RuntimeStatus));

            statusFilters.Add(OrchestrationRuntimeStatus.Completed);
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Equal(10, result.DurableOrchestrationState.Count());

            statusFilters.Remove(OrchestrationRuntimeStatus.Running);
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Equal(5, result.DurableOrchestrationState.Count());
            Assert.All(result.DurableOrchestrationState, state => Assert.Equal(OrchestrationRuntimeStatus.Completed, state.RuntimeStatus));

            statusFilters.Clear();
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Equal(10, result.DurableOrchestrationState.Count());

            // Test InstanceIdPrefix
            condition.InstanceIdPrefix = "Foo";
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Empty(result.DurableOrchestrationState);

            condition.InstanceIdPrefix = prefix;
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.Equal(10, result.DurableOrchestrationState.Count());

            // Test PageSize and ContinuationToken
            var instanceIds = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            condition.PageSize = 0;
            while (condition.PageSize++ < 10)
            {
                result = await client.ListInstancesAsync(condition, CancellationToken.None);

                int total = result.DurableOrchestrationState.Count();
                Assert.Equal(condition.PageSize, total);

                // Make sure all instance IDs are unique
                Assert.All(result.DurableOrchestrationState, s => instanceIds.Add(s.InstanceId));

                while (total < 10)
                {
                    condition.ContinuationToken = result.ContinuationToken;
                    result = await client.ListInstancesAsync(condition, CancellationToken.None);

                    int count = result.DurableOrchestrationState.Count();
                    Assert.NotEqual(0, count);
                    Assert.True(count <= condition.PageSize);
                    total += count;
                    Assert.True(total <= 10);
                    Assert.All(result.DurableOrchestrationState, s => instanceIds.Add(s.InstanceId));
                }

                condition.ContinuationToken = null;
            }

            // Test ShowInput
            condition.ShowInput       = true;
            condition.CreatedTimeFrom = sequencesFinishedTime;
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.All(result.DurableOrchestrationState, state => Assert.NotEqual(JValue.CreateNull(), state.Input));

            condition.ShowInput       = false;
            condition.CreatedTimeFrom = startTime;
            result = await client.ListInstancesAsync(condition, CancellationToken.None);

            Assert.All(result.DurableOrchestrationState, state => Assert.Equal(JValue.CreateNull(), state.Input));
        }