Skip to content

Commit 7b4cc43

Browse files
authored
Restrict Tests run in Pipeline (#735)
* Add Category for Pipeline Safe Tests (i.e. non-collector integration tests), to improve pipeline reliability. * Remove unused usings from RuleFileTests.cs. * Update pipelines to use the `PipelineSafeTests` category to select test executions.
1 parent e25033d commit 7b4cc43

File tree

9 files changed

+11
-22
lines changed

9 files changed

+11
-22
lines changed

Pipelines/asa-pr.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ resources:
2222
- repository: templates
2323
type: git
2424
name: SecurityEngineering/OSS-Tools-Pipeline-Templates
25-
ref: refs/tags/v2.0.0
25+
ref: refs/tags/v2.0.1
2626
- repository: 1esPipelines
2727
type: git
2828
name: 1ESPipelineTemplates/1ESPipelineTemplates
@@ -52,6 +52,7 @@ extends:
5252
poolImage: MSSecurity-1ES-Windows-2022
5353
poolOs: windows
5454
projectPath: 'Tests/Tests.csproj'
55+
dotnetTestArgs: '--filter TestCategory=PipelineSafeTests'
5556

5657
- stage: Build
5758
dependsOn: Test

Pipelines/asa-release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ resources:
77
- repository: templates
88
type: git
99
name: Data/OSS-Tools-Pipeline-Templates
10-
ref: refs/tags/v2.0.0
10+
ref: refs/tags/v2.0.1
1111
- repository: 1esPipelines
1212
type: git
1313
name: 1ESPipelineTemplates/1ESPipelineTemplates
@@ -42,6 +42,8 @@ extends:
4242
poolImage: MSSecurity-1ES-Windows-2022
4343
poolOs: windows
4444
projectPath: 'Tests/Tests.csproj'
45+
dotnetTestArgs: '--filter TestCategory=PipelineSafeTests'
46+
4547
- stage: Build
4648
dependsOn: Test
4749
jobs:

Tests/AsaAnalyzerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests
1111
{
12-
[TestClass]
12+
[TestClass, TestCategory("PipelineSafeTests")]
1313
public class AsaAnalyzerTests
1414
{
1515
public AsaAnalyzerTests()

Tests/CollectorTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ public void TestServiceCollectorWindows()
429429
/// <summary>
430430
/// Requires Admin
431431
/// </summary>
432-
[Ignore]
433432
[TestMethod]
434433
public void TestTpmCollector()
435434
{

Tests/DiffTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests;
1010
/// <summary>
1111
/// Test that the compare logic generates the correct diffs for various object configurations
1212
/// </summary>
13-
[TestClass]
13+
[TestClass, TestCategory("PipelineSafeTests")]
1414
public class DiffTests
1515
{
1616
[DataRow("owner1", "owner2", 1)]

Tests/ExportTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests
1212
{
13-
[TestClass]
13+
[TestClass, TestCategory("PipelineSafeTests")]
1414
public class ExportTests
1515
{
1616
[ClassInitialize]

Tests/HydrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests
99
{
10-
[TestClass]
10+
[TestClass, TestCategory("PipelineSafeTests")]
1111
public class HydrationTests
1212
{
1313
[ClassInitialize]

Tests/InMemoryComparatorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests
1212
{
13-
[TestClass]
13+
[TestClass, TestCategory("PipelineSafeTests")]
1414
public class InMemoryComparatorTests
1515
{
1616
[ClassInitialize]

Tests/RuleFileTests.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License.
2-
using Microsoft.CST.AttackSurfaceAnalyzer.Collectors;
32
using Microsoft.CST.AttackSurfaceAnalyzer.Objects;
43
using Microsoft.CST.AttackSurfaceAnalyzer.Types;
54
using Microsoft.CST.AttackSurfaceAnalyzer.Utils;
65
using Microsoft.VisualStudio.TestTools.UnitTesting;
7-
using Microsoft.Win32;
8-
using Serilog;
96
using System;
10-
using System.Collections.Concurrent;
11-
using System.Collections.Generic;
12-
using System.Diagnostics;
13-
using System.IO;
147
using System.Linq;
15-
using System.Net;
16-
using System.Net.Sockets;
17-
using System.Runtime.InteropServices;
18-
using System.Threading;
19-
using Tpm2Lib;
20-
using WindowsFirewallHelper;
218

229
namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests
2310
{
24-
[TestClass]
11+
[TestClass, TestCategory("PipelineSafeTests")]
2512
public class RuleFileTests
2613
{
2714
[ClassInitialize]

0 commit comments

Comments
 (0)