Ejemplo n.º 1
0
 public ResultService(PowerLinesContext context, IResultReader resultReader, IRatingService ratingService, IBulkInsert <Result> bulkInsert)
 {
     db = context;
     this.resultReader  = resultReader;
     this.ratingService = ratingService;
     this.bulkInsert    = bulkInsert;
 }
Ejemplo n.º 2
0
 public TOutput Map(IResultReader reader)
 {
     if (reader.Read())
     {
         return(_mappingFunction.Invoke(reader));
     }
     return(default(TOutput));
 }
Ejemplo n.º 3
0
 public SingleDeferableSelect(IEntitySelectQueryBuilder <TEntity> queryBuilder, IDataProvider dataProvider,
                              IResultReader <TResult> resultReader)
 {
     _queryBuilder      = queryBuilder;
     _nonGenericBuilder = queryBuilder;
     _resultReader      = resultReader;
     _dataProvider      = dataProvider;
 }
Ejemplo n.º 4
0
        public TOutput Map(IResultReader reader)
        {
            if (reader.Read())
            {
                return(MapItem(reader));
            }

            return(default(TOutput));
        }
        private void ProcessPublishTestResultsCommand(IExecutionContext context, Dictionary <string, string> eventProperties, string data)
        {
            ArgUtil.NotNull(context, nameof(context));
            _executionContext = context;

            LoadPublishTestResultsInputs(context, eventProperties, data);

            string teamProject = context.Variables.System_TeamProject;
            string owner       = context.Variables.Build_RequestedFor;
            string buildUri    = context.Variables.Build_BuildUri;
            int    buildId     = context.Variables.Build_BuildId ?? 0;

            //Temporary fix to support publish in RM scenarios where there might not be a valid Build ID associated.
            //TODO: Make a cleaner fix after TCM User Story 401703 is completed.
            if (buildId == 0)
            {
                _platform = _configuration = null;
            }

            string releaseUri            = null;
            string releaseEnvironmentUri = null;

            // Check to identify if we are in the Release management flow; if not, then release fields will be kept null while publishing to TCM
            if (!string.IsNullOrWhiteSpace(context.Variables.Release_ReleaseUri))
            {
                releaseUri            = context.Variables.Release_ReleaseUri;
                releaseEnvironmentUri = context.Variables.Release_ReleaseEnvironmentUri;
            }

            IResultReader  resultReader = GetTestResultReader(_testRunner);
            TestRunContext runContext   = new TestRunContext(owner, _platform, _configuration, buildId, buildUri, releaseUri, releaseEnvironmentUri);
            VssConnection  connection   = WorkerUtilities.GetVssConnection(_executionContext);

            var publisher = HostContext.GetService <ITestRunPublisher>();

            publisher.InitializePublisher(context, connection, teamProject, resultReader);

            var commandContext = HostContext.CreateService <IAsyncCommandContext>();

            commandContext.InitializeCommandContext(context, StringUtil.Loc("PublishTestResults"));

            if (_mergeResults)
            {
                commandContext.Task = PublishAllTestResultsToSingleTestRunAsync(_testResultFiles, publisher, buildId, runContext, resultReader.Name, context.CancellationToken);
            }
            else
            {
                commandContext.Task = PublishToNewTestRunPerTestResultFileAsync(_testResultFiles, publisher, runContext, resultReader.Name, PublishBatchSize, context.CancellationToken);
            }
            _executionContext.AsyncCommands.Add(commandContext);

            if (_isTestRunOutcomeFailed)
            {
                _executionContext.Result = TaskResult.Failed;
                _executionContext.Error(StringUtil.Loc("FailedTestsInResults"));
            }
        }
Ejemplo n.º 6
0
        public IList <TOutput> MapToList(IResultReader reader)
        {
            IList <TOutput> list = new List <TOutput>();

            while (reader.Read())
            {
                list.Add(_mappingFunction(reader));
            }
            return(list);
        }
 public void InitializePublisher(IExecutionContext context, string projectName, VssConnection connection, string testRunner, bool publishRunLevelAttachments)
 {
     Trace.Entering();
     _executionContext = context;
     _projectName      = projectName;
     _resultReader     = GetTestResultReader(testRunner, publishRunLevelAttachments);
     _testRunPublisher = HostContext.GetService <ITestRunPublisher>();
     _testRunPublisher.InitializePublisher(_executionContext, connection, projectName, _resultReader);
     Trace.Leaving();
 }
Ejemplo n.º 8
0
 public void InitializePublisher(IExecutionContext executionContext, VssConnection connection, string projectName, IResultReader resultReader)
 {
     Trace.Entering();
     _executionContext = executionContext;
     _projectName = projectName;
     _resultReader = resultReader;
     connection.InnerHandler.Settings.SendTimeout = TimeSpan.FromSeconds(PUBLISH_TIMEOUT);
     _testResultsServer = HostContext.GetService<ITestResultsServer>();
     _testResultsServer.InitializeServer(connection);
     Trace.Leaving();
 }
