From 98c5172dda3fa8ae591aaaec07529fcfb119c83b Mon Sep 17 00:00:00 2001 From: Denis Rumyantsev Date: Tue, 21 Mar 2023 06:16:02 +0100 Subject: [PATCH] add ability to disable publishing tests metadata --- src/Agent.Sdk/Knob/AgentKnobs.cs | 7 +++++++ .../TestResults/Utils/TestResultUtils.cs | 14 ++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Agent.Sdk/Knob/AgentKnobs.cs b/src/Agent.Sdk/Knob/AgentKnobs.cs index f85e25ae8f..ea560b82cc 100644 --- a/src/Agent.Sdk/Knob/AgentKnobs.cs +++ b/src/Agent.Sdk/Knob/AgentKnobs.cs @@ -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), diff --git a/src/Agent.Worker/TestResults/Utils/TestResultUtils.cs b/src/Agent.Worker/TestResults/Utils/TestResultUtils.cs index 50c6e4543c..5794409a42 100644 --- a/src/Agent.Worker/TestResults/Utils/TestResultUtils.cs +++ b/src/Agent.Worker/TestResults/Utils/TestResultUtils.cs @@ -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; @@ -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);