Skip to content

Commit

Permalink
Restrict Tests run in Pipeline (#735)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
gfs authored Feb 13, 2025
1 parent e25033d commit 7b4cc43
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 22 deletions.
3 changes: 2 additions & 1 deletion Pipelines/asa-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resources:
- repository: templates
type: git
name: SecurityEngineering/OSS-Tools-Pipeline-Templates
ref: refs/tags/v2.0.0
ref: refs/tags/v2.0.1
- repository: 1esPipelines
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
Expand Down Expand Up @@ -52,6 +52,7 @@ extends:
poolImage: MSSecurity-1ES-Windows-2022
poolOs: windows
projectPath: 'Tests/Tests.csproj'
dotnetTestArgs: '--filter TestCategory=PipelineSafeTests'

- stage: Build
dependsOn: Test
Expand Down
4 changes: 3 additions & 1 deletion Pipelines/asa-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resources:
- repository: templates
type: git
name: Data/OSS-Tools-Pipeline-Templates
ref: refs/tags/v2.0.0
ref: refs/tags/v2.0.1
- repository: 1esPipelines
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
Expand Down Expand Up @@ -42,6 +42,8 @@ extends:
poolImage: MSSecurity-1ES-Windows-2022
poolOs: windows
projectPath: 'Tests/Tests.csproj'
dotnetTestArgs: '--filter TestCategory=PipelineSafeTests'

- stage: Build
dependsOn: Test
jobs:
Expand Down
2 changes: 1 addition & 1 deletion Tests/AsaAnalyzerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests
{
[TestClass]
[TestClass, TestCategory("PipelineSafeTests")]
public class AsaAnalyzerTests
{
public AsaAnalyzerTests()
Expand Down
1 change: 0 additions & 1 deletion Tests/CollectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ public void TestServiceCollectorWindows()
/// <summary>
/// Requires Admin
/// </summary>
[Ignore]
[TestMethod]
public void TestTpmCollector()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/DiffTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests;
/// <summary>
/// Test that the compare logic generates the correct diffs for various object configurations
/// </summary>
[TestClass]
[TestClass, TestCategory("PipelineSafeTests")]
public class DiffTests
{
[DataRow("owner1", "owner2", 1)]
Expand Down
2 changes: 1 addition & 1 deletion Tests/ExportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests
{
[TestClass]
[TestClass, TestCategory("PipelineSafeTests")]
public class ExportTests
{
[ClassInitialize]
Expand Down
2 changes: 1 addition & 1 deletion Tests/HydrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests
{
[TestClass]
[TestClass, TestCategory("PipelineSafeTests")]
public class HydrationTests
{
[ClassInitialize]
Expand Down
2 changes: 1 addition & 1 deletion Tests/InMemoryComparatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests
{
[TestClass]
[TestClass, TestCategory("PipelineSafeTests")]
public class InMemoryComparatorTests
{
[ClassInitialize]
Expand Down
15 changes: 1 addition & 14 deletions Tests/RuleFileTests.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License.
using Microsoft.CST.AttackSurfaceAnalyzer.Collectors;
using Microsoft.CST.AttackSurfaceAnalyzer.Objects;
using Microsoft.CST.AttackSurfaceAnalyzer.Types;
using Microsoft.CST.AttackSurfaceAnalyzer.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Win32;
using Serilog;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Threading;
using Tpm2Lib;
using WindowsFirewallHelper;

namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests
{
[TestClass]
[TestClass, TestCategory("PipelineSafeTests")]
public class RuleFileTests
{
[ClassInitialize]
Expand Down

0 comments on commit 7b4cc43

Please sign in to comment.