Skip to content

Commit 7f1bb33

Browse files
authored
Skip product header check in buggy versions (#84210) (#84240)
In #83290 we added an assertion that Elasticsearch returns the product header in every REST response. Unfortunately this isn't always the case, we found bugs in a couple of released versions and fixed them in #84038 and #84089. With this commit we skip the new assertion in the known-buggy versions. Closes #84036 again.
1 parent 0dc15b0 commit 7f1bb33

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/yaml/ClientYamlTestClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ public class ClientYamlTestClient implements Closeable {
8484
this.clientBuilderWithSniffedNodes = clientBuilderWithSniffedNodes;
8585
}
8686

87+
/**
88+
* @return the version of the oldest node in the cluster
89+
*/
8790
public Version getEsVersion() {
8891
return esVersion;
8992
}

test/framework/src/main/java/org/elasticsearch/test/rest/yaml/ClientYamlTestExecutionContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public Stash stash() {
206206
}
207207

208208
/**
209-
* Returns the current es version as a string
209+
* @return the version of the oldest node in the cluster
210210
*/
211211
public Version esVersion() {
212212
return clientYamlTestClient.getEsVersion();

test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,13 @@ public void execute(ClientYamlTestExecutionContext executionContext) throws IOEx
367367
final String testPath = executionContext.getClientYamlTestCandidate() != null
368368
? executionContext.getClientYamlTestCandidate().getTestPath()
369369
: null;
370-
checkElasticProductHeader(response.getHeaders("X-elastic-product"));
370+
if (executionContext.esVersion().after(Version.V_8_1_0)
371+
|| (executionContext.esVersion().major == Version.V_7_17_0.major && executionContext.esVersion().after(Version.V_7_17_1))) {
372+
// #84038 and #84089 mean that this assertion fails when running against a small number of released versions, but at time of
373+
// writing it's unclear exactly which released versions will contain the fix.
374+
// TODO once a fixed version has been released, adjust the condition above to match.
375+
checkElasticProductHeader(response.getHeaders("X-elastic-product"));
376+
}
371377
checkWarningHeaders(response.getWarningHeaders(), testPath);
372378
} catch (ClientYamlTestResponseException e) {
373379
ClientYamlTestResponse restTestResponse = e.getRestTestResponse();

test/framework/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.client.NodeSelector;
1515
import org.elasticsearch.common.ParsingException;
1616
import org.elasticsearch.common.logging.HeaderWarning;
17+
import org.elasticsearch.test.VersionUtils;
1718
import org.elasticsearch.test.rest.yaml.ClientYamlTestExecutionContext;
1819
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
1920
import org.elasticsearch.xcontent.XContentLocation;
@@ -605,6 +606,7 @@ public void testNodeSelectorByVersion() throws IOException {
605606
doSection.getApiCallSection().getNodeSelector()
606607
)
607608
).thenReturn(mockResponse);
609+
when(context.esVersion()).thenReturn(VersionUtils.randomVersion(random()));
608610
when(mockResponse.getHeaders("X-elastic-product")).thenReturn(List.of("Elasticsearch"));
609611
doSection.execute(context);
610612
verify(context).callApi(

0 commit comments

Comments
 (0)