Move Location of Experiments Call to CD Internal (#720)
* moved location of call to experiments to CD internal * updated tests * updated to call finishasync in CD * updated * update documentation * updated * Update DetectorProcessingServiceTests.cs * syntax * updated tests * updated * updated * updated * updated * updated * updated * updated * updated * added test * added tests * updated tests * updated tests * Update DetectorProcessingService.cs --------- Co-authored-by: Amitla Vannikumar <avannikumar@microsoft.com>
This commit is contained in:
Родитель
0bfe4bab05
Коммит
74fae320e1
|
@ -7,6 +7,11 @@ using System;
|
|||
/// </summary>
|
||||
public static class DetectorExperiments
|
||||
{
|
||||
/// <summary>
|
||||
/// Check to automatically proccess experiments.
|
||||
/// </summary>
|
||||
public static bool AutomaticallyProcessExperiments { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Manually enables detector experiments.
|
||||
/// </summary>
|
||||
|
|
|
@ -116,6 +116,11 @@ public class ExperimentService : IExperimentService
|
|||
return;
|
||||
}
|
||||
|
||||
if (!DetectorExperiments.AutomaticallyProcessExperiments)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var (config, experiment) in this.experiments)
|
||||
{
|
||||
var controlComponents = experiment.ControlGroupComponents;
|
||||
|
|
|
@ -55,7 +55,11 @@ public class ExperimentServiceTests
|
|||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void EnableDetectorExperiments() => DetectorExperiments.Enable = true;
|
||||
public void TestInitialize()
|
||||
{
|
||||
DetectorExperiments.Enable = true;
|
||||
DetectorExperiments.AutomaticallyProcessExperiments = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RecordDetectorRun_AddsComponentsToControlAndExperimentGroup()
|
||||
|
@ -195,6 +199,48 @@ public class ExperimentServiceTests
|
|||
Times.Never());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task FinishAsync_AutomaticallyProcessesExperimentsAsync()
|
||||
{
|
||||
var components = ExperimentTestUtils.CreateRandomComponents();
|
||||
this.SetupGraphMock(components);
|
||||
|
||||
var service = new ExperimentService(
|
||||
new[] { this.experimentConfigMock.Object },
|
||||
new[] { this.experimentProcessorMock.Object },
|
||||
this.graphTranslationServiceMock.Object,
|
||||
this.loggerMock.Object);
|
||||
service.RecordDetectorRun(this.detectorMock.Object, this.componentRecorder, this.detectionArgsMock.Object);
|
||||
|
||||
await service.FinishAsync();
|
||||
|
||||
this.experimentProcessorMock.Verify(
|
||||
x => x.ProcessExperimentAsync(this.experimentConfigMock.Object, It.IsAny<ExperimentDiff>()),
|
||||
Times.Once());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task FinishAsync_DoesNotAutomaticallyProcessExperimentsAsync()
|
||||
{
|
||||
DetectorExperiments.AutomaticallyProcessExperiments = false;
|
||||
|
||||
var components = ExperimentTestUtils.CreateRandomComponents();
|
||||
this.SetupGraphMock(components);
|
||||
|
||||
var service = new ExperimentService(
|
||||
new[] { this.experimentConfigMock.Object },
|
||||
new[] { this.experimentProcessorMock.Object },
|
||||
this.graphTranslationServiceMock.Object,
|
||||
this.loggerMock.Object);
|
||||
service.RecordDetectorRun(this.detectorMock.Object, this.componentRecorder, this.detectionArgsMock.Object);
|
||||
|
||||
await service.FinishAsync();
|
||||
|
||||
this.experimentProcessorMock.Verify(
|
||||
x => x.ProcessExperimentAsync(this.experimentConfigMock.Object, It.IsAny<ExperimentDiff>()),
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task FinishAsync_Respects_DetectorExperiments_EnableAsync()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче