Skip to content

Commit

Permalink
add ability to disable publishing tests metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisRumyantsev committed Mar 21, 2023
1 parent 8114868 commit 98c5172
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/Agent.Sdk/Knob/AgentKnobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ public class AgentKnobs
new EnvironmentKnobSource("VSTSAGENT_DUMP_JOB_EVENT_LOGS"),
new BuiltInDefaultKnobSource("false"));

public static readonly Knob DisableTestsMetadata = new Knob(
nameof(DisableTestsMetadata),
"If true, publishing tests metadata to evidence store will be disabled.",
new RuntimeKnobSource("AZP_AGENT_DISABLE_TESTS_METADATA"),
new EnvironmentKnobSource("AZP_AGENT_DISABLE_TESTS_METADATA"),
new BuiltInDefaultKnobSource("false"));

// Diag logging
public static readonly Knob AgentDiagLogPath = new Knob(
nameof(AgentDiagLogPath),
Expand Down
14 changes: 6 additions & 8 deletions src/Agent.Worker/TestResults/Utils/TestResultUtils.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Agent.Sdk.Knob;
using System;
using Microsoft.TeamFoundation.TestClient.PublishTestResults;
using Microsoft.TeamFoundation.TestManagement.WebApi;
using Microsoft.VisualStudio.Services.WebApi;
using Microsoft.TeamFoundation.Core.WebApi;
using System.Linq;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

Expand All @@ -19,6 +12,11 @@ internal static class TestResultUtils
{
public static void StoreTestRunSummaryInEnvVar(IExecutionContext executionContext, TestRunSummary testRunSummary, string testRunner, string name, string description = "")
{
if (AgentKnobs.DisableTestsMetadata.GetValue(executionContext).AsBoolean())
{
return;
}

try
{
string metadata = GetEvidenceStoreMetadata(executionContext, testRunSummary, testRunner, name, description);
Expand Down

0 comments on commit 98c5172

Please sign in to comment.