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:
Amitla Vannikumar 2023-08-16 19:08:57 -07:00 коммит произвёл GitHub
Родитель 0bfe4bab05
Коммит 74fae320e1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 57 добавлений и 1 удалений

Просмотреть файл

@ -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()
{