Ejemplo n.º 9
0
        public IList <TOutput> MapToList(IResultReader reader)
        {
            List <TOutput> list = new List <TOutput>();

            while (reader.Read())
            {
                list.Add(MapItem(reader));
            }

            return(list);
        }
 public void InitializePublisher(IExecutionContext executionContext, VssConnection connection, string projectName, IResultReader resultReader)
 {
     Trace.Entering();
     _executionContext = executionContext;
     _projectName      = projectName;
     _resultReader     = resultReader;
     connection.InnerHandler.Settings.SendTimeout = TimeSpan.FromSeconds(PUBLISH_TIMEOUT);
     _testResultsServer = HostContext.GetService <ITestResultsServer>();
     _testResultsServer.InitializeServer(connection);
     Trace.Leaving();
 }
 public static SingleDeferableSelect <TEntity, TView> CreateSingleResultQuery <TEntity, TView>(
     this IEntitySelectQueryBuilder <TEntity> queryBuilder,
     IResultReader <TView> resultReader,
     IDataProvider dataProvider
     )
     where TEntity : class
 {
     return(new SingleDeferableSelect <TEntity, TView>(
                queryBuilder, dataProvider, resultReader
                ));
 }
Ejemplo n.º 12
0
        private TOutput MapItem(IResultReader reader)
        {
            TOutput output = Activator.CreateInstance <TOutput>();

            foreach (MappingItem <TOutput> mappingItem in _mappings)
            {
                Expression <Func <TOutput, object> > expression = mappingItem.Expression;
                LambdaExtensions.SetPropertyValue(output, expression, reader.ValueAs(expression.GetExpressionType(), mappingItem.ReaderKey));
            }

            return(output);
        }
Ejemplo n.º 13
0
 public void InitializePublisher(IExecutionContext context, string projectName, VssConnection connection, string testRunner, bool publishRunLevelAttachments)
 {
     Trace.Entering();
     _executionContext   = context;
     _projectName        = projectName;
     _testRunner         = testRunner;
     _resultReader       = GetTestResultReader(_testRunner, publishRunLevelAttachments);
     _testRunPublisher   = HostContext.GetService <ITestRunPublisher>();
     _featureFlagService = HostContext.GetService <IFeatureFlagService>();
     _testRunPublisher.InitializePublisher(_executionContext, connection, projectName, _resultReader);
     _calculateTestRunSummary = _featureFlagService.GetFeatureFlagState(TestResultsConstants.CalculateTestRunSummaryFeatureFlag, TestResultsConstants.TFSServiceInstanceGuid);
     Trace.Leaving();
 }
Ejemplo n.º 14
0
        private IResultReader GetTestResultReader(string testRunner, bool publishRunLevelAttachments)
        {
            var           extensionManager = HostContext.GetService <IExtensionManager>();
            IResultReader reader           = (extensionManager.GetExtensions <IResultReader>()).FirstOrDefault(x => testRunner.Equals(x.Name, StringComparison.OrdinalIgnoreCase));

            if (reader == null)
            {
                throw new ArgumentException("Unknown Test Runner.");
            }

            reader.AddResultsFileToRunLevelAttachments = publishRunLevelAttachments;
            return(reader);
        }
        public MapRenderModule(IRenderQueue queue, IMapRenderer renderer, IJobPrioritizer prioritizer, IResultWriter writer, IResultReader reader, IConfigService config, IWorldFinder finder, IWorldArchivist archivist)
        {
            _queue       = queue;
            _renderer    = renderer;
            _prioritizer = prioritizer;
            _writer      = writer;
            _reader      = reader;
            _config      = config;
            _finder      = finder;
            _archivist   = archivist;

            ensureOverviewerOutput();
        }
Ejemplo n.º 16
0
        private void AttachCustomFactories <TView>(IResultReader <TView> resultReader)
            where TView : class
        {
            var mappingReader = resultReader as MappingReader <TView>;

            if (mappingReader == null)
            {
                return;
            }

            if (_typeInstanceFactory != null)
            {
                mappingReader.TypeInstanceFactory = _typeInstanceFactory;
            }

            if (_typeReaderWriterFactory != null)
            {
                mappingReader.TypeReaderWriterFactory = _typeReaderWriterFactory;
            }
        }
