Exemple #1
0
        public static void SetHelixLogUri(this ModelTestResult modelTestResult, HelixLogKind kind, string uri)
        {
            modelTestResult.IsHelixTestResult = true;
            switch (kind)
            {
            case HelixLogKind.Console:
                modelTestResult.HelixConsoleUri = uri;
                break;

            case HelixLogKind.CoreDump:
                modelTestResult.HelixCoreDumpUri = uri;
                break;

            case HelixLogKind.RunClient:
                modelTestResult.HelixRunClientUri = uri;
                break;

            case HelixLogKind.TestResults:
                modelTestResult.HelixTestResultsUri = uri;
                break;

            default:
                throw new Exception($"Invalid kind '{kind}'");
            }
        }
Exemple #2
0
        public static HelixLogInfo?GetHelixLogInfo(this ModelTestResult modelTestResult)
        {
            if (!modelTestResult.IsHelixTestResult)
            {
                return(null);
            }

            return(new HelixLogInfo(
                       runClientUri: modelTestResult.HelixRunClientUri,
                       consoleUri: modelTestResult.HelixConsoleUri,
                       coreDumpUri: modelTestResult.HelixCoreDumpUri,
                       testResultsUri: modelTestResult.HelixTestResultsUri));
        }
Exemple #3
0
        public async Task <ModelTestRun> EnsureTestRunAsync(ModelBuild modelBuild, int attempt, DotNetTestRun testRun, Dictionary <HelixInfo, HelixLogInfo> helixMap)
        {
            var modelTestRun = await FindModelTestRunAsync(modelBuild.GetBuildKey(), testRun.TestRun.Id).ConfigureAwait(false);

            if (modelTestRun is object)
            {
                return(modelTestRun);
            }

            var buildInfo = testRun.Build.GetBuildResultInfo();

            modelTestRun = new ModelTestRun()
            {
                AzureOrganization = buildInfo.Organization,
                AzureProject      = buildInfo.Project,
                ModelBuild        = modelBuild,
                TestRunId         = testRun.TestRun.Id,
                Name    = testRun.TestRun.Name,
                Attempt = attempt,
            };
            Context.ModelTestRuns.Add(modelTestRun);

            foreach (var dotnetTestCaseResult in testRun.TestCaseResults)
            {
                var testCaseResult = dotnetTestCaseResult.TestCaseResult;
                var testResult     = new ModelTestResult()
                {
                    TestFullName         = testCaseResult.TestCaseTitle,
                    Outcome              = testCaseResult.Outcome,
                    ModelTestRun         = modelTestRun,
                    ModelBuild           = modelBuild,
                    ErrorMessage         = testCaseResult.ErrorMessage,
                    IsSubResultContainer = testCaseResult.SubResults?.Length > 0,
                    IsSubResult          = false,
                };

                AddHelixInfo(testResult);
                Context.ModelTestResults.Add(testResult);

                if (testCaseResult.SubResults is { } subResults)
                {
                    foreach (var subResult in subResults)
                    {
                        var iterationTestResult = new ModelTestResult()
                        {
                            TestFullName         = testCaseResult.TestCaseTitle,
                            Outcome              = subResult.Outcome,
                            ModelTestRun         = modelTestRun,
                            ModelBuild           = modelBuild,
                            ErrorMessage         = subResult.ErrorMessage,
                            IsSubResultContainer = false,
                            IsSubResult          = true
                        };

                        AddHelixInfo(iterationTestResult);
                        Context.ModelTestResults.Add(iterationTestResult);
                    }
                }

                void AddHelixInfo(ModelTestResult testResult)
                {
                    if (dotnetTestCaseResult.HelixInfo is { } helixInfo&&
                        helixMap.TryGetValue(helixInfo, out var helixLogInfo))
                    {
                        testResult.IsHelixTestResult   = true;
                        testResult.HelixConsoleUri     = helixLogInfo.ConsoleUri;
                        testResult.HelixCoreDumpUri    = helixLogInfo.CoreDumpUri;
                        testResult.HelixRunClientUri   = helixLogInfo.RunClientUri;
                        testResult.HelixTestResultsUri = helixLogInfo.TestResultsUri;
                    }
                }
            }

            await Context.SaveChangesAsync().ConfigureAwait(false);

            return(modelTestRun);
        }