-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-259] Configure RunnableOnService tests for Spark runner, batch mode #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.beam.runners.spark; | ||
|
|
||
| import org.apache.beam.sdk.Pipeline; | ||
| import org.apache.beam.sdk.options.PipelineOptions; | ||
| import org.apache.beam.sdk.options.PipelineOptionsValidator; | ||
| import org.apache.beam.sdk.runners.PipelineRunner; | ||
| import org.apache.beam.sdk.transforms.PTransform; | ||
| import org.apache.beam.sdk.values.PInput; | ||
| import org.apache.beam.sdk.values.POutput; | ||
|
|
||
| /** | ||
| * The SparkPipelineRunner translate operations defined on a pipeline to a representation executable | ||
| * by Spark, and then submitting the job to Spark to be executed. If we wanted to run a dataflow | ||
| * pipeline with the default options of a single threaded spark instance in local mode, we would do | ||
| * the following: | ||
| * | ||
| * {@code | ||
| * Pipeline p = [logic for pipeline creation] | ||
| * EvaluationResult result = SparkPipelineRunner.create().run(p); | ||
| * } | ||
| * | ||
| * To create a pipeline runner to run against a different spark cluster, with a custom master url we | ||
| * would do the following: | ||
| * | ||
| * {@code | ||
| * Pipeline p = [logic for pipeline creation] | ||
| * SparkPipelineOptions options = SparkPipelineOptionsFactory.create(); | ||
| * options.setSparkMaster("spark://host:port"); | ||
| * EvaluationResult result = SparkPipelineRunner.create(options).run(p); | ||
| * } | ||
| * | ||
| * To create a Spark streaming pipeline runner use {@link SparkStreamingPipelineOptions} | ||
| */ | ||
| public final class TestSparkPipelineRunner extends PipelineRunner<EvaluationResult> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps you don't - it is really just a hook to set configuration options. I see some test cases that seem to set them up prior to the run, so this might be a place for that knowledge to reside. You could do it in the pom, too.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really mind the additional class, but am wondering if you see some future use for it ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment of yours was prescient; I don't know if it is in the way you meant. The |
||
|
|
||
| private SparkPipelineRunner delegate; | ||
|
|
||
| private TestSparkPipelineRunner(SparkPipelineOptions options) { | ||
| this.delegate = SparkPipelineRunner.fromOptions(options); | ||
| } | ||
|
|
||
| public static TestSparkPipelineRunner fromOptions(PipelineOptions options) { | ||
| // Default options suffice to set it up as a test runner | ||
| SparkPipelineOptions sparkOptions = | ||
| PipelineOptionsValidator.validate(SparkPipelineOptions.class, options); | ||
| return new TestSparkPipelineRunner(sparkOptions); | ||
| } | ||
|
|
||
| @Override | ||
| public <OutputT extends POutput, InputT extends PInput> | ||
| OutputT apply(PTransform<InputT, OutputT> transform, InputT input) { | ||
| return delegate.apply(transform, input); | ||
| }; | ||
|
|
||
| @Override | ||
| public EvaluationResult run(Pipeline pipeline) { | ||
| return delegate.run(pipeline); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's something amiss with the maven config, as omitting this results in
ClassDefNotFoundlooking for Mockito classes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the table here: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html the runner has a scope test dependency on java-sdk-all (classifier tests), and it (java-sdk-all) has a scope test dependency on mockito, so it's not transitive anymore..
Actually it seems as if scope test is never transitive..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, I think I see. To get the behavior automatically, we would probably need a
java-sdk-testsartifact with acompile-scoped dependency for everything that is currently atest-scoped dependency. I propose solving this in the future instead of now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree