Skip to content

Commit

Permalink
Fix test failures by wrapping job scheduelr errors in TableInitializa…
Browse files Browse the repository at this point in the history
…tionExceptions (#5166)
  • Loading branch information
nbauernfeind committed Feb 18, 2024
1 parent 73cdc66 commit a6da0eb
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.deephaven.datastructures.util.CollectionUtil;
import io.deephaven.engine.context.ExecutionContext;
import io.deephaven.engine.context.QueryScope;
import io.deephaven.engine.exceptions.TableInitializationException;
import io.deephaven.engine.liveness.LivenessScopeStack;
import io.deephaven.engine.liveness.SingletonLivenessManager;
import io.deephaven.engine.rowset.RowSet;
Expand Down Expand Up @@ -1069,13 +1070,17 @@ public void testTransformStaticToRefreshing() {
try {
partitionedTable.transform(t -> t.join(refreshingInput, "c", "c2=c"));
TestCase.fail("Expected exception");
} catch (IllegalStateException expected) {
} catch (TableInitializationException expected) {
Assert.eqTrue(expected.getCause().getClass() == IllegalStateException.class,
"expected.getCause().getClass() instanceof IllegalStateException");
}

try {
partitionedTable.partitionedTransform(partitionedTable, (t, u) -> t.join(refreshingInput, "c", "c2=c"));
TestCase.fail("Expected exception");
} catch (IllegalStateException expected) {
} catch (TableInitializationException expected) {
Assert.eqTrue(expected.getCause().getClass() == IllegalStateException.class,
"expected.getCause().getClass() instanceof IllegalStateException");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.deephaven.engine.context.QueryScope;
import io.deephaven.engine.exceptions.CancellationException;
import io.deephaven.engine.table.impl.sources.RowKeyColumnSource;
import io.deephaven.engine.exceptions.TableInitializationException;
import io.deephaven.engine.util.TableTools;
import io.deephaven.engine.table.impl.verify.TableAssertions;
import io.deephaven.engine.table.impl.select.*;
Expand Down Expand Up @@ -723,8 +724,11 @@ public void testInterFilterInterruption() {
waitForLatch(latch);

assertEquals(0, fastCounter.invokes.get());
assertNotNull(caught.getValue());
assertEquals(CancellationException.class, caught.getValue().getClass());
Throwable err = caught.getValue();
assertNotNull(err);
assertEquals(TableInitializationException.class, err.getClass());
err = err.getCause();
assertEquals(CancellationException.class, err.getClass());

QueryScope.addParam("slowCounter", null);
QueryScope.addParam("fastCounter", null);
Expand Down Expand Up @@ -1071,7 +1075,10 @@ public void testFilterErrorInitial() {
try {
final QueryTable whereResult = (QueryTable) table.where("y.length() > 0");
Assert.statementNeverExecuted("Expected exception not thrown.");
} catch (Exception e) {
} catch (Throwable e) {
Assert.eqTrue(e instanceof TableInitializationException,
"TableInitializationException expected.");
e = e.getCause();
Assert.eqTrue(e instanceof FormulaEvaluationException
&& e.getCause() != null && e.getCause() instanceof NullPointerException,
"NPE causing FormulaEvaluationException expected.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import io.deephaven.api.updateby.OperationControl;
import io.deephaven.api.updateby.UpdateByControl;
import io.deephaven.api.updateby.UpdateByOperation;
import io.deephaven.base.verify.Assert;
import io.deephaven.chunk.Chunk;
import io.deephaven.chunk.ObjectChunk;
import io.deephaven.chunk.attributes.Values;
import io.deephaven.engine.context.ExecutionContext;
import io.deephaven.engine.exceptions.TableInitializationException;
import io.deephaven.engine.rowset.RowSet;
import io.deephaven.engine.rowset.RowSetFactory;
import io.deephaven.engine.table.PartitionedTable;
Expand Down Expand Up @@ -356,73 +358,103 @@ public void testThrowBehaviors() {
final TableDefaults bytes = testTable(RowSetFactory.flat(4).toTracking(),
byteCol("col", (byte) 0, (byte) 1, NULL_BYTE, (byte) 3));

assertThrows(TableDataException.class,
Throwable err = assertThrows(TableInitializationException.class,
() -> bytes.updateBy(UpdateByOperation.EmMin(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");


assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> bytes.updateBy(UpdateByOperation.EmMin(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");

TableDefaults shorts = testTable(RowSetFactory.flat(4).toTracking(),
shortCol("col", (short) 0, (short) 1, NULL_SHORT, (short) 3));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> shorts.updateBy(UpdateByOperation.EmMin(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");

TableDefaults ints = testTable(RowSetFactory.flat(4).toTracking(),
intCol("col", 0, 1, NULL_INT, 3));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> ints.updateBy(UpdateByOperation.EmMin(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");

TableDefaults longs = testTable(RowSetFactory.flat(4).toTracking(),
longCol("col", 0, 1, NULL_LONG, 3));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> longs.updateBy(UpdateByOperation.EmMin(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");

TableDefaults floats = testTable(RowSetFactory.flat(4).toTracking(),
floatCol("col", 0, 1, NULL_FLOAT, Float.NaN));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> floats.updateBy(
UpdateByOperation.EmMin(OperationControl.builder().onNullValue(BadDataBehavior.THROW).build(),
10)),
"Encountered null value during EMS processing");

assertThrows(TableDataException.class,
10)));
err = err.getCause();
Assert.eqTrue(err.getClass() == TableDataException.class,
"err.getClass() == TableDataException.class");
Assert.eqTrue(err.getMessage().contains("Encountered null value during Exponential Moving output processing"),
"err.getMessage().contains(\"Encountered null value during Exponential Moving output processing\")");

err = assertThrows(TableInitializationException.class,
() -> floats.updateBy(
UpdateByOperation.EmMin(OperationControl.builder().onNanValue(BadDataBehavior.THROW).build(),
10)),
"Encountered NaN value during EMS processing");
10)));
err = err.getCause();
Assert.eqTrue(err.getClass() == TableDataException.class,
"err.getClass() == TableDataException.class");
Assert.eqTrue(err.getMessage().contains("Encountered NaN value during Exponential Moving output processing"),
"err.getMessage().contains(\"Encountered NaN value during Exponential Moving output processing\")");

TableDefaults doubles = testTable(RowSetFactory.flat(4).toTracking(),
doubleCol("col", 0, 1, NULL_DOUBLE, Double.NaN));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> doubles.updateBy(
UpdateByOperation.EmMin(OperationControl.builder().onNullValue(BadDataBehavior.THROW).build(),
10)),
"Encountered null value during EMS processing");

assertThrows(TableDataException.class,
10)));
err = err.getCause();
Assert.eqTrue(err.getClass() == TableDataException.class,
"err.getClass() == TableDataException.class");
Assert.eqTrue(err.getMessage().contains("Encountered null value during Exponential Moving output processing"),
"err.getMessage().contains(\"Encountered null value during Exponential Moving output processing\")");

err = assertThrows(TableInitializationException.class,
() -> doubles.updateBy(
UpdateByOperation.EmMin(OperationControl.builder().onNanValue(BadDataBehavior.THROW).build(),
10)),
"Encountered NaN value during EMS processing");
10)));
err = err.getCause();
Assert.eqTrue(err.getClass() == TableDataException.class,
"err.getClass() == TableDataException.class");
Assert.eqTrue(err.getMessage().contains("Encountered NaN value during Exponential Moving output processing"),
"err.getMessage().contains(\"Encountered NaN value during Exponential Moving output processing\")");


TableDefaults bi = testTable(RowSetFactory.flat(4).toTracking(),
col("col", BigInteger.valueOf(0), BigInteger.valueOf(1), null, BigInteger.valueOf(3)));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> bi.updateBy(UpdateByOperation.EmMin(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");

TableDefaults bd = testTable(RowSetFactory.flat(4).toTracking(),
col("col", BigDecimal.valueOf(0), BigDecimal.valueOf(1), null, BigDecimal.valueOf(3)));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> bd.updateBy(UpdateByOperation.EmMin(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import io.deephaven.api.updateby.OperationControl;
import io.deephaven.api.updateby.UpdateByControl;
import io.deephaven.api.updateby.UpdateByOperation;
import io.deephaven.base.verify.Assert;
import io.deephaven.chunk.Chunk;
import io.deephaven.chunk.ObjectChunk;
import io.deephaven.chunk.attributes.Values;
import io.deephaven.engine.context.ExecutionContext;
import io.deephaven.engine.exceptions.TableInitializationException;
import io.deephaven.engine.rowset.RowSet;
import io.deephaven.engine.rowset.RowSetFactory;
import io.deephaven.engine.table.PartitionedTable;
Expand Down Expand Up @@ -370,73 +372,103 @@ public void testThrowBehaviors() {
final TableDefaults bytes = testTable(RowSetFactory.flat(4).toTracking(),
byteCol("col", (byte) 0, (byte) 1, NULL_BYTE, (byte) 3));

assertThrows(TableDataException.class,
Throwable err = assertThrows(TableInitializationException.class,
() -> bytes.updateBy(UpdateByOperation.EmStd(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");


assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> bytes.updateBy(UpdateByOperation.EmStd(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");

TableDefaults shorts = testTable(RowSetFactory.flat(4).toTracking(),
shortCol("col", (short) 0, (short) 1, NULL_SHORT, (short) 3));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> shorts.updateBy(UpdateByOperation.EmStd(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");

TableDefaults ints = testTable(RowSetFactory.flat(4).toTracking(),
intCol("col", 0, 1, NULL_INT, 3));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> ints.updateBy(UpdateByOperation.EmStd(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");

TableDefaults longs = testTable(RowSetFactory.flat(4).toTracking(),
longCol("col", 0, 1, NULL_LONG, 3));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> longs.updateBy(UpdateByOperation.EmStd(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");

TableDefaults floats = testTable(RowSetFactory.flat(4).toTracking(),
floatCol("col", 0, 1, NULL_FLOAT, Float.NaN));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> floats.updateBy(
UpdateByOperation.EmStd(OperationControl.builder().onNullValue(BadDataBehavior.THROW).build(),
10)),
"Encountered null value during EMS processing");

assertThrows(TableDataException.class,
10)));
err = err.getCause();
Assert.eqTrue(err.getClass() == TableDataException.class,
"err.getClass() == TableDataException.class");
Assert.eqTrue(err.getMessage().contains("Encountered null value during Exponential Moving output processing"),
"err.getMessage().contains(\"Encountered null value during Exponential Moving output processing\")");

err = assertThrows(TableInitializationException.class,
() -> floats.updateBy(
UpdateByOperation.EmStd(OperationControl.builder().onNanValue(BadDataBehavior.THROW).build(),
10)),
"Encountered NaN value during EMS processing");
10)));
err = err.getCause();
Assert.eqTrue(err.getClass() == TableDataException.class,
"err.getClass() == TableDataException.class");
Assert.eqTrue(err.getMessage().contains("Encountered NaN value during Exponential Moving output processing"),
"err.getMessage().contains(\"Encountered NaN value during Exponential Moving output processing\")");

TableDefaults doubles = testTable(RowSetFactory.flat(4).toTracking(),
doubleCol("col", 0, 1, NULL_DOUBLE, Double.NaN));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> doubles.updateBy(
UpdateByOperation.EmStd(OperationControl.builder().onNullValue(BadDataBehavior.THROW).build(),
10)),
"Encountered null value during EMS processing");

assertThrows(TableDataException.class,
10)));
err = err.getCause();
Assert.eqTrue(err.getClass() == TableDataException.class,
"err.getClass() == TableDataException.class");
Assert.eqTrue(err.getMessage().contains("Encountered null value during Exponential Moving output processing"),
"err.getMessage().contains(\"Encountered null value during Exponential Moving output processing\")");

err = assertThrows(TableInitializationException.class,
() -> doubles.updateBy(
UpdateByOperation.EmStd(OperationControl.builder().onNanValue(BadDataBehavior.THROW).build(),
10)),
"Encountered NaN value during EMS processing");
10)));
err = err.getCause();
Assert.eqTrue(err.getClass() == TableDataException.class,
"err.getClass() == TableDataException.class");
Assert.eqTrue(err.getMessage().contains("Encountered NaN value during Exponential Moving output processing"),
"err.getMessage().contains(\"Encountered NaN value during Exponential Moving output processing\")");


TableDefaults bi = testTable(RowSetFactory.flat(4).toTracking(),
col("col", BigInteger.valueOf(0), BigInteger.valueOf(1), null, BigInteger.valueOf(3)));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> bi.updateBy(UpdateByOperation.EmStd(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");

TableDefaults bd = testTable(RowSetFactory.flat(4).toTracking(),
col("col", BigDecimal.valueOf(0), BigDecimal.valueOf(1), null, BigDecimal.valueOf(3)));

assertThrows(TableDataException.class,
err = assertThrows(TableInitializationException.class,
() -> bd.updateBy(UpdateByOperation.EmStd(throwControl, 10)));
Assert.eqTrue(err.getCause().getClass() == TableDataException.class,
"err.getCause().getClass() == TableDataException.class");
}

@Test
Expand Down
Loading

0 comments on commit a6da0eb

Please sign in to comment.