use of org.apache.flink.api.common.InvalidProgramException in project flink-mirror by flink-ci.
the class GroupingPojoTranslationTest method testCustomPartitioningTupleInvalidTypeSorted.
@Test
public void testCustomPartitioningTupleInvalidTypeSorted() {
try {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Pojo3> data = env.fromElements(new Pojo3()).rebalance().setParallelism(4);
try {
data.groupBy("a").sortGroup("b", Order.ASCENDING).withPartitioner(new TestPartitionerLong());
fail("Should throw an exception");
} catch (InvalidProgramException e) {
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink-mirror by flink-ci.
the class GroupingPojoTranslationTest method testCustomPartitioningTupleRejectCompositeKey.
@Test
public void testCustomPartitioningTupleRejectCompositeKey() {
try {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Pojo2> data = env.fromElements(new Pojo2()).rebalance().setParallelism(4);
try {
data.groupBy("a", "b").withPartitioner(new TestPartitionerInt());
fail("Should throw an exception");
} catch (InvalidProgramException e) {
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink-mirror by flink-ci.
the class JoinCustomPartitioningTest method testJoinWithKeySelectorsWrongType.
@Test
public void testJoinWithKeySelectorsWrongType() {
try {
final Partitioner<Long> partitioner = new TestPartitionerLong();
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Pojo2> input1 = env.fromElements(new Pojo2());
DataSet<Pojo3> input2 = env.fromElements(new Pojo3());
try {
input1.join(input2, JoinHint.REPARTITION_HASH_FIRST).where(new Pojo2KeySelector()).equalTo(new Pojo3KeySelector()).withPartitioner(partitioner);
fail("should throw an exception");
} catch (InvalidProgramException e) {
// expected
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink-mirror by flink-ci.
the class DeltaIterationTranslationTest method testRejectWhenSolutionSetKeysDontMatchJoin.
@Test
public void testRejectWhenSolutionSetKeysDontMatchJoin() {
try {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
@SuppressWarnings("unchecked") DataSet<Tuple3<Double, Long, String>> initialSolutionSet = env.fromElements(new Tuple3<Double, Long, String>(3.44, 5L, "abc"));
@SuppressWarnings("unchecked") DataSet<Tuple2<Double, String>> initialWorkSet = env.fromElements(new Tuple2<Double, String>(1.23, "abc"));
DeltaIteration<Tuple3<Double, Long, String>, Tuple2<Double, String>> iteration = initialSolutionSet.iterateDelta(initialWorkSet, 10, 1);
try {
iteration.getWorkset().join(iteration.getSolutionSet()).where(1).equalTo(2);
fail("Accepted invalid program.");
} catch (InvalidProgramException e) {
// all good!
}
try {
iteration.getSolutionSet().join(iteration.getWorkset()).where(2).equalTo(1);
fail("Accepted invalid program.");
} catch (InvalidProgramException e) {
// all good!
}
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink-mirror by flink-ci.
the class ClientTest method tryLocalExecution.
/**
* This test verifies that the local execution environment cannot be created when the program is
* submitted through a client.
*/
@Test
public void tryLocalExecution() throws ProgramInvocationException, ProgramMissingJobException {
PackagedProgram packagedProgramMock = mock(PackagedProgram.class);
when(packagedProgramMock.getUserCodeClassLoader()).thenReturn(packagedProgramMock.getClass().getClassLoader());
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
ExecutionEnvironment.createLocalEnvironment();
return null;
}
}).when(packagedProgramMock).invokeInteractiveModeForExecution();
try {
final ClusterClient<?> client = new MiniClusterClient(new Configuration(), MINI_CLUSTER_RESOURCE.getMiniCluster());
final Configuration configuration = fromPackagedProgram(packagedProgramMock, 1, true);
ClientUtils.executeProgram(new TestExecutorServiceLoader(client, plan), configuration, packagedProgramMock, false, false);
fail("Creating the local execution environment should not be possible");
} catch (InvalidProgramException e) {
// that is what we want
}
}
Aggregations