Skip to content

Conversation

@s1monw
Copy link
Contributor

@s1monw s1monw commented Jun 21, 2017

This change cleans up core tests to not use index.mapping.single_type=false
but instead where applicable use a single type or markt the index as created
with a pre 6.x version.

Relates to #24961

This change cleans up core tests to not use `index.mapping.single_type=false`
but instead where applicable use a single type or markt the index as created
with a pre 6.x version.

Relates to elastic#24961
@s1monw s1monw added >non-issue >test Issues or PRs that are addressing/adding tests v6.0.0 labels Jun 21, 2017
@s1monw s1monw requested review from jpountz and nik9000 June 21, 2017 10:18
Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a fair way to fix those tests. LGTM.

@nik9000
Copy link
Member

nik9000 commented Jun 21, 2017

I dunno. I expected this process to consist more of removing multiple types in the tests and less of declaring indices to be old. The test names don't make it look like they are testing old index behavior. They mostly look like they intend to test "normal" index behavior.

I think this kicks the can down to 7.0 when someone will have to look at these tests and decide weather to rewrite them with one type or just remove them.

@jpountz
Copy link
Contributor

jpountz commented Jun 21, 2017

The test names don't make it look like they are testing old index behavior.

They do since they are using parent/child?

@s1monw
Copy link
Contributor Author

s1monw commented Jun 21, 2017

I dunno. I expected this process to consist more of removing multiple types in the tests and less of declaring indices to be old. The test names don't make it look like they are testing old index behavior. They mostly look like they intend to test "normal" index behavior.

I did convert quite a few of them, actually all of the ones that are possible and I invested a lot of time. I think you should look closer and tell me the ones that I missed. We are in-fact supporting multiple types for 5.x indices so we should also test the APIs against it. This is why I kept or duplicated a lot of them.

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a bunch of comments, mostly asking for comments explaining why we need multiple types and/or asking whether we should have a "single type" variant of tests.

.addMapping("type1", mapping1, XContentType.JSON)
.addMapping("type2", mapping2, XContentType.JSON)
.setSettings("index.refresh_interval", -1, "index.mapping.single_type", false));
.setSettings("index.refresh_interval", -1, "index.version.created", Version.V_5_6_0.id)); // multi types in 5.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is testing 5.x compat we should rename the test. It reads like it is testing stored fields with multiple values.

.addMapping("my-type1", "_parent", "type=parent", "field1", "type=keyword,store=true")
.addAlias(new Alias("alias"))
.setSettings("index.refresh_interval", -1, "index.mapping.single_type", false));
.setSettings("index.refresh_interval", -1, "index.version.created", Version.V_5_6_0.id)); // multi types in 5.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we're better off testing old style parent/child metadata in its own test. That way we can remove the entire test when we no longer support it. Maybe that'd be as simple as moving routing into another test and renaming the test.


for (String index : Arrays.asList("foo", "foobar", "bar", "barbaz")) {
assertAcked(prepareCreate(index).setSettings("index.mapping.single_type", false));
assertAcked(prepareCreate(index).setSettings("index.version.created", Version.V_5_6_0.id)); // allows for multiple types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this test have a multi-type variant and a single type variant?


assertAcked(prepareCreate("indexa")
.setSettings("index.mapping.single_type", false)
.setSettings("index.version.created", Version.V_5_6_0.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a single-type variant?

public void testSimpleGetMappings() throws Exception {
client().admin().indices().prepareCreate("indexa")
.setSettings("index.mapping.single_type", false)
.setSettings("index.version.created", Version.V_5_6_0.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think multiple types are "simple" any more. Should this have a single type and a multi-type variant?


assertAcked(prepareCreate("test_index")
.setSettings("index.mapping.single_type", false)
.setSettings("index.version.created", Version.V_5_6_0.id) // allow for multiple version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding a single type variant of this?


assertAcked(prepareCreate("test").setSettings(builder.build()).addMapping("type1", type1TermVectorMapping())
.addMapping("type2",
assertAcked(prepareCreate("test").setSettings(builder.build()).addMapping("type1", type1TermVectorMapping()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename these indices? I know I'll get test and test1 mixed up. Even test1 and test2 would be better.

public void testLoadMetadata() throws Exception {
assertAcked(prepareCreate("test")
.setSettings("index.mapping.single_type", false)
.setSettings("index.version.created", Version.V_5_6_0.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have another test for routing I'd rename this one to testLoadParent or something. Then we can nuke it in 7.0 easilly.

assertThat(searchResponse.getHits().getHits().length, equalTo(3));
}

public void testBasicQueryByIdMultiType() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

public void testContextVariables() throws Exception {
assertAcked(prepareCreate("test")
.setSettings("index.mapping.single_type", false)
.setSettings("index.version.created", Version.V_5_6_0.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth leaving a comment that we can remove this setting, the parent, and the second document once we no longer support types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wont' the test just fail in that case?

@s1monw
Copy link
Contributor Author

s1monw commented Jun 22, 2017

@nik9000 I pushed changes

@s1monw s1monw merged commit 29e80ee into elastic:master Jun 22, 2017
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jun 22, 2017
* master: (56 commits)
  Initialize max unsafe auto ID timestamp on shrink
  Enable a long translog retention policy by default (elastic#25294)
  Remove `index.mapping.single_type=false` from core/tests (elastic#25331)
  test: single type defaults to true since alpha1 and not alpha3
  Get short path name for native controllers
  Live primary-replica resync (no rollback) (elastic#24841)
  Upgrade to lucene-7.0.0-snapshot-ad2cb77. (elastic#25349)
  percolator: Deprecate `document_type` parameter.
  [DOCS] Fixed typo.
  [rest-api-spec/indices.refresh] Remove old params
  Remove redundant and broken MD5 checksum from repository-s3 (elastic#25270)
  Initialize sequence numbers on a shrunken index
  Port most snapshot/restore static bwc tests to qa:full-cluster-restart (elastic#25296)
  Javadoc: ThreadPool doesn't reject while shutdown (elastic#23678)
  test: verify `size_to_upgrade_in_bytes` in assertBusy(...)
  Docs: Removed duplicated line in mapping docs
  Add backward compatibility indices for 5.4.2
  Update MockTransportService to the age of Transport.Connection (elastic#25320)
  Add version v5.4.2 after release
  IndexMetaData: Add internal format index setting (elastic#25292)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue >test Issues or PRs that are addressing/adding tests v6.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants