johnjcasey commented on issue #21257:
URL: https://github.com/apache/beam/issues/21257#issuecomment-1284352355
I attempted to reproduce this:
```
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.options.PipelineOptionsFactory;
import org.apache.beam.sdk.options.StreamingOptions;
import org.apache.beam.sdk.testing.ExpectedLogs;
import org.apache.beam.sdk.testing.PAssert;
import org.apache.beam.sdk.transforms.Create;
import org.apache.beam.sdk.transforms.DoFn;
import org.apache.beam.sdk.transforms.ParDo;
import org.apache.beam.sdk.values.PCollection;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@RunWith(Parameterized.class)
public class SimpleStreamingTest {
@Rule public ExpectedLogs expectedLogs =
ExpectedLogs.none(SimpleStreamingTest.class);
private static final Logger LOG =
LoggerFactory.getLogger(SimpleStreamingTest.class);
private static final int COUNT = 100;
@Parameterized.Parameters
public static Object[][] data() {
return new Object[100][0];
}
@Test
public void testDoFnSideEffects(){
PipelineOptions options = PipelineOptionsFactory.create();
options.as(StreamingOptions.class).setStreaming(true);
Pipeline testPipeline = Pipeline.create(options);
List<Integer> indexes = IntStream.range(0,
COUNT).boxed().collect(Collectors.toList());
PCollection<Integer> values = testPipeline.apply( "createIndexes",
Create.of(indexes))
.apply("createMessages", ParDo.of(new Counter()));
PAssert.that(values).containsInAnyOrder(indexes);
testPipeline.run().waitUntilFinish();
for(int i : indexes){
expectedLogs.verifyError(String.valueOf(i));
}
}
private static class Counter extends DoFn<Integer,Integer>{
@ProcessElement
public void processElement(@Element Integer i, OutputReceiver<Integer>
receiver){
LOG.error(String.valueOf(i));
receiver.output(i);
}
}
}
```
Running the above 100 times did not result in any failures, so I believe
this issue is not current.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]