Пример #1
0
            private void TestAll(JobId id, string name)
            {
                var other = JobId.ParseName(name);

                Assert.Equal(id, other);
                Assert.Equal(id.Name, name);
            }
Пример #2
0
            public void ParseNonJson()
            {
                var buildId = new BuildId(42, JobId.ParseName("test"));

                _restClient.AddJson(buildId, testReportJson: TestResources.TestReport1);
                Assert.Throws <JsonReaderException>(() => _client.GetFailedTestCases(buildId));
            }
Пример #3
0
 public void Single()
 {
     RunAll(EqualityUnit
            .Create(new JobId("test"))
            .WithEqualValues(new JobId("test"), JobId.ParseName("test"))
            .WithNotEqualValues(new JobId("test2"), JobId.Root));
 }
Пример #4
0
 public void Nested()
 {
     RunAll(EqualityUnit
            .Create(new JobId("test", new JobId("op")))
            .WithEqualValues(new JobId("test", new JobId("op")), JobId.ParseName("op/test"))
            .WithNotEqualValues(new JobId("test"), JobId.Root, new JobId("op")));
 }
Пример #5
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);
            }
        }
Пример #6
0
        public void ViewNameAll()
        {
            var buildId = new BuildId(42, JobId.ParseName("test"));
            var entity  = new BuildResultEntity(buildId, DateTimeOffset.UtcNow, TimeSpan.FromSeconds(1), "kind", "test", BuildResultClassification.Succeeded, null);

            Assert.Equal(AzureUtil.ViewNameRoot, entity.ViewName);
        }
Пример #7
0
        private static async Task Test()
        {
            var account     = GetStorageAccount();
            var tableClient = account.CreateCloudTableClient();
            var table       = tableClient.GetTableReference(AzureConstants.TableNames.BuildResultDate);
            var query       = new TableQuery <DynamicTableEntity>()
                              .Where(FilterUtil.SinceDate(ColumnNames.PartitionKey, DateTimeOffset.UtcNow - TimeSpan.FromDays(2)))
                              .Select(new[] { "JobName" });
            var nameSet = new HashSet <string>();
            var kindSet = new HashSet <string>();

            foreach (var entity in table.ExecuteQuery(query))
            {
                var name = entity["JobName"].StringValue;
                if (nameSet.Add(name))
                {
                    var id = JobId.ParseName(name);
                    try
                    {
                        var client = CreateClient(id);
                        var kind   = await client.GetJobKindAsync(id);

                        if (kindSet.Add(kind))
                        {
                            Console.WriteLine(kind);
                        }
                    }
                    catch
                    {
                        // Ignore
                    }
                }
            }
        }
Пример #8
0
        public void ViewNameOther()
        {
            var buildId = Create("example.com", 42, JobId.ParseName("house/test"));
            var entity  = new BuildResultEntity(buildId, DateTimeOffset.UtcNow, TimeSpan.FromSeconds(1), "kind", "test", BuildResultClassification.Succeeded, null);

            Assert.Equal("house", entity.ViewName);
        }
Пример #9
0
 public void Root()
 {
     RunAll(EqualityUnit
            .Create(JobId.Root)
            .WithEqualValues(JobId.Root, JobId.ParseName(""))
            .WithNotEqualValues(new JobId("test")));
 }
Пример #10
0
        public void JobNameInFolder()
        {
            var jobId    = JobId.ParseName("job/cat/job/dog");
            var buildId  = new BuildId(42, jobId);
            var buildKey = new BuildKey(buildId);

            Assert.False(AzureUtil.IsIllegalKey(buildKey.Key));
        }
Пример #11
0
        private static void OomTest()
        {
            var buildId = new BuildId(352, JobId.ParseName("dotnet_corefx/master/windows_nt_release_prtest"));
            var client  = CreateClient();
            var list    = client.GetFailedTestCases(buildId);

            Console.WriteLine(list.Count);
        }
Пример #12
0
        public void DateKey()
        {
            var offset  = DateTimeOffset.UtcNow;
            var buildId = new BuildId(42, JobId.ParseName("test"));
            var key     = BuildFailureEntity.GetDateEntityKey(offset, buildId, "testName");

            Assert.False(key.RowKey.Contains("Key"));
        }
Пример #13
0
        public void Simple()
        {
            var jobId    = JobId.ParseName("dog");
            var buildId  = new BuildId(42, jobId);
            var buildKey = new BuildKey(buildId);

            Assert.False(AzureUtil.IsIllegalKey(buildKey.Key));
            Assert.Equal("42-dog", buildKey.Key);
        }
Пример #14
0
        public void ComplexJobKey()
        {
            var jobId     = JobId.ParseName("job/cat/job/dog");
            var buildId   = new BuildId(42, jobId);
            var entityKey = BuildResultEntity.GetExactEntityKey(buildId);

            Assert.False(AzureUtil.IsIllegalKey(entityKey.PartitionKey));
            Assert.False(AzureUtil.IsIllegalKey(entityKey.RowKey));
        }
Пример #15
0
        public void ComplexJobKeyDate()
        {
            var jobId     = JobId.ParseName("job/cat/job/dog");
            var buildId   = new BuildId(42, jobId);
            var entityKey = BuildFailureEntity.GetDateEntityKey(DateTimeOffset.UtcNow, buildId, "terrible/blah");

            Assert.False(AzureUtil.IsIllegalKey(entityKey.PartitionKey));
            Assert.False(AzureUtil.IsIllegalKey(entityKey.RowKey));
        }
Пример #16
0
            public void Scheme()
            {
                var buildId = new BuildId(42, JobId.ParseName("cat"));

                RunAll(EqualityUnit
                       .Create(new BoundBuildId("test", buildId, Uri.UriSchemeFtp))
                       .WithEqualValues(new BoundBuildId("test", buildId, Uri.UriSchemeFtp))
                       .WithNotEqualValues(new BoundBuildId("other", buildId, Uri.UriSchemeHttps)));
            }
Пример #17
0
            public void HostName()
            {
                var host    = new Uri("http://test.com");
                var buildId = new BuildId(42, JobId.ParseName("cat"));

                RunAll(EqualityUnit
                       .Create(new BoundBuildId(host, buildId))
                       .WithEqualValues(new BoundBuildId(host, buildId), new BoundBuildId(host, buildId))
                       .WithNotEqualValues(new BoundBuildId(new Uri("http://other.com"), buildId)));
            }
Пример #18
0
            public void JobIdDifferent()
            {
                var id1 = JobId.ParseName("dog");
                var id2 = JobId.ParseName("cat");

                RunAll(EqualityUnit.Create(new BuildId(42, id1))
                       .WithEqualValues(new BuildId(42, id1))
                       .WithNotEqualValues(
                           new BuildId(42, id2),
                           new BuildId(42, JobId.Root)));
            }
Пример #19
0
        private static List <Tuple <bool, JobId> > GetJobList()
        {
            var list = new List <Tuple <bool, JobId> >();

            foreach (var line in File.ReadAllLines(JobListFile))
            {
                var parts    = line.Split(new[] { ':' }, count: 2, options: StringSplitOptions.None);
                var isFolder = bool.Parse(parts[0]);
                var jobId    = JobId.ParseName(parts[1]);
                list.Add(Tuple.Create(isFolder, jobId));
            }

            return(list);
        }
Пример #20
0
        public void FallbackToHostName()
        {
            var jobId  = JobId.ParseName("test");
            var host   = new Uri("http://example.com");
            var entity = new BuildStateEntity()
            {
                JobName     = jobId.Name,
                BuildNumber = 42,
                HostRaw     = null,
                HostName    = "example.com"
            };

            Assert.Equal(host, entity.BoundBuildId.Host);
        }
Пример #21
0
        public void PreferHostRaw()
        {
            var jobId  = JobId.ParseName("test");
            var host   = new Uri("https://example.com");
            var entity = new BuildStateEntity()
            {
                JobName     = jobId.Name,
                BuildNumber = 42,
                HostRaw     = host.ToString(),
                HostName    = "ignore"
            };

            Assert.Equal(host, entity.BoundBuildId.Host);
        }
Пример #22
0
        public void MissingHostName()
        {
            var jobId  = JobId.ParseName("test");
            var entity = new BuildResultEntity()
            {
                BuildNumber = 42,
                JobName     = jobId.Name
            };

            var buildId = entity.BoundBuildId;

            Assert.Equal(LegacyUtil.DefaultHost, buildId.Host);
            Assert.Equal(jobId, buildId.JobId);
            Assert.Equal(42, buildId.Number);
        }
Пример #23
0
            internal static BuildData ParseLine(string line)
            {
                var parts = line.Split(',');

                Debug.Assert(parts.Length == 4);
                var jobId  = JobId.ParseName(parts[0]);
                var number = int.Parse(parts[1]);

                return(new BuildData()
                {
                    BuildId = new BuildId(number, jobId),
                    ResultName = parts[2],
                    ResultCategory = parts[3]
                });
            }
Пример #24
0
        public async Task IsPopulated()
        {
            var buildId = new BuildId(42, JobId.ParseName(Guid.NewGuid().ToString()));

            Assert.False(await _populator.IsPopulated(buildId));

            var key    = BuildResultEntity.GetExactEntityKey(buildId);
            var entity = new DynamicTableEntity()
            {
                PartitionKey = key.PartitionKey,
                RowKey       = key.RowKey
            };
            await _buildResultExactTable.ExecuteAsync(TableOperation.Insert(entity));

            Assert.True(await _populator.IsPopulated(buildId));
        }
Пример #25
0
        private BuildResultModel GetBuildResultModel(string jobName, BuildFilterModel filter)
        {
            var model = new BuildResultModel()
            {
                Filter = filter,
                JobId  = JobId.ParseName(jobName),
            };

            var queryResult = _buildUtil
                              .GetBuildResults(filter.StartDate, jobName, filter.ViewName)
                              .Where(x => filter.IncludePullRequests || !JobUtil.IsPullRequestJobName(x.JobId.Name))
                              .Where(x => x.ClassificationKind != ClassificationKind.Succeeded)
                              .OrderBy(x => x.BuildNumber);

            model.Entries.AddRange(queryResult);
            return(model);
        }
Пример #26
0
        public void PullRequestInfo()
        {
            var buildId   = Create("example.com", 42, JobId.ParseName("hello"));
            var buildDate = DateTimeOffset.UtcNow;
            var prInfo    = new PullRequestInfo("bob", "dog", 42, "cat", "tree");
            var entity    = new BuildResultEntity(
                buildId,
                buildDate,
                TimeSpan.FromSeconds(1),
                "kind",
                "test",
                BuildResultClassification.Succeeded,
                prInfo: prInfo);

            Assert.True(entity.HasPullRequestInfo);
            Assert.Equal(entity.PullRequestInfo.Author, prInfo.Author);
            Assert.Equal(entity.PullRequestInfo.AuthorEmail, prInfo.AuthorEmail);
            Assert.Equal(entity.PullRequestInfo.Id, prInfo.Id);
            Assert.Equal(entity.PullRequestInfo.PullUrl, prInfo.PullUrl);
            Assert.Equal(entity.PullRequestSha1, prInfo.Sha1);
        }
Пример #27
0
        public void Properties()
        {
            var buildId   = Create("example.com", 42, JobId.ParseName("hello"));
            var buildDate = DateTimeOffset.UtcNow;
            var entity    = new BuildResultEntity(
                buildId,
                buildDate,
                TimeSpan.FromSeconds(1),
                "kind",
                "test",
                BuildResultClassification.Succeeded,
                prInfo: null);

            Assert.Equal(BuildResultClassification.Succeeded.Kind, entity.Classification.Kind);
            Assert.Equal(BuildResultClassification.Succeeded.Name, entity.Classification.Name);
            Assert.Equal(buildId, entity.BoundBuildId);
            Assert.Equal(buildId.Number, entity.BuildNumber);
            Assert.Equal(buildId.JobId, entity.JobId);
            Assert.Equal(buildDate, entity.BuildDateTimeOffset);
            Assert.Equal("test", entity.MachineName);
            Assert.False(entity.HasPullRequestInfo);
            Assert.Null(entity.PullRequestInfo);
        }
Пример #28
0
        public ActionResult Jobs(string name = null, string view = null)
        {
            var client = ControllerUtil.CreateJenkinsClient();

            if (!string.IsNullOrEmpty(name))
            {
                var jobId   = JobId.ParseName(name);
                var jobInfo = client.GetJobInfo(jobId);
                if (jobInfo.JobKind == JobKind.Folder)
                {
                    return(GetJobList(name, JobListContainerKind.Job, jobInfo.Jobs));
                }

                return(GetJob(jobId));
            }

            if (!string.IsNullOrEmpty(view))
            {
                return(GetJobList(view, JobListContainerKind.View, client.GetJobIdsInView(view)));
            }

            return(GetJobList("Root", JobListContainerKind.Root, client.GetJobIds()));
        }
        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);
            }
        }
Пример #30
0
 private static void PrintFailure()
 {
     var client = CreateClient(auth: false);
     var info   = client.GetBuildFailureInfo(new BuildId(number: 6066, jobId: JobId.ParseName("roslyn_prtest_win_dbg_unit64")));
     // Console.WriteLine(info.Category);
 }