writing tests for my program

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

writing tests for my program

igor.berman
Any idea how to handle following(the message is clear, but I'm not sure what I need to do)
I'm opening "generic" environment in my code (StreamExecutionEnvironment.getExecutionEnvironment())

and JavaProgramTestBase configures TestEnvironment...
so what I should do to support custom tests?




Error:
The LocalStreamEnvironment cannot be used when submitting a program through a client, or running in a TestEnvironment context.
org.apache.flink.api.common.InvalidProgramException: The LocalStreamEnvironment cannot be used when submitting a program through a client, or running in a TestEnvironment context.
at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.<init>(LocalStreamEnvironment.java:67)
at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.<init>(LocalStreamEnvironment.java:57)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.createLocalEnvironment(StreamExecutionEnvironment.java:1299)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.createLocalEnvironment(StreamExecutionEnvironment.java:1285)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getExecutionEnvironment(StreamExecutionEnvironment.java:1271)
at com.x.x.StreamConsumer.configureEnv(StreamConsumer.java:150)


The error happens when using 
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
in my program


test is something like:

public class StreamConsumerTest extends JavaProgramTestBase {

@Override
protected void preSubmit() throws Exception {

}

@Override
protected void postSubmit() throws Exception {
}
@Override
protected void testProgram() throws Exception {
StreamConsumer.main(new String[] {
"--" + StreamConsumer.CONF_PARAM, "conf/test",
});
}

}

Reply | Threaded
Open this post in threaded view
|

Re: writing tests for my program

igor.berman
answering my own question:
testing streaming environment should be done with StreamingProgramTestBase & TestStreamEnvironment which are present in test package of flink-streaming-java project so it's not directly available?

Project owners, why not to move above two to flink-test-utils? Or I don't understand something?



On 9 May 2016 at 19:37, Igor Berman <[hidden email]> wrote:
Any idea how to handle following(the message is clear, but I'm not sure what I need to do)
I'm opening "generic" environment in my code (StreamExecutionEnvironment.getExecutionEnvironment())

and JavaProgramTestBase configures TestEnvironment...
so what I should do to support custom tests?




Error:
The LocalStreamEnvironment cannot be used when submitting a program through a client, or running in a TestEnvironment context.
org.apache.flink.api.common.InvalidProgramException: The LocalStreamEnvironment cannot be used when submitting a program through a client, or running in a TestEnvironment context.
at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.<init>(LocalStreamEnvironment.java:67)
at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.<init>(LocalStreamEnvironment.java:57)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.createLocalEnvironment(StreamExecutionEnvironment.java:1299)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.createLocalEnvironment(StreamExecutionEnvironment.java:1285)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getExecutionEnvironment(StreamExecutionEnvironment.java:1271)
at com.x.x.StreamConsumer.configureEnv(StreamConsumer.java:150)


The error happens when using 
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
in my program


test is something like:

public class StreamConsumerTest extends JavaProgramTestBase {

@Override
protected void preSubmit() throws Exception {

}

@Override
protected void postSubmit() throws Exception {
}
@Override
protected void testProgram() throws Exception {
StreamConsumer.main(new String[] {
"--" + StreamConsumer.CONF_PARAM, "conf/test",
});
}

}


Reply | Threaded
Open this post in threaded view
|

Re: writing tests for my program

lofifnc
Hi,

Some shameless self promotion:

You can also checkout:
https://github.com/ottogroup/flink-spector
which has to the goal to remove such hurdles when testing flink programs.

Best,
Alex

 
Reply | Threaded
Open this post in threaded view
|

Re: writing tests for my program

igor.berman
thanks Alexander, I'll take a look


On 10 May 2016 at 13:07, lofifnc <[hidden email]> wrote:
Hi,

Some shameless self promotion:

You can also checkout:
https://github.com/ottogroup/flink-spector
which has to the goal to remove such hurdles when testing flink programs.

Best,
Alex





--
View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/writing-tests-for-my-program-tp6784p6801.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.