Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Type removal] _type removal from tests of yaml tests #3406

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,9 @@ public void testParseTestSetupTeardownAndSections() throws Exception {
+ " indices.get_mapping:\n"
+ " index: test_index\n"
+ "\n"
+ " - match: {test_index.test_type.properties.text.type: string}\n"
+ " - match: {test_index.test_type.properties.text.analyzer: whitespace}\n"
+ " - match: {test_index.properties.text.type: string}\n"
+ " - match: {test_index.properties.text.analyzer: whitespace}\n"
+ "\n"
+ "---\n"
+ "\"Get type mapping - pre 6.0\":\n"
+ "\n"
+ " - skip:\n"
+ " version: \"6.0.0 - \"\n"
+ " reason: \"for newer versions the index name is always returned\"\n"
+ "\n"
+ " - do:\n"
+ " indices.get_mapping:\n"
+ " index: test_index\n"
+ " type: test_type\n"
+ "\n"
+ " - match: {test_type.properties.text.type: string}\n"
+ " - match: {test_type.properties.text.analyzer: whitespace}\n"
);

ClientYamlTestSuite restTestSuite = ClientYamlTestSuite.parse(getTestClass().getName(), getTestName(), parser);
Expand Down Expand Up @@ -135,7 +121,7 @@ public void testParseTestSetupTeardownAndSections() throws Exception {
assertThat(restTestSuite.getTeardownSection().isEmpty(), equalTo(true));
}

assertThat(restTestSuite.getTestSections().size(), equalTo(2));
assertThat(restTestSuite.getTestSections().size(), equalTo(1));

