Skip to content

Commit 1467939

Browse files
authored
Change default ModelSnapshotRetentionDays (#4792)
This commit fixes assertions on ModelSnapshotRetentionDays as the default days has changed from 1 to 10.
1 parent 185d185 commit 1467939

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

tests/Tests/XPack/MachineLearning/GetJobs/GetJobsApiTests.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5-
using System;
5+
using System;
66
using System.Linq;
77
using Elasticsearch.Net;
88
using FluentAssertions;
99
using Nest;
10+
using Tests.Core.Client;
1011
using Tests.Core.Extensions;
1112
using Tests.Framework.EndpointTests.TestState;
1213

@@ -65,7 +66,9 @@ protected override void ExpectResponse(GetJobsResponse response)
6566
response.Jobs.First().DataDescription.TimeField.Name.Should().Be("@timestamp");
6667
response.Jobs.First().DataDescription.TimeFormat.Should().Be("epoch_ms");
6768

68-
response.Jobs.First().ModelSnapshotRetentionDays.Should().Be(1);
69+
response.Jobs.First().ModelSnapshotRetentionDays.Should().Be(TestClient.Configuration.InRange(">=7.8.0")
70+
? 10
71+
: 1);
6972
response.Jobs.First().ResultsIndexName.Should().Be("shared");
7073
}
7174
}
@@ -123,7 +126,9 @@ protected override void ExpectResponse(GetJobsResponse response)
123126
response.Jobs.First().DataDescription.TimeField.Name.Should().Be("@timestamp");
124127
response.Jobs.First().DataDescription.TimeFormat.Should().Be("epoch_ms");
125128

126-
response.Jobs.First().ModelSnapshotRetentionDays.Should().Be(1);
129+
response.Jobs.First().ModelSnapshotRetentionDays.Should().Be(TestClient.Configuration.InRange(">=7.8.0")
130+
? 10
131+
: 1);
127132
response.Jobs.First().ResultsIndexName.Should().Be("shared");
128133
}
129134
}

tests/Tests/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoApiTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5-
using System;
5+
using System;
66
using Elasticsearch.Net;
77
using FluentAssertions;
88
using Nest;
9+
using Tests.Core.Client;
910
using Tests.Core.Extensions;
1011
using Tests.Framework.EndpointTests.TestState;
1112

@@ -41,7 +42,10 @@ protected override void ExpectResponse(MachineLearningInfoResponse response)
4142
var anomalyDetectors = response.Defaults.AnomalyDetectors;
4243
anomalyDetectors.ModelMemoryLimit.Should().Be("1gb");
4344
anomalyDetectors.CategorizationExamplesLimit.Should().Be(4);
44-
anomalyDetectors.ModelSnapshotRetentionDays.Should().Be(1);
45+
46+
anomalyDetectors.ModelSnapshotRetentionDays.Should().Be(TestClient.Configuration.InRange(">=7.8.0")
47+
? 10
48+
: 1);
4549

4650
response.Defaults.Datafeeds.ScrollSize.Should().Be(1000);
4751

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5-
using System;
5+
using System;
66
using System.Collections.Generic;
77
using System.Linq;
88
using Elastic.Elasticsearch.Xunit.XunitPlumbing;
99
using Elasticsearch.Net;
1010
using FluentAssertions;
1111
using Nest;
12+
using Tests.Core.Client;
1213
using Tests.Core.Extensions;
1314
using Tests.Domain;
1415
using Tests.Framework.EndpointTests.TestState;
@@ -122,7 +123,9 @@ protected override void ExpectResponse(PutJobResponse response)
122123
response.DataDescription.TimeField.Name.Should().Be("@timestamp");
123124
response.DataDescription.TimeFormat.Should().Be("epoch_ms");
124125

125-
response.ModelSnapshotRetentionDays.Should().Be(1);
126+
response.ModelSnapshotRetentionDays.Should().Be(TestClient.Configuration.InRange(">=7.8.0")
127+
? 10
128+
: 1);
126129

127130
// User-defined names are prepended with "custom-" by X-Pack ML
128131
response.ResultsIndexName.Should().Be("custom-server-metrics");
@@ -205,6 +208,7 @@ public PutJobWithCustomRulesApiTests(MachineLearningCluster cluster, EndpointUsa
205208
protected override Func<PutJobDescriptor<Metric>, IPutJobRequest> Fluent => f => f
206209
.Description("Lab 1 - Simple example")
207210
.ResultsIndexName("server-metrics")
211+
.ModelSnapshotRetentionDays(1)
208212
.AnalysisConfig(a => a
209213
.BucketSpan("30m")
210214
.Latency("0s")
@@ -247,6 +251,7 @@ public PutJobWithCustomRulesApiTests(MachineLearningCluster cluster, EndpointUsa
247251
{
248252
Description = "Lab 1 - Simple example",
249253
ResultsIndexName = "server-metrics",
254+
ModelSnapshotRetentionDays = 1,
250255
AnalysisConfig = new AnalysisConfig
251256
{
252257
BucketSpan = "30m",

0 commit comments

Comments
 (0)