Skip to content

Commit b083b92

Browse files
committed
Include npm and pip detectors in experiment
1 parent 871162c commit b083b92

File tree

2 files changed

+129
-1
lines changed

2 files changed

+129
-1
lines changed

src/Microsoft.ComponentDetection.Orchestrator/Experiments/Configs/LinuxApplicationLayerExperiment.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ namespace Microsoft.ComponentDetection.Orchestrator.Experiments.Configs;
22

33
using Microsoft.ComponentDetection.Contracts;
44
using Microsoft.ComponentDetection.Detectors.Linux;
5+
using Microsoft.ComponentDetection.Detectors.Npm;
6+
using Microsoft.ComponentDetection.Detectors.Pip;
57

68
/// <summary>
79
/// Experiment to validate the <see cref="LinuxApplicationLayerDetector"/> which captures application-level
810
/// packages in addition to system packages from Linux containers.
11+
/// Control group includes the standard file-based npm and pip detectors plus the Linux system package detector.
12+
/// Experiment group uses container-based detection for all package types together.
913
/// </summary>
1014
public class LinuxApplicationLayerExperiment : IExperimentConfiguration
1115
{
@@ -14,7 +18,11 @@ public class LinuxApplicationLayerExperiment : IExperimentConfiguration
1418

1519
/// <inheritdoc />
1620
public bool IsInControlGroup(IComponentDetector componentDetector) =>
17-
componentDetector is LinuxContainerDetector and not LinuxApplicationLayerDetector;
21+
componentDetector
22+
is (LinuxContainerDetector and not LinuxApplicationLayerDetector)
23+
or NpmComponentDetector
24+
or NpmLockfileDetectorBase
25+
or PipReportComponentDetector;
1826

1927
/// <inheritdoc />
2028
public bool IsInExperimentGroup(IComponentDetector componentDetector) =>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
namespace Microsoft.ComponentDetection.Orchestrator.Tests.Experiments;
2+
3+
using AwesomeAssertions;
4+
using Microsoft.ComponentDetection.Detectors.Linux;
5+
using Microsoft.ComponentDetection.Detectors.Npm;
6+
using Microsoft.ComponentDetection.Detectors.Pip;
7+
using Microsoft.ComponentDetection.Orchestrator.Experiments.Configs;
8+
using Microsoft.VisualStudio.TestTools.UnitTesting;
9+
10+
[TestClass]
11+
public class LinuxApplicationLayerExperimentTests
12+
{
13+
private readonly LinuxApplicationLayerExperiment experiment = new();
14+
15+
[TestMethod]
16+
public void IsInControlGroup_LinuxContainerDetector_ReturnsTrue()
17+
{
18+
var linuxDetector = new LinuxContainerDetector(null, null, null);
19+
this.experiment.IsInControlGroup(linuxDetector).Should().BeTrue();
20+
}
21+
22+
[TestMethod]
23+
public void IsInControlGroup_NpmComponentDetector_ReturnsTrue()
24+
{
25+
var npmDetector = new NpmComponentDetector(null, null, null);
26+
this.experiment.IsInControlGroup(npmDetector).Should().BeTrue();
27+
}
28+
29+
[TestMethod]
30+
public void IsInControlGroup_NpmLockfile3Detector_ReturnsTrue()
31+
{
32+
var npmLockfile3Detector = new NpmLockfile3Detector(null, null, null, null);
33+
this.experiment.IsInControlGroup(npmLockfile3Detector).Should().BeTrue();
34+
}
35+
36+
[TestMethod]
37+
public void IsInControlGroup_NpmComponentDetectorWithRoots_ReturnsTrue()
38+
{
39+
var npmDetectorWithRoots = new NpmComponentDetectorWithRoots(null, null, null, null);
40+
this.experiment.IsInControlGroup(npmDetectorWithRoots).Should().BeTrue();
41+
}
42+
43+
[TestMethod]
44+
public void IsInControlGroup_PipReportComponentDetector_ReturnsTrue()
45+
{
46+
var pipDetector = new PipReportComponentDetector(
47+
null,
48+
null,
49+
null,
50+
null,
51+
null,
52+
null,
53+
null,
54+
null,
55+
null
56+
);
57+
58+
this.experiment.IsInControlGroup(pipDetector).Should().BeTrue();
59+
}
60+
61+
[TestMethod]
62+
public void IsInControlGroup_LinuxApplicationLayerDetector_ReturnsFalse()
63+
{
64+
var experimentalDetector = new LinuxApplicationLayerDetector(null, null, null);
65+
this.experiment.IsInControlGroup(experimentalDetector).Should().BeFalse();
66+
}
67+
68+
[TestMethod]
69+
public void IsInExperimentGroup_LinuxApplicationLayerDetector_ReturnsTrue()
70+
{
71+
var experimentalDetector = new LinuxApplicationLayerDetector(null, null, null);
72+
this.experiment.IsInExperimentGroup(experimentalDetector).Should().BeTrue();
73+
}
74+
75+
[TestMethod]
76+
public void IsInExperimentGroup_LinuxContainerDetector_ReturnsFalse()
77+
{
78+
var linuxDetector = new LinuxContainerDetector(null, null, null);
79+
this.experiment.IsInExperimentGroup(linuxDetector).Should().BeFalse();
80+
}
81+
82+
[TestMethod]
83+
public void IsInExperimentGroup_NpmComponentDetector_ReturnsFalse()
84+
{
85+
var npmDetector = new NpmComponentDetector(null, null, null);
86+
this.experiment.IsInExperimentGroup(npmDetector).Should().BeFalse();
87+
}
88+
89+
[TestMethod]
90+
public void IsInExperimentGroup_NpmLockfile3Detector_ReturnsFalse()
91+
{
92+
var npmLockfile3Detector = new NpmLockfile3Detector(null, null, null, null);
93+
this.experiment.IsInExperimentGroup(npmLockfile3Detector).Should().BeFalse();
94+
}
95+
96+
[TestMethod]
97+
public void IsInExperimentGroup_NpmComponentDetectorWithRoots_ReturnsFalse()
98+
{
99+
var npmDetectorWithRoots = new NpmComponentDetectorWithRoots(null, null, null, null);
100+
this.experiment.IsInExperimentGroup(npmDetectorWithRoots).Should().BeFalse();
101+
}
102+
103+
[TestMethod]
104+
public void IsInExperimentGroup_PipReportComponentDetector_ReturnsFalse()
105+
{
106+
var pipDetector = new PipReportComponentDetector(
107+
null,
108+
null,
109+
null,
110+
null,
111+
null,
112+
null,
113+
null,
114+
null,
115+
null
116+
);
117+
118+
this.experiment.IsInExperimentGroup(pipDetector).Should().BeFalse();
119+
}
120+
}

0 commit comments

Comments
 (0)