This is an automated email from the ASF dual-hosted git repository.
ppa pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 19fae974c3c IGNITE-27059 Revise SQL-related tests that fail with
disabled assertions (#6978)
19fae974c3c is described below
commit 19fae974c3c27d9d9849cf65917f524c3a76f4ef
Author: Pavel Pereslegin <[email protected]>
AuthorDate: Wed Nov 19 09:23:33 2025 +0300
IGNITE-27059 Revise SQL-related tests that fail with disabled assertions
(#6978)
---
.../ignite/jdbc/ItJdbcComplexDmlDdlSelfTest.java | 10 ++++++----
.../sql/engine/exec/ScannableTableImpl.java | 12 ++++++++++--
.../sql/engine/exec/exp/agg/Accumulators.java | 16 ++++++++++++----
.../mapping/largecluster/LargeClusterFactory.java | 21 +++++++++++++++++----
.../mapping/smallcluster/SmallClusterFactory.java | 17 ++++++++++++++---
.../exec/exp/agg/GroupingAccumulatorTest.java | 8 ++++----
.../mapping/ExecutionTargetFactorySelfTest.java | 14 +++++++-------
.../sql/engine/exec/rel/ScannableTableSelfTest.java | 2 +-
.../internal/sql/engine/util/QueryCheckerTest.java | 14 ++++++++++----
.../ItDisasterRecoveryResetPartitionsTest.java | 2 +-
.../tx/readonly/ItReadOnlyTxInPastTest.java | 2 +-
11 files changed, 83 insertions(+), 35 deletions(-)
diff --git
a/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcComplexDmlDdlSelfTest.java
b/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcComplexDmlDdlSelfTest.java
index 6beb8ceba39..f9f9a912c58 100644
---
a/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcComplexDmlDdlSelfTest.java
+++
b/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcComplexDmlDdlSelfTest.java
@@ -77,7 +77,7 @@ public class ItJdbcComplexDmlDdlSelfTest extends
AbstractJdbcSelfTest {
);
}
- final int[] cnt = {0};
+ int[] cnt = {0};
sql(new ResultPredicateChecker((Object[] objs) -> {
int id = ((Integer) objs[0]);
@@ -99,7 +99,7 @@ public class ItJdbcComplexDmlDdlSelfTest extends
AbstractJdbcSelfTest {
return true;
}), "SELECT id, name, age FROM person_t where id < 50");
- assertEquals(cnt[0], 50, "Invalid rows count");
+ assertEquals(50, cnt[0], "Invalid rows count");
// Berkeley is not present in City table, although 25 people have it
specified as their city.
sql(new ResultChecker(new Object[][] {{75L}}),
@@ -130,7 +130,7 @@ public class ItJdbcComplexDmlDdlSelfTest extends
AbstractJdbcSelfTest {
return true;
}), "SELECT * FROM person_t where company = 'New Company'");
- assertEquals(cnt[0], 34, "Invalid rows count");
+ assertEquals(34, cnt[0], "Invalid rows count");
sql(new UpdateChecker(0), "DROP TABLE IF EXISTS city_t");
sql(new UpdateChecker(0), "DROP TABLE IF EXISTS person_t");
@@ -343,7 +343,9 @@ public class ItJdbcComplexDmlDdlSelfTest extends
AbstractJdbcSelfTest {
rowObjs[i] = rs.getObject(i + 1);
}
- assert rowPredicate.apply(rowObjs) : "Invalid row. [row=" +
Arrays.toString(rowObjs) + ']';
+ boolean applied = rowPredicate.apply(rowObjs);
+
+ assert applied : "Invalid row. [row=" +
Arrays.toString(rowObjs) + ']';
}
}
diff --git
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ScannableTableImpl.java
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ScannableTableImpl.java
index 2256e7047fe..7f5807bd043 100644
---
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ScannableTableImpl.java
+++
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ScannableTableImpl.java
@@ -192,11 +192,19 @@ public class ScannableTableImpl implements ScannableTable
{
RowHandler<RowT> handler,
@Nullable RowT prefix
) {
- if (prefix == null || handler.columnCount(prefix) == 0) {
+ if (prefix == null) {
return null;
}
- assert searchBoundSize >= handler.columnCount(prefix) : "Invalid range
condition";
+ int columnsCount = handler.columnCount(prefix);
+
+ if (columnsCount == 0) {
+ return null;
+ }
+
+ if (searchBoundSize < columnsCount) {
+ throw new IllegalStateException("Invalid range condition");
+ }
return BinaryTuplePrefix.fromBinaryTuple(searchBoundSize,
handler.toBinaryTuple(prefix));
}
diff --git
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/agg/Accumulators.java
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/agg/Accumulators.java
index 9b263d51e0b..8589c8f4130 100644
---
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/agg/Accumulators.java
+++
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/agg/Accumulators.java
@@ -254,21 +254,29 @@ public class Accumulators {
}
private GroupingAccumulator(List<Integer> argList) {
- assert !argList.isEmpty() : "GROUPING function must have at least
one argument.";
- assert argList.size() < Long.SIZE : "GROUPING function with more
than 63 arguments is not supported.";
+ if (argList.isEmpty()) {
+ throw new IllegalArgumentException("GROUPING function must
have at least one argument.");
+ }
+
+ if (argList.size() >= Long.SIZE) {
+ throw new IllegalArgumentException("GROUPING function with
more than 63 arguments is not supported.");
+ }
+
this.argList = argList;
}
@Override
public void add(AccumulatorsState state, Object[] args) {
- assert false;
+ throw new UnsupportedOperationException("This method should not be
called.");
}
@Override
public void end(AccumulatorsState state, AccumulatorsState result) {
ImmutableBitSet groupKey = (ImmutableBitSet) state.get();
- assert groupKey != null;
+ if (groupKey == null) {
+ throw new IllegalStateException("Invalid accumulator state");
+ }
long res = 0;
long bit = 1L << (argList.size() - 1);
diff --git
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/mapping/largecluster/LargeClusterFactory.java
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/mapping/largecluster/LargeClusterFactory.java
index 99f353cee17..d0adf9e1e8d 100644
---
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/mapping/largecluster/LargeClusterFactory.java
+++
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/mapping/largecluster/LargeClusterFactory.java
@@ -53,6 +53,8 @@ public class LargeClusterFactory implements
ExecutionTargetFactory {
@Override
public ExecutionTarget allOf(List<String> nodes) {
+ ensureNonEmptyTarget(nodes);
+
BitSet nodesSet = new BitSet(nodeNameToId.size());
for (String name : nodes) {
@@ -69,16 +71,22 @@ public class LargeClusterFactory implements
ExecutionTargetFactory {
@Override
public ExecutionTarget oneOf(List<String> nodes) {
+ ensureNonEmptyTarget(nodes);
+
return new OneOfTarget(nodeListToMap(nodes));
}
@Override
public ExecutionTarget someOf(List<String> nodes) {
+ ensureNonEmptyTarget(nodes);
+
return new SomeOfTarget(nodeListToMap(nodes));
}
@Override
public ExecutionTarget partitioned(List<TokenizedAssignments> assignments)
{
+ ensureNonEmptyTarget(assignments);
+
BitSet[] partitionNodes = new BitSet[assignments.size()];
long[] enlistmentConsistencyTokens = new long[assignments.size()];
@@ -99,7 +107,7 @@ public class LargeClusterFactory implements
ExecutionTargetFactory {
.map(Assignment::consistentId)
.collect(Collectors.toList());
- throw new MappingException("Mandatory nodes was excluded from
mapping: " + nodes0);
+ throw new MappingException("Mandatory nodes were excluded from
mapping: " + nodes0);
}
finalised = finalised && nodes.cardinality() < 2;
@@ -131,8 +139,6 @@ public class LargeClusterFactory implements
ExecutionTargetFactory {
}
private BitSet nodeListToMap(List<String> nodes) {
- assert !nodes.isEmpty() : "Empty target is not allowed";
-
BitSet nodesSet = new BitSet(nodeNameToId.size());
for (String name : nodes) {
@@ -144,9 +150,16 @@ public class LargeClusterFactory implements
ExecutionTargetFactory {
}
if (nodesSet.isEmpty()) {
- throw new MappingException("Mandatory nodes was excluded from
mapping: " + nodes);
+ throw new MappingException("Mandatory nodes were excluded from
mapping: " + nodes);
}
return nodesSet;
}
+
+ /** Throws {@link MappingException} if provided list of target nodes
(assignments) is empty. */
+ public static void ensureNonEmptyTarget(List<?> nodes) {
+ if (nodes.isEmpty()) {
+ throw new MappingException("Empty target is not allowed");
+ }
+ }
}
diff --git
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/mapping/smallcluster/SmallClusterFactory.java
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/mapping/smallcluster/SmallClusterFactory.java
index c4accfc78c1..7971f2089e6 100644
---
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/mapping/smallcluster/SmallClusterFactory.java
+++
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/mapping/smallcluster/SmallClusterFactory.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.sql.engine.exec.mapping.smallcluster;
+import static
org.apache.ignite.internal.sql.engine.exec.mapping.largecluster.LargeClusterFactory.ensureNonEmptyTarget;
import static org.apache.ignite.internal.util.IgniteUtils.isPow2;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@@ -57,6 +58,8 @@ public class SmallClusterFactory implements
ExecutionTargetFactory {
@Override
public ExecutionTarget allOf(List<String> nodes) {
+ ensureNonEmptyTarget(nodes);
+
long nodesMap = 0;
for (String name : nodes) {
@@ -74,16 +77,22 @@ public class SmallClusterFactory implements
ExecutionTargetFactory {
@Override
public ExecutionTarget oneOf(List<String> nodes) {
+ ensureNonEmptyTarget(nodes);
+
return new OneOfTarget(nodeListToMap(nodes));
}
@Override
public ExecutionTarget someOf(List<String> nodes) {
+ ensureNonEmptyTarget(nodes);
+
return new SomeOfTarget(nodeListToMap(nodes));
}
@Override
public ExecutionTarget partitioned(List<TokenizedAssignments> assignments)
{
+ ensureNonEmptyTarget(assignments);
+
long[] partitionNodes = new long[assignments.size()];
long[] enlistmentConsistencyTokens = new long[assignments.size()];
@@ -104,7 +113,7 @@ public class SmallClusterFactory implements
ExecutionTargetFactory {
.map(Assignment::consistentId)
.collect(Collectors.toList());
- throw new MappingException("Mandatory nodes was excluded from
mapping: " + nodes);
+ throw new MappingException("Mandatory nodes were excluded from
mapping: " + nodes);
}
finalised = finalised && isPow2(currentPartitionNodes);
@@ -137,7 +146,9 @@ public class SmallClusterFactory implements
ExecutionTargetFactory {
}
private long nodeListToMap(List<String> nodes) {
- assert !nodes.isEmpty() : "Empty target is not allowed";
+ if (nodes.isEmpty()) {
+ throw new IllegalArgumentException("Empty target is not allowed");
+ }
long nodesMap = 0;
@@ -150,7 +161,7 @@ public class SmallClusterFactory implements
ExecutionTargetFactory {
}
if (nodesMap == 0) {
- throw new MappingException("Mandatory nodes was excluded from
mapping: " + nodes);
+ throw new MappingException("Mandatory nodes were excluded from
mapping: " + nodes);
}
return nodesMap;
diff --git
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/exp/agg/GroupingAccumulatorTest.java
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/exp/agg/GroupingAccumulatorTest.java
index 85476a6fda7..db7d8601e30 100644
---
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/exp/agg/GroupingAccumulatorTest.java
+++
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/exp/agg/GroupingAccumulatorTest.java
@@ -40,11 +40,11 @@ public class GroupingAccumulatorTest {
@Test
public void testFactory() {
- assertThrows(AssertionError.class,
+ assertThrows(IllegalArgumentException.class,
() -> GroupingAccumulator.newAccumulator(List.of()).get(),
"GROUPING function must have at least one argument"
);
- assertThrows(AssertionError.class,
+ assertThrows(IllegalArgumentException.class,
() -> GroupingAccumulator.newAccumulator(IntStream.range(0,
64).boxed().collect(Collectors.toList())).get(),
"GROUPING function with more than 63 arguments is not
supported"
);
@@ -57,7 +57,7 @@ public class GroupingAccumulatorTest {
Accumulator acc = newCall(List.of(0));
AccumulatorsState result = newState();
- assertThrows(AssertionError.class, () -> acc.end(newState(), result));
+ assertThrows(IllegalStateException.class, () -> acc.end(newState(),
result));
assertNull(result.get());
}
@@ -69,7 +69,7 @@ public class GroupingAccumulatorTest {
AccumulatorsState state = newState();
assertEquals(IgniteTypeFactory.INSTANCE.createSqlType(SqlTypeName.BIGINT),
acc.returnType(IgniteTypeFactory.INSTANCE));
- assertThrows(AssertionError.class, () -> acc.add(state, new
Object[]{1}));
+ assertThrows(UnsupportedOperationException.class, () -> acc.add(state,
new Object[]{1}));
assertFalse(state.hasValue());
}
diff --git
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/mapping/ExecutionTargetFactorySelfTest.java
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/mapping/ExecutionTargetFactorySelfTest.java
index 1a4c2503ecf..3020bcac74f 100644
---
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/mapping/ExecutionTargetFactorySelfTest.java
+++
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/mapping/ExecutionTargetFactorySelfTest.java
@@ -82,10 +82,10 @@ public class ExecutionTargetFactorySelfTest {
@ParameterizedTest
@MethodSource("clusterFactory")
void emptyTargets(ExecutionTargetFactory f) {
- assertThrows(AssertionError.class, () -> f.allOf(List.of()), "Empty
target is not allowed");
- assertThrows(AssertionError.class, () -> f.someOf(List.of()), "Empty
target is not allowed");
- assertThrows(AssertionError.class, () -> f.oneOf(List.of()), "Empty
target is not allowed");
- assertThrows(AssertionError.class, () -> f.partitioned(List.of()),
"Empty target is not allowed");
+ assertThrows(MappingException.class, () -> f.allOf(List.of()), "Empty
target is not allowed");
+ assertThrows(MappingException.class, () -> f.someOf(List.of()), "Empty
target is not allowed");
+ assertThrows(MappingException.class, () -> f.oneOf(List.of()), "Empty
target is not allowed");
+ assertThrows(MappingException.class, () -> f.partitioned(List.of()),
"Empty target is not allowed");
}
@ParameterizedTest
@@ -94,10 +94,10 @@ public class ExecutionTargetFactorySelfTest {
List<String> invalidNodeSet = List.of("node100");
assertThrows(MappingException.class, () -> f.allOf(invalidNodeSet),
"Mandatory node was excluded from mapping: node100");
- assertThrows(MappingException.class, () -> f.someOf(invalidNodeSet),
"Mandatory nodes was excluded from mapping: [node100]");
- assertThrows(MappingException.class, () -> f.oneOf(invalidNodeSet),
"Mandatory nodes was excluded from mapping: [node100]");
+ assertThrows(MappingException.class, () -> f.someOf(invalidNodeSet),
"Mandatory nodes were excluded from mapping: [node100]");
+ assertThrows(MappingException.class, () -> f.oneOf(invalidNodeSet),
"Mandatory nodes were excluded from mapping: [node100]");
assertThrows(MappingException.class, () -> f.partitioned(
- assignmentFromPrimaries(invalidNodeSet)), "Mandatory nodes was
excluded from mapping: [node100]");
+ assignmentFromPrimaries(invalidNodeSet)), "Mandatory nodes
were excluded from mapping: [node100]");
}
@ParameterizedTest
diff --git
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/rel/ScannableTableSelfTest.java
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/rel/ScannableTableSelfTest.java
index 66ca760ffdb..0b60d17f050 100644
---
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/rel/ScannableTableSelfTest.java
+++
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/rel/ScannableTableSelfTest.java
@@ -318,7 +318,7 @@ public class ScannableTableSelfTest extends
BaseIgniteAbstractTest {
// Bound columns != input columns.
condition.setLower(Bound.INCLUSIVE, new Object[]{1, 2});
- AssertionError err = assertThrows(AssertionError.class,
+ IllegalStateException err = assertThrows(IllegalStateException.class,
() -> tester.indexScan(partitionId, consistencyToken, tx,
indexId, condition));
assertEquals("Invalid range condition", err.getMessage());
diff --git
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/util/QueryCheckerTest.java
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/util/QueryCheckerTest.java
index 575cb6b1edb..0f5b4094a37 100644
---
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/util/QueryCheckerTest.java
+++
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/util/QueryCheckerTest.java
@@ -310,7 +310,7 @@ public class QueryCheckerTest extends
BaseIgniteAbstractTest {
// Test that validates the results cannot be executed correctly
without actually executing the query.
assertThrows(
- AssertionError.class,
+ IllegalStateException.class,
() -> assertQueryMeta("SELECT * FROM t1")
.columnTypes(Integer.class, Integer.class)
.returns(1, 1)
@@ -321,7 +321,7 @@ public class QueryCheckerTest extends
BaseIgniteAbstractTest {
// Test that only checks metadata should not execute the query.
assertThrows(
- AssertionError.class,
+ IllegalStateException.class,
() -> assertQuery("SELECT * FROM t1")
.columnTypes(Integer.class, Integer.class)
.check(),
@@ -370,7 +370,10 @@ public class QueryCheckerTest extends
BaseIgniteAbstractTest {
Object... params
) {
assert params == null || params.length == 0 : "params are not
supported";
- assert prepareOnly : "Expected that the query will be executed";
+
+ if (!prepareOnly) {
+ throw new IllegalStateException("Expected that the query will
be executed");
+ }
QueryPlan plan = node.prepare(qry);
@@ -387,7 +390,10 @@ public class QueryCheckerTest extends
BaseIgniteAbstractTest {
Object... params
) {
assert params == null || params.length == 0 : "params are not
supported";
- assert !prepareOnly : "Expected that the query will only be
prepared, but not executed";
+
+ if (prepareOnly) {
+ throw new IllegalStateException("Expected that the query will
only be prepared, but not executed");
+ }
AsyncSqlCursor<InternalSqlRow> sqlCursor = node.executeQuery(qry);
diff --git
a/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryResetPartitionsTest.java
b/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryResetPartitionsTest.java
index 565d1422c75..ad250d42043 100644
---
a/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryResetPartitionsTest.java
+++
b/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryResetPartitionsTest.java
@@ -71,7 +71,7 @@ public class ItDisasterRecoveryResetPartitionsTest extends
ClusterPerTestIntegra
stopNode(nodeToStop);
- assertThrows(SqlException.class, () -> executeSql(selectSql),
"Mandatory nodes was excluded from mapping:");
+ assertThrows(SqlException.class, () -> executeSql(selectSql),
"Mandatory nodes were excluded from mapping:");
DisasterRecoveryManager disasterRecoveryManager =
unwrapIgniteImpl(cluster.aliveNode()).disasterRecoveryManager();
CompletableFuture<Void> resetFuture =
TestDisasterRecoveryUtils.resetPartitions(
diff --git
a/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/tx/readonly/ItReadOnlyTxInPastTest.java
b/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/tx/readonly/ItReadOnlyTxInPastTest.java
index 425a7f9711f..45a67a023cb 100644
---
a/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/tx/readonly/ItReadOnlyTxInPastTest.java
+++
b/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/tx/readonly/ItReadOnlyTxInPastTest.java
@@ -72,7 +72,7 @@ class ItReadOnlyTxInPastTest extends
ClusterPerTestIntegrationTest {
setDefaultZoneAutoAdjustScaleUpTimeoutToImmediate();
}
- // In case of empty assignments, SQL engine will throw "Mandatory
nodes was excluded from mapping: []".
+ // In case of empty assignments, SQL engine will throw "Mandatory
nodes were excluded from mapping: []".
// In order to eliminate this, assignments stabilization is needed,
otherwise test may fail. Not related to colocation.
awaitAssignmentsStabilization(node, TABLE_NAME);