assertThat(restTestSuite.getTestSections().get(0).getName(), equalTo("Get index mapping"));
assertThat(restTestSuite.getTestSections().get(0).getSkipSection().isEmpty(), equalTo(true));
Expand All @@ -147,36 +133,13 @@ public void testParseTestSetupTeardownAndSections() throws Exception {
assertThat(doSection.getApiCallSection().getParams().get("index"), equalTo("test_index"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(1), instanceOf(MatchAssertion.class));
MatchAssertion matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(1);
assertThat(matchAssertion.getField(), equalTo("test_index.test_type.properties.text.type"));
assertThat(matchAssertion.getField(), equalTo("test_index.properties.text.type"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("string"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(2), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(2);
assertThat(matchAssertion.getField(), equalTo("test_index.test_type.properties.text.analyzer"));
assertThat(matchAssertion.getField(), equalTo("test_index.properties.text.analyzer"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("whitespace"));

assertThat(restTestSuite.getTestSections().get(1).getName(), equalTo("Get type mapping - pre 6.0"));
assertThat(restTestSuite.getTestSections().get(1).getSkipSection().isEmpty(), equalTo(false));
assertThat(
restTestSuite.getTestSections().get(1).getSkipSection().getReason(),
equalTo("for newer versions the index name is always returned")
);
assertThat(restTestSuite.getTestSections().get(1).getSkipSection().getLowerVersion(), equalTo(LegacyESVersion.fromString("6.0.0")));
assertThat(restTestSuite.getTestSections().get(1).getSkipSection().getUpperVersion(), equalTo(Version.CURRENT));
assertThat(restTestSuite.getTestSections().get(1).getExecutableSections().size(), equalTo(3));
assertThat(restTestSuite.getTestSections().get(1).getExecutableSections().get(0), instanceOf(DoSection.class));
doSection = (DoSection) restTestSuite.getTestSections().get(1).getExecutableSections().get(0);
assertThat(doSection.getApiCallSection().getApi(), equalTo("indices.get_mapping"));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(2));
assertThat(doSection.getApiCallSection().getParams().get("index"), equalTo("test_index"));
assertThat(doSection.getApiCallSection().getParams().get("type"), equalTo("test_type"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(1), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(1).getExecutableSections().get(1);
assertThat(matchAssertion.getField(), equalTo("test_type.properties.text.type"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("string"));
assertThat(restTestSuite.getTestSections().get(1).getExecutableSections().get(2), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(1).getExecutableSections().get(2);
assertThat(matchAssertion.getField(), equalTo("test_type.properties.text.analyzer"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("whitespace"));
}

public void testParseTestSingleTestSection() throws Exception {
Expand All @@ -188,24 +151,20 @@ public void testParseTestSingleTestSection() throws Exception {
+ " - do:\n"
+ " index:\n"
+ " index: test-weird-index-中文\n"
+ " type: weird.type\n"
+ " id: 1\n"
+ " body: { foo: bar }\n"
+ "\n"
+ " - is_true: ok\n"
+ " - match: { _index: test-weird-index-中文 }\n"
+ " - match: { _type: weird.type }\n"
+ " - match: { _id: \"1\"}\n"
+ " - match: { _version: 1}\n"
+ "\n"
+ " - do:\n"
+ " get:\n"
+ " index: test-weird-index-中文\n"
+ " type: weird.type\n"
+ " id: 1\n"
+ "\n"
+ " - match: { _index: test-weird-index-中文 }\n"
+ " - match: { _type: weird.type }\n"
+ " - match: { _id: \"1\"}\n"
+ " - match: { _version: 1}\n"
+ " - match: { _source: { foo: bar }}"
Expand All @@ -222,12 +181,12 @@ public void testParseTestSingleTestSection() throws Exception {

assertThat(restTestSuite.getTestSections().get(0).getName(), equalTo("Index with ID"));
assertThat(restTestSuite.getTestSections().get(0).getSkipSection().isEmpty(), equalTo(true));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().size(), equalTo(12));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().size(), equalTo(10));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(0), instanceOf(DoSection.class));
DoSection doSection = (DoSection) restTestSuite.getTestSections().get(0).getExecutableSections().get(0);
assertThat(doSection.getCatch(), nullValue());
assertThat(doSection.getApiCallSection().getApi(), equalTo("index"));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(3));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(2));
assertThat(doSection.getApiCallSection().hasBody(), equalTo(true));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(1), instanceOf(IsTrueAssertion.class));
IsTrueAssertion trueAssertion = (IsTrueAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(1);
Expand All @@ -238,40 +197,32 @@ public void testParseTestSingleTestSection() throws Exception {
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("test-weird-index-中文"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(3), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(3);
assertThat(matchAssertion.getField(), equalTo("_type"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("weird.type"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(4), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(4);
assertThat(matchAssertion.getField(), equalTo("_id"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("1"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(5), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(5);
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(4), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(4);
assertThat(matchAssertion.getField(), equalTo("_version"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("1"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(6), instanceOf(DoSection.class));
doSection = (DoSection) restTestSuite.getTestSections().get(0).getExecutableSections().get(6);
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(5), instanceOf(DoSection.class));
doSection = (DoSection) restTestSuite.getTestSections().get(0).getExecutableSections().get(5);
assertThat(doSection.getCatch(), nullValue());
assertThat(doSection.getApiCallSection().getApi(), equalTo("get"));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(3));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(2));
assertThat(doSection.getApiCallSection().hasBody(), equalTo(false));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(7), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(7);
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(6), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(6);
assertThat(matchAssertion.getField(), equalTo("_index"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("test-weird-index-中文"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(8), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(8);
assertThat(matchAssertion.getField(), equalTo("_type"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("weird.type"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(9), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(9);
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(7), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(7);
assertThat(matchAssertion.getField(), equalTo("_id"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("1"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(10), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(10);
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(8), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(8);
assertThat(matchAssertion.getField(), equalTo("_version"));
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("1"));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(11), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(11);
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(9), instanceOf(MatchAssertion.class));
matchAssertion = (MatchAssertion) restTestSuite.getTestSections().get(0).getExecutableSections().get(9);
assertThat(matchAssertion.getField(), equalTo("_source"));
assertThat(matchAssertion.getExpectedValue(), instanceOf(Map.class));
assertThat(((Map) matchAssertion.getExpectedValue()).get("foo").toString(), equalTo("bar"));
Expand All @@ -287,14 +238,12 @@ public void testParseTestMultipleTestSections() throws Exception {
+ " catch: missing\n"
+ " update:\n"
+ " index: test_1\n"
+ " type: test\n"
+ " id: 1\n"
+ " body: { doc: { foo: bar } }\n"
+ "\n"
+ " - do:\n"
+ " update:\n"
+ " index: test_1\n"
+ " type: test\n"
+ " id: 1\n"
+ " body: { doc: { foo: bar } }\n"
+ " ignore: 404\n"
Expand All @@ -307,7 +256,6 @@ public void testParseTestMultipleTestSections() throws Exception {
+ " catch: missing\n"
+ " update:\n"
+ " index: test_1\n"
+ " type: test\n"
+ " id: 1\n"
+ " body:\n"
+ " script: \"ctx._source.foo = bar\"\n"
Expand All @@ -316,7 +264,6 @@ public void testParseTestMultipleTestSections() throws Exception {
+ " - do:\n"
+ " update:\n"
+ " index: test_1\n"
+ " type: test\n"
+ " id: 1\n"
+ " ignore: 404\n"
+ " body:\n"
Expand All @@ -341,13 +288,13 @@ public void testParseTestMultipleTestSections() throws Exception {
DoSection doSection = (DoSection) restTestSuite.getTestSections().get(0).getExecutableSections().get(0);
assertThat(doSection.getCatch(), equalTo("missing"));
assertThat(doSection.getApiCallSection().getApi(), equalTo("update"));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(3));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(2));
assertThat(doSection.getApiCallSection().hasBody(), equalTo(true));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(1), instanceOf(DoSection.class));
doSection = (DoSection) restTestSuite.getTestSections().get(0).getExecutableSections().get(1);
assertThat(doSection.getCatch(), nullValue());
assertThat(doSection.getApiCallSection().getApi(), equalTo("update"));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(4));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(3));
assertThat(doSection.getApiCallSection().hasBody(), equalTo(true));

assertThat(restTestSuite.getTestSections().get(1).getName(), equalTo("Missing document (script)"));
Expand All @@ -358,13 +305,13 @@ public void testParseTestMultipleTestSections() throws Exception {
doSection = (DoSection) restTestSuite.getTestSections().get(1).getExecutableSections().get(0);
assertThat(doSection.getCatch(), equalTo("missing"));
assertThat(doSection.getApiCallSection().getApi(), equalTo("update"));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(3));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(2));
assertThat(doSection.getApiCallSection().hasBody(), equalTo(true));
assertThat(restTestSuite.getTestSections().get(0).getExecutableSections().get(1), instanceOf(DoSection.class));
doSection = (DoSection) restTestSuite.getTestSections().get(1).getExecutableSections().get(1);
assertThat(doSection.getCatch(), nullValue());
assertThat(doSection.getApiCallSection().getApi(), equalTo("update"));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(4));
assertThat(doSection.getApiCallSection().getParams().size(), equalTo(3));
assertThat(doSection.getApiCallSection().hasBody(), equalTo(true));
}

Expand All @@ -378,7 +325,6 @@ public void testParseTestDuplicateTestSections() throws Exception {
+ " catch: missing\n"
+ " update:\n"
+ " index: test_1\n"
+ " type: test\n"
+ " id: 1\n"
+ " body: { doc: { foo: bar } }\n"
+ "\n"
Expand All @@ -390,7 +336,6 @@ public void testParseTestDuplicateTestSections() throws Exception {
+ " catch: missing\n"
+ " update:\n"
+ " index: test_1\n"
+ " type: test\n"
+ " id: 1\n"
+ " body:\n"
+ " script: \"ctx._source.foo = bar\"\n"
Expand Down
Loading