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)); }
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")); }
public static Uri GetBuildStatusIconUri(Uri jenkinsUri, BuildId id) { var builder = new UriBuilder(jenkinsUri); builder.Path = "buildStatus/icon"; builder.Query = $"job={id.JobId.Name}&build={id.Number}"; return builder.Uri; }
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)); }
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); }
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)); }
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); }
public async Task VerifySymbolFileAsync(string filepath, bool isDebugInfoFile) { BuildId buildId = await ReadBuildIdAsync(filepath); if (_verificationFailures.TryGetValue(buildId.ToString(), out string errorString)) { throw new BinaryFileUtilException(errorString); } }
/// <summary> /// Update the table storage to contain the result of the specified build. /// </summary> private async Task <BuildResultEntity> GetBuildFailureEntity(BuildId id) { var buildInfo = await _client.GetBuildInfoAsync(id); var jobKind = await _client.GetJobKindAsync(id.JobId); PullRequestInfo prInfo = null; if (JobUtil.IsPullRequestJobName(id.JobId.Name)) { try { prInfo = await _client.GetPullRequestInfoAsync(id); } catch (Exception ex) { // TODO: Flow builds don't have the PR directly in the triggered jobs. Have to walk // back up to the parent job. For now swallow this error so we don't trigger false // positives in the error detection. _textWriter.WriteLine($"Error pulling PR info for {id}: {ex.Message}"); } } BuildResultClassification classification; switch (buildInfo.State) { case BuildState.Succeeded: classification = BuildResultClassification.Succeeded; break; case BuildState.Aborted: classification = BuildResultClassification.Aborted; break; case BuildState.Failed: classification = await PopulateFailedBuildResult(buildInfo, jobKind, prInfo); break; case BuildState.Running: classification = BuildResultClassification.Unknown; break; default: throw new Exception($"Invalid enum: {buildInfo.State} for {id.JobName} - {id.Number}"); } return(new BuildResultEntity( buildInfo.Id, buildInfo.Date, buildInfo.Duration, jobKind: jobKind, machineName: buildInfo.MachineName, classification: classification, prInfo: prInfo)); }
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))); }
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))); }
public void Inequality(string aStr, string bStr) { var a = new BuildId(aStr); var b = new BuildId(bStr); Assert.False(a.Equals(b)); Assert.False(Equals(a, b)); Assert.True(a != b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void Equality_DefaultEqualsZeroLength() { BuildId defaultBuilId; BuildId zeroLength = new BuildId(new byte[] { }); Assert.True(defaultBuilId.Equals(zeroLength)); Assert.True(Equals(defaultBuilId, zeroLength)); Assert.True(defaultBuilId == zeroLength); Assert.AreEqual(defaultBuilId.GetHashCode(), zeroLength.GetHashCode()); }
private static async Task <BuildData?> GetBuildDataAsync(BuildId buildId) { var client = CreateClient(); var buildInfo = await client.GetBuildInfoAsync(buildId); string name; string category; switch (buildInfo.State) { case BuildState.Succeeded: name = "Succeeded"; category = "Succeeded"; break;; case BuildState.Aborted: name = "Aborted"; category = "Aborted"; break;; case BuildState.Failed: { try { var buildResult = await client.GetBuildResultAsync(buildInfo); var cause = GetBestCause(buildResult.FailureInfo); name = string.IsNullOrEmpty(cause.Name) ? "Unknown Name" : cause.Name; category = string.IsNullOrEmpty(cause.Category) ? "Unknown Category" : cause.Category; } catch { name = "Rest API Error"; category = "Unknown"; } } break; case BuildState.Running: // Don't collect data here return(null); default: Debug.Assert(false); return(null); } return(new BuildData() { BuildId = buildId, ResultName = name, ResultCategory = category, }); }
public Auth(byte[] state, string node = "") { if (string.IsNullOrEmpty(node)) { node = new BuildId().MakeIdS + Encoding.UTF8.GetString(state); node += new Random().NextDouble().ToString(CultureInfo.CurrentCulture); } this.KeyBytes = this._sha512.ComputeHash(Encoding.UTF8.GetBytes(node)); this.TokenBytes = this._sha512.ComputeHash(this.KeyBytes); }
public void AddFile_InvalidArgument(string filename, string buildIdStr) { var buildId = new BuildId(buildIdStr); var store = GetEmptyStore(); if (!store.SupportsAddingFiles) { return; } Assert.ThrowsAsync <ArgumentException>( () => store.AddFileAsync(sourceSymbolFile, filename, buildId)); }
public static byte[] GetElfFileBytesFromBuildId(BuildId id, bool isExecutable = false) { var idNote = GetNoteSectionBytes(NoteSection.GnuName, NoteSection.NtGnuBuildIdType, id.Bytes.ToArray()); var noteOffset = ProgramHeader.Size + ElfHeader.Size; var programHeader = GetProgramHeaderBytes( ProgramHeader.Type.NoteSegment, (ulong)noteOffset, 0, (ulong)idNote.Length); var elfHeader = GetElfBytes(ElfHeader.Size, ProgramHeader.Size, 1, isExecutable); return(elfHeader.Concat(programHeader).Concat(idNote).ToArray()); }
public async Task FindFile_BuildIdMismatchAsync() { var mismatchedBuildId = new BuildId("4321"); var store = await GetStoreWithFileAsync(); var fileReference = await store.FindFileAsync(FILENAME, mismatchedBuildId, true, log); Assert.Null(fileReference); StringAssert.Contains(Strings.BuildIdMismatch(Path.Combine(STORE_PATH, FILENAME), mismatchedBuildId, BUILD_ID), log.ToString()); }
private OS GetOsForBuild(BuildId buildId) { var json = _client.GetJson(JenkinsUtil.GetBuildPath(buildId), tree: "builtOn[*]"); var computer = json.Value <string>("builtOn"); OS os; if (!string.IsNullOrEmpty(computer) && _computerNameMap.TryGetValue(computer, out os)) { return(os); } return(OS.Unknown); }
public override async Task <IFileReference> FindFileAsync(string filename, BuildId buildId, bool isDebugInfoFile, TextWriter log) { if (string.IsNullOrEmpty(filename)) { throw new ArgumentException(Strings.FilenameNullOrEmpty, "filename"); } ISymbolStore currentCache = null; foreach (var store in _stores) { IFileReference fileReference = await store.FindFileAsync(filename, buildId, false, log); if (fileReference != null) { if (!store.IsCache && currentCache != null) { try { fileReference = await currentCache.AddFileAsync(fileReference, filename, buildId, log); } catch (Exception e) when(e is NotSupportedException || e is SymbolStoreException || e is ArgumentException) { Trace.WriteLine(e.Message); await log.WriteLineAsync(e.Message); } } if (!fileReference.IsFilesystemLocation || await VerifySymbolFileAsync(fileReference.Location, buildId, isDebugInfoFile, log)) { return(fileReference); } } if (store.IsCache) { currentCache = store; } } return(null); }
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); }
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)); }
private async Task <BuildResultEntity> PopulateBuildIdCore(BuildId buildId) { try { var entity = await GetBuildFailureEntity(buildId); WriteLine(buildId, $"adding reason {entity.ClassificationKind}"); return(entity); } catch (Exception ex) { WriteLine(buildId, $"error processing {ex.Message}"); throw; } }
/// <summary> /// Populate the <see cref="BuildResultEntity"/> structures for a build overwriting any data /// that existed before. Returns the entity if enough information was there to process the value. /// </summary> public async Task <BuildResultEntity> PopulateBuild(BuildId buildId) { var entity = await PopulateBuildIdCore(buildId); if (entity == null) { return(null); } await PopulateViewName(buildId.JobId, entity.BuildDateTimeOffset); await _buildResultDateTable.ExecuteAsync(TableOperation.InsertOrReplace(entity.CopyDate())); await _buildResultExactTable.ExecuteAsync(TableOperation.InsertOrReplace(entity.CopyExact())); return(entity); }
public override async Task <IFileReference> FindFileAsync(string filename, BuildId buildId, bool isDebugInfoFile, TextWriter log) { if (string.IsNullOrEmpty(filename)) { throw new ArgumentException(Strings.FilenameNullOrEmpty, "filename"); } if (buildId == BuildId.Empty) { Trace.WriteLine( Strings.FailedToSearchStructuredStore(_path, filename, Strings.EmptyBuildId)); await log.WriteLineAsync( Strings.FailedToSearchStructuredStore(_path, filename, Strings.EmptyBuildId)); return(null); } string filepath; try { filepath = Path.Combine(_path, filename, buildId.ToString(), filename); } catch (ArgumentException e) { Trace.WriteLine(Strings.FailedToSearchStructuredStore(_path, filename, e.Message)); await log.WriteLineAsync( Strings.FailedToSearchStructuredStore(_path, filename, e.Message)); return(null); } if (!_fileSystem.File.Exists(filepath)) { Trace.WriteLine(Strings.FileNotFound(filepath)); await log.WriteLineAsync(Strings.FileNotFound(filepath)); return(null); } Trace.WriteLine(Strings.FileFound(filepath)); await log.WriteLineAsync(Strings.FileFound(filepath)); return(new FileReference(_fileSystem, filepath)); }
public override int GetHashCode() { int hash = 1; if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (RepoSource.Length != 0) { hash ^= RepoSource.GetHashCode(); } if (RepoOwner.Length != 0) { hash ^= RepoOwner.GetHashCode(); } if (RepoName.Length != 0) { hash ^= RepoName.GetHashCode(); } if (RepoBranch.Length != 0) { hash ^= RepoBranch.GetHashCode(); } if (RepoRevision.Length != 0) { hash ^= RepoRevision.GetHashCode(); } if (BuildId.Length != 0) { hash ^= BuildId.GetHashCode(); } hash ^= steps_.GetHashCode(); if (insertedAtTime_ != null) { hash ^= InsertedAtTime.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <inheritdoc /> public bool Equals(BuildChangeStateCommentReadModel other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (BuildId.Equals(other.BuildId) && Comment == other.Comment && Equals(UserId, other.UserId) && CreatedAt == other.CreatedAt && NewState == other.NewState); }
public override async Task <IFileReference> AddFileAsync(IFileReference source, string filename, BuildId buildId, TextWriter log) { if (source == null) { throw new ArgumentException(Strings.FailedToCopyToStructuredStore( _path, filename, Strings.SourceFileReferenceNull), nameof(source)); } if (string.IsNullOrEmpty(filename)) { throw new ArgumentException(Strings.FailedToCopyToStructuredStore( _path, filename, Strings.FilenameNullOrEmpty), nameof(filename)); } if (buildId == BuildId.Empty) { throw new ArgumentException( Strings.FailedToCopyToStructuredStore(_path, filename, Strings.EmptyBuildId), nameof(buildId)); } try { AddMarkerFileIfNeeded(); string filepath = Path.Combine(_path, filename, buildId.ToString(), filename); await source.CopyToAsync(filepath); Trace.WriteLine(Strings.CopiedFile(filename, filepath)); await log.WriteLineAsync(Strings.CopiedFile(filename, filepath)); return(new FileReference(_fileSystem, filepath)); } catch (Exception e) when(e is SymbolStoreException || e is IOException || e is UnauthorizedAccessException || e is NotSupportedException || e is ArgumentException) { throw new SymbolStoreException( Strings.FailedToCopyToStructuredStore(_path, filename, e.Message), e); } }
public async Task <string> FindFileAsync( string filename, BuildId uuid, bool isDebugInfoFile, TextWriter searchLog) { if (string.IsNullOrEmpty(filename)) { throw new ArgumentNullException(Strings.FilenameNullOrEmpty, nameof(filename)); } searchLog = searchLog ?? TextWriter.Null; await searchLog.WriteLineAsync($"Searching for {filename}"); Trace.WriteLine($"Searching for {filename}"); if (uuid == BuildId.Empty) { await searchLog.WriteLineAsync(ErrorStrings.ModuleBuildIdUnknown); Trace.WriteLine($"Warning: The build ID of {filename} is unknown."); } var fileReference = await _symbolStore.FindFileAsync(filename, uuid, isDebugInfoFile, searchLog); if (fileReference == null) { await searchLog.WriteLineAsync(ErrorStrings.FailedToFindFile(filename)); Trace.WriteLine(ErrorStrings.FailedToFindFile(filename)); return(null); } if (!fileReference.IsFilesystemLocation) { await searchLog.WriteLineAsync( ErrorStrings.FileNotOnFilesystem(fileReference.Location)); Trace.WriteLine($"Unable to load file. '{fileReference.Location}' must be " + $"cached in a filesystem location."); return(null); } return(fileReference.Location); }
public override int GetHashCode() { int hash = 1; if (Target.Length != 0) { hash ^= Target.GetHashCode(); } if (Type != global::Google.Cloud.Functions.V1.OperationType.OperationUnspecified) { hash ^= Type.GetHashCode(); } if (request_ != null) { hash ^= Request.GetHashCode(); } if (VersionId != 0L) { hash ^= VersionId.GetHashCode(); } if (updateTime_ != null) { hash ^= UpdateTime.GetHashCode(); } if (BuildId.Length != 0) { hash ^= BuildId.GetHashCode(); } if (SourceToken.Length != 0) { hash ^= SourceToken.GetHashCode(); } if (BuildName.Length != 0) { hash ^= BuildName.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private static async Task <bool> IsJavaFailure(BuildId buildId) { var client = CreateClient(); try { var consoleText = await client.GetConsoleTextAsync(buildId); if (consoleText.Contains("java.lang.IllegalStateException: Invalid")) { return(true); } return(false); } catch { return(false); } }
public void PullRequestInfo() { var buildId = new BuildId(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); }
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); } }
public BuildAnalyzeError(BuildId id, Exception ex) { BuildId = id; Exception = ex; }
public void ParseNonJson() { var buildId = new BuildId(42, JobId.ParseName("test")); _restClient.AddJson(buildId, testReportJson: TestResources.TestReport1); Assert.Throws<JsonReaderException>(() => _client.GetFailedTestCases(buildId)); }
public BuildEventEntity(BuildId id) { var key = GetEntityKey(id); PartitionKey = key.PartitionKey; RowKey = key.RowKey; }
// TODO: Consider using the host name here as part of the key. Need to understand what happens when // jenkins sends multiple events with same BuildId from different hosts (because it picks one of the // several host names we have for the server). public static EntityKey GetExactEntityKey(BuildId buildId) { var partitionKey = AzureUtil.NormalizeKey(buildId.JobId.Name, '_'); var rowKey = buildId.Number.ToString("0000000000"); return new EntityKey(partitionKey, rowKey); }
public static EntityKey GetDateEntityKey(DateTimeOffset buildDate, BuildId buildId) { return new EntityKey( DateTimeKey.GetDateKey(buildDate), new BuildKey(buildId).Key); }
public static string GetTestReportPath(BuildId id) { return $"{GetBuildPath(id)}testReport"; }
/// <summary> /// Is this build alreadiy fully populated. /// </summary> public async Task<bool> IsPopulated(BuildId buildId, CancellationToken cancellationToken = default(CancellationToken)) { var key = BuildResultEntity.GetExactEntityKey(buildId); var entity = await AzureUtil.QueryAsync<DynamicTableEntity>(_buildResultExactTable, key, cancellationToken); return entity != null; }
public static EntityKey GetDateEntityKey(DateTimeOffset buildDate, BuildId buildId, string identifier) { identifier = AzureUtil.NormalizeKey(identifier, '_'); return new EntityKey( DateTimeKey.GetDateKey(buildDate), $"{new BuildKey(buildId).Key}-{identifier}"); }
public static EntityKey GetExactEntityKey(BuildId buildId, string identifier) { return new EntityKey( AzureUtil.NormalizeKey(identifier, '_'), new BuildKey(buildId).Key); }
private static void Test(string path, BuildId buildId) { Assert.Equal(buildId, JenkinsUtil.ConvertPathToBuildId(path)); }
public static bool TryConvertPathToBuildId(string path, out BuildId buildId) { buildId = default(BuildId); if (path.Contains('?')) { return false; } var parts = path.Split(new[] { '/' }, options: StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) { return false; } int number; if (!int.TryParse(parts[parts.Length - 1], out number)) { return false; } var jobPath = string.Join("/", parts.Take(parts.Length - 1)); JobId jobId; if (!TryConvertPathToJobId(jobPath, out jobId)) { return false; } buildId = new BuildId(number, jobId); return true; }
public static Uri GetBuildUri(Uri baseUrl, BuildId buildId) { var path = GetBuildPath(buildId); return GetUri(baseUrl, path); }
public static string GetBuildPath(BuildId id) { return $"{GetJobPath(id.JobId)}/{id.Number}/"; }
public static string GetConsoleTextPath(BuildId id) { return $"{GetBuildPath(id)}consoleText"; }
public static EntityKey GetEntityKey(BuildId id) { return new EntityKey(id.JobName.ToString(), id.Number.ToString()); }
private void WriteLine(BuildId buildId, string message) { _textWriter.WriteLine($"{buildId.JobName} - {buildId.Number}: {message}"); }