Abacn opened a new issue, #25699:
URL: https://github.com/apache/beam/issues/25699

   ### What happened?
   
   Working example:
   
   ```java
   @RunWith(JUnit4.class)
   public class TestPipelineTest {
   
     @Rule public TestPipeline pipeline = TestPipeline.create();
     @Test
     public void testTestPipelineOptions() {
       pipeline.getOptions().setTempLocation("gs://some-location/");
   
       ArrayList<String> pipelineArgs = new ArrayList<String>();
       pipelineArgs.add("--tempLocation=gs://some-location/");
   
       pipeline.apply(Create.of(1, 2, 3)).apply(new ValidateTempLocation<>());
   
       // PipelineResult.State result = pipeline.run().waitUntilFinish(); // 
<-- replace with run(), test succeeded
       PipelineResult.State result = 
pipeline.runWithAdditionalOptionArgs(pipelineArgs).waitUntilFinish();
       assert(result == PipelineResult.State.DONE);
    }
   
    static class ValidateTempLocation<T> extends PTransform<PCollection<T>, 
PCollection<T>> {
      @Override
      public void validate(PipelineOptions pipelineOptions) {
       assert(!Strings.isNullOrEmpty(pipelineOptions.getTempLocation()));
      }
   
      public PCollection<T> expand(PCollection<T> input) {
        // assert(!Strings.isNullOrEmpty(pipelineOptions.getTempLocation()));
        return input.apply(ParDo.of(new PassthroughFn<>()));
      }
    }
   
    static class PassthroughFn<T> extends DoFn<T, T> {
      @ProcessElement
      public void process(ProcessContext ctx) {
        ctx.output(ctx.element());
      }
    }
   }
   ```
   
   in this example, the pipeline option "tempLocation" is set both manually and 
in pipelineArgs, neither of them was effective. The validate fails with null 
tempLocation.
   
   Actually, the option is present in pipeline expansion time (commented out 
the asset in `expand` verifies this (done when apply() is called). However, the 
pipeline option is just not present in validate time.
   
   If run with run(), instead of `runWithAdditionalOptionArgs()`, test 
succeeded.
   
   
   ### Issue Priority
   
   Priority: 2 (default / most bugs should be filed as P2)
   
   ### Issue Components
   
   - [ ] Component: Python SDK
   - [X] Component: Java SDK
   - [ ] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [ ] Component: IO connector
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Samza Runner
   - [ ] Component: Twister2 Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner


-- 
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]

Reply via email to