Skip to content

Commit e77cec9

Browse files
committed
Merge branch 'develop' of github.com:elasticsearch/elasticsearch-net into develop
2 parents 81e6401 + bfeebe2 commit e77cec9

File tree

9 files changed

+61
-28
lines changed

9 files changed

+61
-28
lines changed

src/Tests/Nest.Tests.Integration/Aggregations/BucketAggregationTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void Terms()
2424
}
2525

2626
[Test]
27-
[SkipVersion("1.0", "Significant terms aggregation not introduced until 1.1")]
27+
[SkipVersion("0 - 1.0.9", "Significant terms aggregation not introduced until 1.1")]
2828
public void SignificantTerms()
2929
{
3030
var results = this._client.Search<ElasticsearchProject>(s => s
@@ -84,7 +84,7 @@ public void Histogram()
8484
}
8585

8686
[Test]
87-
[SkipVersion("1.0", "Percentiles aggregation not introduced until 1.1")]
87+
[SkipVersion("0 - 1.0.9", "Percentiles aggregation not introduced until 1.1")]
8888
public void Percentiles()
8989
{
9090
var results = this._client.Search<ElasticsearchProject>(s => s
@@ -108,7 +108,7 @@ public void Percentiles()
108108
}
109109

110110
[Test]
111-
[SkipVersion("1.0", "Percentiles aggregation not introduced until 1.1")]
111+
[SkipVersion("0 - 1.0.9", "Percentiles aggregation not introduced until 1.1")]
112112
public void PercentilesCustom()
113113
{
114114
var results = this._client.Search<ElasticsearchProject>(s => s

src/Tests/Nest.Tests.Integration/Aggregations/MetricAggregationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void Min()
5656
}
5757

5858
[Test]
59-
[SkipVersion("1.0", "Cardinality aggregation not introduced until 1.1")]
59+
[SkipVersion("0 - 1.0.9", "Cardinality aggregation not introduced until 1.1")]
6060
public void Cardinality()
6161
{
6262
var results = this._client.Search<ElasticsearchProject>(s => s

src/Tests/Nest.Tests.Integration/Attributes/SkipVersionAttribute.cs

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,56 @@ namespace Nest.Tests.Integration
99
{
1010
public class SkipVersionAttribute : TestActionAttribute
1111
{
12-
private string _Version;
13-
private string _Reason;
14-
15-
public SkipVersionAttribute(string version)
16-
: this(version, null)
12+
private Version _lowerBound;
13+
private Version _upperBound;
14+
private string _reason;
15+
private bool _inclusive;
16+
17+
public SkipVersionAttribute(string range, string reason, bool inclusive = true)
1718
{
19+
_reason = reason;
20+
_inclusive = inclusive;
21+
22+
ParseVersions(range);
1823
}
1924

20-
public SkipVersionAttribute(string version, string reason)
25+
public override void BeforeTest(TestDetails testDetails)
2126
{
22-
_Version = version;
23-
_Reason = reason;
27+
var currentVersion = ElasticsearchConfiguration.CurrentVersion;
28+
29+
var skip =
30+
(_inclusive && _upperBound >= currentVersion && currentVersion >= _lowerBound) ||
31+
(_upperBound > currentVersion && currentVersion > _lowerBound);
32+
33+
if (skip)
34+
Assert.Pass(_reason);
2435
}
2536

26-
public override void BeforeTest(TestDetails testDetails)
37+
private void ParseVersions(string range)
2738
{
28-
if (ElasticsearchConfiguration.CurrentVersion.Contains(_Version))
29-
{
30-
Assert.Pass(_Reason);
31-
}
39+
var bounds = range.Split('-').ToList();
40+
if (bounds.Count > 2)
41+
throw new ArgumentException("Failed to skip test: invalid range");
42+
43+
_lowerBound = Version.Parse(NormalizeVersion(bounds[0]));
44+
45+
var upperBound = bounds.Count == 2 ? bounds[1] : bounds[0];
46+
_upperBound = Version.Parse(NormalizeVersion(upperBound));
47+
}
48+
49+
private string NormalizeVersion(string version)
50+
{
51+
var format = "{0}.{1}.{2}";
52+
var versionParts = version.Split('.').ToList();
53+
54+
if (versionParts.Count == 1)
55+
return string.Format(format, versionParts[0], 0, 0);
56+
else if (versionParts.Count == 2)
57+
return string.Format(format, versionParts[0], versionParts[1], 0);
58+
else if (versionParts.Count == 3)
59+
return string.Format(format, versionParts[0], versionParts[1], versionParts[2]);
60+
else
61+
throw new ArgumentException("Failed to skip test: invalid version format");
3262
}
3363
}
3464
}

src/Tests/Nest.Tests.Integration/Core/ClearScroll/ClearScrollTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ namespace Nest.Tests.Integration.Core.ClearScroll
1111
public class ClearScrollTests : IntegrationTests
1212
{
1313
[Test]
14-
[SkipVersion("1.0.2", "Scroll ids were not accepted in the request body until 1.0.3 (https://github.com/elasticsearch/elasticsearch/issues/5726)")]
14+
[SkipVersion("0 - 1.0.2", "Scroll ids were not accepted in the request body until 1.0.3 (https://github.com/elasticsearch/elasticsearch/issues/5726)")]
15+
[SkipVersion("1.1.0", "Scroll ids in request body broken in 1.1.0 and fixed in 1.1.1")]
1516
public void ClearScroll()
1617
{
1718
var searchResults = this._client.Search<ElasticsearchProject>(s => s.Scroll("1m").SearchType(SearchType.Scan));

src/Tests/Nest.Tests.Integration/Core/TermVectors/MultiTermVectorsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void MultiTermVectorsTest_DocumentsInBody()
5656
}
5757

5858
[Test]
59-
[SkipVersion("1.2", "Fails against ES 1.2: https://github.com/elasticsearch/elasticsearch/issues/6451")]
59+
[SkipVersion("1.2.0 - 1.2.2", "Fails against ES 1.2: https://github.com/elasticsearch/elasticsearch/issues/6451")]
6060
public void MultiTermVectorsNonExistentIdTest()
6161
{
6262
var result = _client.MultiTermVectors<ElasticsearchProject>(s => s

src/Tests/Nest.Tests.Integration/Core/TermVectors/TermVectorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void TermVectorNonMappedFieldTest()
9191
}
9292

9393
[Test]
94-
[SkipVersion("1.2", "Fails against ES 1.2: https://github.com/elasticsearch/elasticsearch/issues/6451")]
94+
[SkipVersion("1.2.0 - 1.2.2", "Fails against ES 1.2: https://github.com/elasticsearch/elasticsearch/issues/6451")]
9595
public void TermVectorNonExistentIdTest()
9696
{
9797
var result = _client.TermVector<ElasticsearchProject>(s => s

src/Tests/Nest.Tests.Integration/ElasticsearchConfiguration.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ public static class ElasticsearchConfiguration
99
{
1010
public static readonly string DefaultIndex = Test.Default.DefaultIndex + "-" + Process.GetCurrentProcess().Id.ToString();
1111

12-
private static string _currentVersion;
13-
public static string CurrentVersion
12+
private static Version _currentVersion;
13+
public static Version CurrentVersion
1414
{
1515
get
1616
{
17-
if (string.IsNullOrEmpty(_currentVersion))
17+
if (_currentVersion == null)
1818
_currentVersion = GetCurrentVersion();
1919

2020
return _currentVersion;
@@ -48,10 +48,12 @@ public static string NewUniqueIndexName()
4848
return DefaultIndex + "_" + Guid.NewGuid().ToString();
4949
}
5050

51-
public static string GetCurrentVersion()
51+
public static Version GetCurrentVersion()
5252
{
5353
dynamic info = Client.Raw.Info().Response;
54-
return info.version.number;
54+
var version = Version.Parse(info.version.number);
55+
56+
return version;
5557
}
5658
}
5759
}

src/Tests/Nest.Tests.Integration/Indices/AliasTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void SimpleRenameAlias()
111111
}
112112

113113
[Test]
114-
[SkipVersion("1.0", "Adding aliases during index creation not introduced until 1.1")]
114+
[SkipVersion("0 - 1.0.9", "Adding aliases during index creation not introduced until 1.1")]
115115
public void AddAliasFromCreateIndex()
116116
{
117117
var indexName = ElasticsearchConfiguration.NewUniqueIndexName();

src/Tests/Nest.Tests.Integration/Indices/OpenCloseTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public void CloseAndSearchAndOpenIndex()
4545

4646
var error = results.ServerError;
4747
error.Should().NotBeNull();
48-
error.ExceptionType.Should().Be("ClusterBlockException");
49-
error.Error.Should().Contain("index closed");
48+
error.ExceptionType.Should().BeOneOf("ClusterBlockException", "IndexClosedException");
49+
error.Error.Should().Contain("closed");
5050

5151
r = this._client.OpenIndex(ElasticsearchConfiguration.DefaultIndex);
5252
Assert.True(r.Acknowledged);

0 commit comments

Comments
 (0)