diff --git a/muted-tests.yml b/muted-tests.yml index f7cd2a7ff7ad1..f275e2cec5267 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -585,9 +585,6 @@ tests: - class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT method: testManyConcat issue: https://github.com/elastic/elasticsearch/issues/136728 -- class: org.elasticsearch.compute.data.BasicPageTests - method: testEqualityAndHashCode - issue: https://github.com/elastic/elasticsearch/issues/136753 # Examples: # diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicPageTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicPageTests.java index d5fbc92d7b77f..7985a26019197 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicPageTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicPageTests.java @@ -141,17 +141,31 @@ public void testEqualityAndHashCode() throws IOException { }; final EqualsHashCodeTestUtils.MutateFunction mutatePageFunction = page -> { - assert page.getPositionCount() > 0; - Block[] blocks = new Block[page.getBlockCount()]; - int positions = randomInt(page.getPositionCount() - 1); - for (int blockIndex = 0; blockIndex < blocks.length; blockIndex++) { - Block block = page.getBlock(blockIndex); - blocks[blockIndex] = block.elementType() - .newBlockBuilder(positions, TestBlockFactory.getNonBreakingInstance()) - .copyFrom(block, 0, positions) - .build(); + if (page.getPositionCount() > 0) { + Block[] blocks = new Block[page.getBlockCount()]; + int positions = randomInt(page.getPositionCount() - 1); + for (int blockIndex = 0; blockIndex < blocks.length; blockIndex++) { + Block block = page.getBlock(blockIndex); + blocks[blockIndex] = block.elementType() + .newBlockBuilder(positions, TestBlockFactory.getNonBreakingInstance()) + .copyFrom(block, 0, positions) + .build(); + } + return new Page(positions, blocks); + } else { + Block[] blocks = new Block[page.getBlockCount() + 1]; + for (int blockIndex = 0; blockIndex < page.getBlockCount(); blockIndex++) { + blocks[blockIndex] = page.getBlock(blockIndex); + } + + ElementType newBlockType = randomValueOtherThanMany( + x -> x == ElementType.DOC || x == ElementType.COMPOSITE || x == ElementType.UNKNOWN, + () -> randomFrom(ElementType.values()) + ); + + blocks[blocks.length - 1] = newBlockType.newBlockBuilder(0, TestBlockFactory.getNonBreakingInstance()).build(); + return new Page(0, blocks); } - return new Page(positions, blocks); }; int positions = randomIntBetween(0, 512);