Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Location of Experiments Call to CD Internal #720

Merged
merged 28 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,18 @@ private void FilterExperiments(IComponentDetector detector, int count)
}

/// <inheritdoc />
public async Task FinishAsync()
public async Task FinishAsync(bool shouldCheckAutomaticProcessFlag = false)
{
if (!DetectorExperiments.AreExperimentsEnabled)
{
return;
}

if (!shouldCheckAutomaticProcessFlag && !Orchestrator.AutomaticallyProcessExperiments)
{
return;
}

foreach (var (config, experiment) in this.experiments)
{
var controlComponents = experiment.ControlGroupComponents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public interface IExperimentService
/// Called when all detectors have finished executing. Processes the experiments and reports the results.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
amitla1 marked this conversation as resolved.
Show resolved Hide resolved
Task FinishAsync();
Task FinishAsync(bool shouldCheckAutomaticProcessFlag = false);
}
2 changes: 2 additions & 0 deletions src/Microsoft.ComponentDetection.Orchestrator/Orchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace Microsoft.ComponentDetection.Orchestrator;

public class Orchestrator
{
public const bool AutomaticallyProcessExperiments = false;
amitla1 marked this conversation as resolved.
Show resolved Hide resolved
amitla1 marked this conversation as resolved.
Show resolved Hide resolved

private static readonly bool IsLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

private readonly IServiceProvider serviceProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ public async Task<DetectorProcessingResult> ProcessDetectorsAsync(IDetectionArgu
record.DetectedComponentCount = detectedComponents.Count();
var dependencyGraphs = componentRecorder.GetDependencyGraphsByLocation().Values;
record.ExplicitlyReferencedComponentCount = dependencyGraphs.Select(dependencyGraph =>
{
return dependencyGraph.GetAllExplicitlyReferencedComponents();
})
{
return dependencyGraph.GetAllExplicitlyReferencedComponents();
})
.SelectMany(x => x)
.Distinct()
.Count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,19 +510,6 @@ public async Task ProcessDetectorsAsync_HandlesDetectorArgsAsync()
.And.Contain("arg3", "val3");
}

[TestMethod]
amitla1 marked this conversation as resolved.
Show resolved Hide resolved
public async Task ProcessDetectorsAsync_FinishesExperimentsAsync()
{
this.detectorsToUse = new[]
{
this.firstFileComponentDetectorMock.Object, this.secondFileComponentDetectorMock.Object,
};

await this.serviceUnderTest.ProcessDetectorsAsync(DefaultArgs, this.detectorsToUse, new DetectorRestrictions());

this.experimentServiceMock.Verify(x => x.FinishAsync(), Times.Once());
}

[TestMethod]
public async Task ProcessDetectorsAsync_RecordsDetectorRunsAsync()
{
Expand Down
Loading