Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,6 @@ tests:
- class: org.elasticsearch.search.CCSDuelIT
method: testTermsAggsWithProfile
issue: https://github.com/elastic/elasticsearch/issues/132880
- class: org.elasticsearch.index.mapper.LongFieldMapperTests
method: testFetchMany
issue: https://github.com/elastic/elasticsearch/issues/132948
- class: org.elasticsearch.index.mapper.LongFieldMapperTests
method: testFetch
issue: https://github.com/elastic/elasticsearch/issues/132956
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
package org.elasticsearch.index.mapper;

import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.datageneration.FieldType;
import org.elasticsearch.script.LongFieldScript;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentType;
import org.junit.Before;

import java.io.IOException;
import java.math.BigInteger;
Expand All @@ -26,6 +28,15 @@

public class LongFieldMapperTests extends WholeNumberFieldMapperTests {

private FieldType fieldType;

@Before
public void pickNumberType() {
// randomly select between long and double to use for generating random numbers
boolean shouldUseLong = randomBoolean();
fieldType = shouldUseLong ? FieldType.LONG : FieldType.DOUBLE;
}

@Override
protected Number missingValue() {
return 123L;
Expand All @@ -45,7 +56,7 @@ protected List<NumberTypeOutOfRangeSpec> outOfRangeSpecs() {

@Override
protected void minimalMapping(XContentBuilder b) throws IOException {
b.field("type", "long");
b.field("type", fieldType.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels wrong to have a "type": "double" in the LongFieldMapperTests. Shouldn't the double tests be in the DoubleFieldMapperTests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its weird that a test class that tests long is generating doubles. Now that you pointed it out, its probably for verifying conversions, but it should've been more explicit in code.

}

@Override
Expand Down Expand Up @@ -105,7 +116,8 @@ public void testLongIndexingCoercesIntoRange() throws Exception {

@Override
protected Number randomNumber() {
if (randomBoolean()) {
// we must be consistent with the type of each number that we generate
if (fieldType.equals(FieldType.LONG)) {
return randomLong();
}
if (randomBoolean()) {
Expand Down