コード例 #1
0
        public async Task TaoFailure()
        {
            var buildId = new BuildId(4, JobId.ParseName("test"));

            _restClient.AddJson(
                buildId: buildId,
                buildResultJson: TestResources.Tao1BuildResult,
                buildInfoJson: TestResources.Tao1BuildInfo,
                failureInfoJson: TestResources.Tao1FailureInfo,
                testReportJson: TestResources.Tao1TestResult);

            var entity = await _populator.PopulateBuild(buildId);

            var filter = FilterUtil
                         .Column(nameof(BuildFailureEntity.JobName), buildId.JobName)
                         .Filter;
            var list = AzureUtil.Query <BuildFailureEntity>(_buildFailureExactTable, filter).ToList();

            Assert.Equal(2, list.Count);
            foreach (var item in list)
            {
                Assert.Equal(BuildFailureKind.TestCase, item.BuildFailureKind);
                Assert.Equal(buildId, item.BuildId);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: karelz/jenkins
        private static async Task DrainPoisonQueue()
        {
            var account   = GetStorageAccount();
            var client    = account.CreateCloudQueueClient();
            var queue     = client.GetQueueReference($"{AzureConstants.QueueNames.BuildEvent}-poison");
            var populator = new BuildTablePopulator(account.CreateCloudTableClient(), CreateClient(), Console.Out);
            var set       = new HashSet <BuildId>();

            do
            {
                var message = await queue.GetMessageAsync();

                var obj     = JObject.Parse(message.AsString);
                var jobPath = obj.Value <string>("jobName");
                var number  = obj.Value <int>("number");
                var buildId = new BuildId(number, JenkinsUtil.ConvertPathToJobId(jobPath));
                if (!set.Add(buildId))
                {
                    continue;
                }

                await populator.PopulateBuild(buildId);

                await queue.DeleteMessageAsync(message);
            } while (true);
        }
コード例 #3
0
        private static async Task TestFailureYesterday(int days = -1)
        {
            var account     = GetStorageAccount();
            var tableClient = account.CreateCloudTableClient();
            var table       = tableClient.GetTableReference(TableNames.BuildState);
            var date        = DateTimeOffset.UtcNow.AddDays(days);
            var query       = TableQueryUtil.And(
                TableQueryUtil.PartitionKey(DateTimeKey.GetDateKey(date)),
                TableQueryUtil.Column(nameof(BuildStateEntity.IsBuildFinished), true),
                TableQueryUtil.Column(nameof(BuildStateEntity.IsDataComplete), false));
            var list = await AzureUtil.QueryAsync <BuildStateEntity>(table, query);

            foreach (var entity in list)
            {
                var populator = new BuildTablePopulator(tableClient, CounterUtilFactory, CreateClient(entity.BoundBuildId), TextWriter.Null);
                try
                {
                    Console.Write($"{entity.BuildId} ... ");
                    await populator.PopulateBuild(entity.BoundBuildId);

                    Console.WriteLine("good");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERRROR");
                    Console.WriteLine(ex);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Function to help diagnose failures in processing.
        /// </summary>
        /// <returns></returns>
        private static async Task TestFailure()
        {
            /*
             * var name = "Private/Microsoft_vstest/master/Microsoft_vstest_Release_prtest";
             * var number = 119;
             * var host = SharedConstants.DotnetJenkinsHostName;
             * var jobId = JobId.ParseName(name);
             * var boundBuildId = new BoundBuildId(host, new BuildId(number, jobId));
             */

            var url          = "http://dotnet-ci.cloudapp.net/job/dotnet_coreclr/job/master/job/debug_windows_nt_bld/198";
            var boundBuildId = BoundBuildId.Parse(url);

            var buildId   = boundBuildId.BuildId;
            var account   = GetStorageAccount();
            var client    = CreateClient(boundBuildId);
            var populator = new BuildTablePopulator(account.CreateCloudTableClient(), CounterUtilFactory, client, Console.Out);

            try
            {
                await populator.PopulateBuild(boundBuildId);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #5
0
ファイル: StateUTil.cs プロジェクト: venkat-raman251/jenkins
        internal async Task <bool> PopulateCore(BuildStateEntity entity, BuildTablePopulator populator, CancellationToken cancellationToken)
        {
            var buildId = entity.BoundBuildId;
            var key     = entity.BuildStateKey;

            await CheckFinished(entity, cancellationToken);

            // Don't process the build unless it's known to have finished.
            if (!entity.IsBuildFinished)
            {
                _logger.WriteLine($"Build {buildId.JobId} isn't finished yet");
                return(false);
            }

            // The build was completely populated by a previous message.  No more work needed.
            if (entity.IsDataComplete)
            {
                _logger.WriteLine($"Build {buildId.JobId} is already populated");
                return(true);
            }

            try
            {
                _logger.WriteLine($"Populating {buildId.JobId} ... ");
                await populator.PopulateBuild(buildId);

                _logger.WriteLine($"Updating the build data state ..");
                entity.IsDataComplete = true;
                entity.Error          = null;
                entity.ETag           = "*";
                await _buildStateTable.ExecuteAsync(TableOperation.Replace(entity), cancellationToken);

                _logger.WriteLine($"Completed");
                return(true);
            }
            catch (Exception e)
            {
                _logger.WriteLine($"Failed");
                _logger.WriteLine(e);

                await CheckForMissingBuild(entity, cancellationToken);

                try
                {
                    entity.Error = $"{e.Message} - {e.StackTrace.Take(1000)}";
                    await _buildStateTable.ExecuteAsync(TableOperation.Replace(entity));
                }
                catch (StorageException ex) when(ex.RequestInformation.HttpStatusCode == 412)
                {
                    // It's possible the enity was updated in parallel.  That's okay.  This table
                    // is meant as an approximation of the build state and always moving towards complete.
                }

                return(false);
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: karelz/jenkins
        private static async Task TestJob()
        {
            var jobUrlStr = "http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_roslyn-internal/job/microupdate/job/windows_vsi_p2/8/";
            var uri       = new Uri(jobUrlStr);
            var parts     = uri.PathAndQuery.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            var jobPath   = string.Join("/", parts.Take(parts.Length - 1));
            var number    = int.Parse(parts.Last());
            var jobId     = JenkinsUtil.ConvertPathToJobId(jobPath);
            var buildId   = new BuildId(number, jobId);

            var account   = GetStorageAccount();
            var populator = new BuildTablePopulator(account.CreateCloudTableClient(), CreateClient(), Console.Out);
            await populator.PopulateBuild(buildId);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: karelz/jenkins
        private static async Task TestPopulator()
        {
            var account   = GetStorageAccount();
            var client    = CreateClient(auth: false);
            var populator = new BuildTablePopulator(account.CreateCloudTableClient(), client, Console.Out);

            var boundBuildId = BoundBuildId.Parse("https://dotnet-ci.cloudapp.net/job/dotnet_coreclr/job/master/job/jitstress/job/x64_checked_osx_jitstress1_flow/7/");

            try
            {
                await populator.PopulateBuild(boundBuildId.BuildId);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #8
0
        /// <summary>
        /// Populate the given build and update the unprocessed table accordingly.  If there is no
        /// existing entity in the unprocessed table, this won't add one.  It will only update existing
        /// ones.
        /// </summary>
        internal async Task Populate(BuildId buildId, BuildTablePopulator populator, bool force, CancellationToken cancellationToken)
        {
            var key = UnprocessedBuildEntity.GetEntityKey(buildId);

            try
            {
                // If we are not forcing the update then check for the existence of a completed run before
                // requerying Jenkins.
                if (force || !(await populator.IsPopulated(buildId)))
                {
                    await populator.PopulateBuild(buildId);
                }

                await AzureUtil.MaybeDeleteAsync(_unprocessedBuildTable, key, cancellationToken);
            }
            catch (Exception e)
            {
                // Update the error state for the row.
                var entity = await AzureUtil.QueryAsync <UnprocessedBuildEntity>(_unprocessedBuildTable, key, cancellationToken);

                if (entity != null)
                {
                    entity.StatusText = $"{e.Message} - {e.StackTrace.Take(1000)}";
                    var operation = TableOperation.Replace(entity);
                    try
                    {
                        await _unprocessedBuildTable.ExecuteAsync(operation);
                    }
                    catch
                    {
                        // It's possible the enity was deleted / updated in parallel.  That's okay.  This table
                        // is meant as an approximation of the build state and always moving towards complete.
                    }
                }
            }
        }
コード例 #9
0
        public async Task TaoFailure()
        {
            var buildId = new BuildId(4, JobId.ParseName("test"));

            _restClient.AddJson(
                buildId: buildId,
                buildResultJson: TestResources.Tao1BuildResult,
                buildInfoJson: TestResources.Tao1BuildInfo,
                failureInfoJson: TestResources.Tao1FailureInfo,
                testReportJson: TestResources.Tao1TestResult,
                jobXml: @"<freeStyleProject></freeStyleProject>");

            await _populator.PopulateBuild(new BoundBuildId(new Uri("http://example.com"), buildId));

            var filter = TableQueryUtil.Column(nameof(BuildFailureEntity.JobName), buildId.JobName);
            var list   = AzureUtil.Query <BuildFailureEntity>(_buildFailureExactTable, filter).ToList();

            Assert.Equal(2, list.Count);
            foreach (var item in list)
            {
                Assert.Equal(BuildFailureKind.TestCase, item.BuildFailureKind);
                Assert.Equal(buildId, item.BuildId);
            }
        }