Skip to content

Commit 93a1756

Browse files
committed
Delete jobs in teardown
This commit deletes jobs created in the PutJob integration test as part of integration test teardown
1 parent 3571b57 commit 93a1756

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Tests/XPack/MachineLearning/MachineLearningIntegrationTestBase.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ protected IPutJobResponse PutJob(IElasticClient client, string jobId)
3636
return putJobResponse;
3737
}
3838

39+
protected IDeleteJobResponse DeleteJob(IElasticClient client, string jobId)
40+
{
41+
var deleteJobResponse = client.DeleteJob(jobId);
42+
if (!deleteJobResponse.IsValid || deleteJobResponse.Acknowledged == false)
43+
throw new Exception($"Problem deleting job {jobId} for integration test: {deleteJobResponse.DebugInformation}");
44+
return deleteJobResponse;
45+
}
46+
3947
protected IOpenJobResponse OpenJob(IElasticClient client, string jobId)
4048
{
4149
var openJobResponse = client.OpenJob(jobId);

src/Tests/XPack/MachineLearning/PutJob/PutJobApiTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ protected override LazyResponses ClientUsage() => Calls(
2222
requestAsync: (client, r) => client.PutJobAsync(r)
2323
);
2424

25+
protected override void IntegrationTeardown(IElasticClient client, CallUniqueValues values)
26+
{
27+
foreach (var callUniqueValue in values.Values)
28+
{
29+
DeleteJob(client, callUniqueValue);
30+
}
31+
}
32+
2533
protected override bool ExpectIsValid => true;
2634
protected override int ExpectStatusCode => 200;
2735
protected override HttpMethod HttpMethod => HttpMethod.PUT;

0 commit comments

Comments
 (0)