Skip to content

Commit

Permalink
Skip product header check in buggy versions (elastic#84210)
Browse files Browse the repository at this point in the history
In elastic#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 elastic#84038
and elastic#84089. With this commit we skip the new assertion in the
known-buggy versions.

Closes elastic#84036 again.
  • Loading branch information
DaveCTurner authored and probakowski committed Feb 23, 2022
1 parent 0eefaf8 commit 4d2817e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public class ClientYamlTestClient implements Closeable {
this.clientBuilderWithSniffedNodes = clientBuilderWithSniffedNodes;
}

/**
* @return the version of the oldest node in the cluster
*/
public Version getEsVersion() {
return esVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public Stash stash() {
}

/**
* Returns the current es version as a string
* @return the version of the oldest node in the cluster
*/
public Version esVersion() {
return clientYamlTestClient.getEsVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,13 @@ public void execute(ClientYamlTestExecutionContext executionContext) throws IOEx
final String testPath = executionContext.getClientYamlTestCandidate() != null
? executionContext.getClientYamlTestCandidate().getTestPath()
: null;
checkElasticProductHeader(response.getHeaders("X-elastic-product"));
if (executionContext.esVersion().after(Version.V_8_1_0)
|| (executionContext.esVersion().major == Version.V_7_17_0.major && executionContext.esVersion().after(Version.V_7_17_1))) {
// #84038 and #84089 mean that this assertion fails when running against a small number of released versions, but at time of
// writing it's unclear exactly which released versions will contain the fix.
// TODO once a fixed version has been released, adjust the condition above to match.
checkElasticProductHeader(response.getHeaders("X-elastic-product"));
}
checkWarningHeaders(response.getWarningHeaders(), testPath);
} catch (ClientYamlTestResponseException e) {
ClientYamlTestResponse restTestResponse = e.getRestTestResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.elasticsearch.client.NodeSelector;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.logging.HeaderWarning;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.test.rest.yaml.ClientYamlTestExecutionContext;
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
import org.elasticsearch.xcontent.XContentLocation;
Expand Down Expand Up @@ -605,6 +606,7 @@ public void testNodeSelectorByVersion() throws IOException {
doSection.getApiCallSection().getNodeSelector()
)
).thenReturn(mockResponse);
when(context.esVersion()).thenReturn(VersionUtils.randomVersion(random()));
when(mockResponse.getHeaders("X-elastic-product")).thenReturn(List.of("Elasticsearch"));
doSection.execute(context);
verify(context).callApi(
Expand Down

0 comments on commit 4d2817e

Please sign in to comment.