Skip to content

Commit

Permalink
Another try
Browse files Browse the repository at this point in the history
  • Loading branch information
daveaglick committed Dec 12, 2018
1 parent 3ccac75 commit d32aa63
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
7 changes: 6 additions & 1 deletion ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# 0.2.1
# 0.2.2

- [Feature] Better test run names
- [Fix] Common API version for all endpoints

# 0.2.0

- [Fix] Big refactoring to create a new test run before posting results

Expand Down
2 changes: 1 addition & 1 deletion src/PipelinesTestLogger/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace PipelinesTestLogger
{
internal class ApiClient
{
private const string ApiVersion = "5.0-preview.5";
private const string ApiVersion = "5.0-preview.2";

private static readonly HttpClient _client = new HttpClient();

Expand Down
8 changes: 4 additions & 4 deletions src/PipelinesTestLogger/LoggerQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace PipelinesTestLogger
internal class LoggerQueue
{
private readonly ApiClient _apiClient;
private readonly string _runName;
private readonly string _buildId;
private readonly string _jobName;

private readonly AsyncProducerConsumerCollection<string> _queue = new AsyncProducerConsumerCollection<string>();
private readonly Task _consumeTask;
Expand All @@ -20,11 +20,11 @@ internal class LoggerQueue
private int totalEnqueued = 0;
private int totalSent = 0;

public LoggerQueue(ApiClient apiClient, string buildId, string jobName)
public LoggerQueue(ApiClient apiClient, string buildId, string agentName, string jobName)
{
_apiClient = apiClient;
_buildId = buildId;
_jobName = jobName;
_runName = $"{ jobName } on { agentName } at {DateTime.UtcNow.ToString("o")}";
_consumeTask = ConsumeItemsAsync(_consumeTaskCancellationSource.Token);
}

Expand Down Expand Up @@ -104,7 +104,7 @@ private async Task<int> CreateTestRun(CancellationToken cancellationToken)
{
Dictionary<string, object> request = new Dictionary<string, object>
{
{ "name", $"{_jobName} at {DateTime.UtcNow.ToString("o")}"},
{ "name", _runName },
{ "build", new Dictionary<string, object> { { "id", _buildId } } },
{ "isAutomated", true }
};
Expand Down
3 changes: 2 additions & 1 deletion src/PipelinesTestLogger/PipelinesTestLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ public void Initialize(TestLoggerEvents events, string testRunDirectory)
|| !GetRequiredVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", out string collectionUri)
|| !GetRequiredVariable("SYSTEM_TEAMPROJECT", out string teamProject)
|| !GetRequiredVariable("BUILD_BUILDID", out string buildId)
|| !GetRequiredVariable("AGENT_NAME", out string agentName)
|| !GetRequiredVariable("AGENT_JOBNAME", out string jobName))
{
return;
}

ApiClient apiClient = new ApiClient(accessToken, collectionUri, teamProject);
_queue = new LoggerQueue(apiClient, buildId, jobName);
_queue = new LoggerQueue(apiClient, buildId, agentName, jobName);

// Register for the events.
events.TestRunMessage += TestMessageHandler;
Expand Down

0 comments on commit d32aa63

Please sign in to comment.