Ejemplo n.º 17
0
        public IEntitySelectQueryBuilder <T> Select <TView>(IEntityReference <T> entityReference, out IResultReader <TView> resultReader) where TView : class
        {
            if (_primaryKeys.Length == 0)
            {
                ExceptionHelper.ThrowNoPrimaryKey <T>();
            }
            var entity  = entityReference.AsEntity();
            var builder = new SelectBuilder <T>(_schema, _entityModel);

            foreach (var field in _primaryKeys)
            {
                builder.Where.AndAlso(field, ComparisonOperator.AreEqual, entity);
            }
            builder.Range.Limit(1);
            resultReader = builder.Projection.AddView <TView>();
            return(builder);
        }
Ejemplo n.º 18
0
        private void ProcessPublishTestResultsCommand(IExecutionContext context, Dictionary <string, string> eventProperties, string data)
        {
            ArgUtil.NotNull(context, nameof(context));
            _executionContext = context;

            _telemetryProperties = new Dictionary <string, object>();
            PopulateTelemetryData();

            LoadPublishTestResultsInputs(context, eventProperties, data);

            string teamProject = context.Variables.System_TeamProject;
            string owner       = context.Variables.Build_RequestedFor;
            string buildUri    = context.Variables.Build_BuildUri;
            int    buildId     = context.Variables.Build_BuildId ?? 0;
            string pullRequestTargetBranchName = context.Variables.System_PullRequest_TargetBranch;
            string stageName    = context.Variables.System_StageName;
            string phaseName    = context.Variables.System_PhaseName;
            string jobName      = context.Variables.System_JobName;
            int    stageAttempt = context.Variables.System_StageAttempt ?? 0;
            int    phaseAttempt = context.Variables.System_PhaseAttempt ?? 0;
            int    jobAttempt   = context.Variables.System_JobAttempt ?? 0;


            //Temporary fix to support publish in RM scenarios where there might not be a valid Build ID associated.
            //TODO: Make a cleaner fix after TCM User Story 401703 is completed.
            if (buildId == 0)
            {
                _platform = _configuration = null;
            }

            string releaseUri            = null;
            string releaseEnvironmentUri = null;

            // Check to identify if we are in the Release management flow; if not, then release fields will be kept null while publishing to TCM
            if (!string.IsNullOrWhiteSpace(context.Variables.Release_ReleaseUri))
            {
                releaseUri            = context.Variables.Release_ReleaseUri;
                releaseEnvironmentUri = context.Variables.Release_ReleaseEnvironmentUri;
            }

            IResultReader  resultReader = GetTestResultReader(_testRunner);
            TestRunContext runContext   = new TestRunContext(owner, _platform, _configuration, buildId, buildUri, releaseUri, releaseEnvironmentUri);

            runContext.StageName    = stageName;
            runContext.StageAttempt = stageAttempt;
            runContext.PhaseName    = phaseName;
            runContext.PhaseAttempt = phaseAttempt;
            runContext.JobName      = jobName;
            runContext.JobAttempt   = jobAttempt;

            runContext.PullRequestTargetBranchName = pullRequestTargetBranchName;

            VssConnection connection = WorkerUtilities.GetVssConnection(_executionContext);

            var commandContext = HostContext.CreateService <IAsyncCommandContext>();

            commandContext.InitializeCommandContext(context, StringUtil.Loc("PublishTestResults"));
            commandContext.Task = PublishTestResultsAsync(connection, teamProject, buildId, runContext, resultReader);
            _executionContext.AsyncCommands.Add(commandContext);

            if (_isTestRunOutcomeFailed)
            {
                _executionContext.Result = TaskResult.Failed;
                _executionContext.Error(StringUtil.Loc("FailedTestsInResults"));
            }
        }
Ejemplo n.º 19
0
 public static IResultReader <(T1, T2)> Combine <T1, T2>(this IResultReader <T1> resultReader1, IResultReader <T2> resultReader2)
 {
     return(new CompositeResultReader <T1, T2>(resultReader1, resultReader2));
 public RenderStateReader(IRenderQueue queue, IResultReader reader)
 {
     _queue  = queue;
     _reader = reader;
 }
Ejemplo n.º 21
0
        private async Task PublishTestResultsAsync(VssConnection connection, String teamProject, int buildId, TestRunContext runContext, IResultReader resultReader)
        {
            var publisher = HostContext.GetService <ITestRunPublisher>();

            publisher.InitializePublisher(_executionContext, connection, teamProject, resultReader);

            if (_mergeResults)
            {
                await PublishAllTestResultsToSingleTestRunAsync(_testResultFiles, publisher, buildId, runContext, resultReader.Name, _executionContext.CancellationToken);
            }
            else
            {
                await PublishToNewTestRunPerTestResultFileAsync(_testResultFiles, publisher, runContext, resultReader.Name, PublishBatchSize, _executionContext.CancellationToken);
            }

            await PublishEventsAsync(connection);
        }