Skip to content

Commit

Permalink
Remove usage of @test with exceptions in operator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Damans227 authored and ebyhr committed Oct 7, 2021
1 parent c6a80cc commit 3203ec2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.concurrent.atomic.AtomicInteger;

import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
Expand Down Expand Up @@ -78,11 +79,13 @@ public void testRevocationAlreadyRequested()
assertEquals(counter.get(), 1);
}

@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "listener already set")
@Test
public void testSingleListenerEnforcement()
{
OperatorContext operatorContext = TestingOperatorContext.create(scheduledExecutor);
operatorContext.setMemoryRevocationRequestListener(() -> {});
operatorContext.setMemoryRevocationRequestListener(() -> {});
assertThatThrownBy(() -> operatorContext.setMemoryRevocationRequestListener(() -> {}))
.isInstanceOf(IllegalStateException.class)
.hasMessage("listener already set");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import static java.lang.String.format;
import static java.util.concurrent.Executors.newCachedThreadPool;
import static java.util.concurrent.Executors.newScheduledThreadPool;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

Expand Down Expand Up @@ -232,7 +233,7 @@ public void testReverseOrder(boolean spillEnabled, boolean revokeMemoryWhenAddin
assertOperatorEquals(operatorFactory, driverContext, input, expected, revokeMemoryWhenAddingPages);
}

@Test(expectedExceptions = ExceededMemoryLimitException.class, expectedExceptionsMessageRegExp = "Query exceeded per-node user memory limit of 10B.*")
@Test
public void testMemoryLimit()
{
List<Page> input = rowPagesBuilder(BIGINT, DOUBLE)
Expand Down Expand Up @@ -260,7 +261,9 @@ public void testMemoryLimit()
Optional.of(spillerFactory),
new OrderingCompiler(typeOperators));

toPages(operatorFactory, driverContext, input);
assertThatThrownBy(() -> toPages(operatorFactory, driverContext, input))
.isInstanceOf(ExceededMemoryLimitException.class)
.hasMessageMatching("Query exceeded per-node user memory limit of 10B.*");
}

private DriverContext createDriverContext(long memoryLimit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ public void testOuterJoinWithNullOnBothSidesAndFilterFunction(boolean parallelBu
assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true, false).addDriverContext(), probeInput, expected, true, getHashChannels(probePages, buildPages));
}

@Test(expectedExceptions = ExceededMemoryLimitException.class, expectedExceptionsMessageRegExp = "Query exceeded per-node user memory limit of.*", dataProvider = "testMemoryLimitProvider")
@Test(dataProvider = "testMemoryLimitProvider")
public void testMemoryLimit(boolean parallelBuild, boolean buildHashEnabled)
{
TaskContext taskContext = TestingTaskContext.createTaskContext(executor, scheduledExecutor, TEST_SESSION, DataSize.ofBytes(100));
Expand All @@ -1210,7 +1210,10 @@ public void testMemoryLimit(boolean parallelBuild, boolean buildHashEnabled)
.addSequencePage(10, 20, 30, 40);
BuildSideSetup buildSideSetup = setupBuildSide(nodePartitioningManager, parallelBuild, taskContext, buildPages, Optional.empty(), false, SINGLE_STREAM_SPILLER_FACTORY);
instantiateBuildDrivers(buildSideSetup, taskContext);
buildLookupSource(executor, buildSideSetup);

assertThatThrownBy(() -> buildLookupSource(executor, buildSideSetup))
.isInstanceOf(ExceededMemoryLimitException.class)
.hasMessageMatching("Query exceeded per-node user memory limit of.*");
}

@Test(dataProvider = "hashJoinTestValues")
Expand Down

0 comments on commit 3203ec2

Please sign in to comment.