You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by st...@apache.org on 2017/02/26 15:29:08 UTC
[1/2] beam git commit: Updated TestPipeline's javadoc.
Repository: beam
Updated Branches:
refs/heads/master 38a01e9cf -> 4bba380cb
Updated TestPipeline's javadoc.
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/acc10130
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/acc10130
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/acc10130
Branch: refs/heads/master
Commit: acc10130982168ad5c4f29b2af3be67e53f7c967
Parents: 38a01e9
Author: Stas Levin <st...@gmail.com>
Authored: Fri Feb 24 00:02:14 2017 +0200
Committer: Stas Levin <st...@apache.org>
Committed: Sun Feb 26 17:28:05 2017 +0200
----------------------------------------------------------------------
.../apache/beam/sdk/testing/TestPipeline.java | 42 +++++++++++++++-----
1 file changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/beam/blob/acc10130/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java
index 02eefa9..6c5244d 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java
@@ -79,17 +79,23 @@ import org.junit.runners.model.Statement;
* <p>Use {@link PAssert} for tests, as it integrates with this test harness in both direct and
* remote execution modes. For example:
*
- * <pre>{@code
- * Pipeline p = TestPipeline.create();
- * PCollection<Integer> output = ...
+ * <pre><code>
+ * {@literal @Rule}
+ * public final transient TestPipeline p = TestPipeline.create();
*
- * PAssert.that(output)
- * .containsInAnyOrder(1, 2, 3, 4);
- * p.run();
- * }</pre>
+ * {@literal @Test}
+ * {@literal @Category}(NeedsRunner.class)
+ * public void myPipelineTest() throws Exception {
+ * final PCollection<String> pCollection = pipeline.apply(...)
+ * PAssert.that(pCollection).containsInAnyOrder(...);
+ * pipeline.run();
+ * }
+ * </code></pre>
*
* <p>For pipeline runners, it is required that they must throw an {@link AssertionError} containing
- * the message from the {@link PAssert} that failed.
+ * the message from the {@link PAssert} that failed.</p>
+ * <p>See also the <a href="https://beam.apache.org/contribute/testing/">Testing</a> documentation
+ * section.</p>
*/
public class TestPipeline extends Pipeline implements TestRule {
@@ -292,8 +298,8 @@ public class TestPipeline extends Pipeline implements TestRule {
public PipelineResult run() {
checkState(
enforcement.isPresent(),
- "Attempted to run a pipeline while it's enforcement level was not set. Are you "
- + "using TestPipeline without a @Rule annotation?");
+ "Is your TestPipeline declaration missing a @Rule annotation? Usage: "
+ + "@Rule public final transient TestPipeline pipeline = TestPipeline.Create();");
try {
return super.run();
@@ -309,6 +315,18 @@ public class TestPipeline extends Pipeline implements TestRule {
}
}
+ /**
+ * Enables the abandoned node detection. Abandoned nodes are <code>PTransforms</code>, <code>
+ * PAsserts</code> included, that were not executed by the pipeline runner. Abandoned nodes are
+ * most likely to occur due to the one of the following scenarios:
+ * <ul>
+ * <li>Lack of a <code>pipeline.run()</code> statement at the end of a test.
+ * <li>Addition of PTransforms after the pipeline has already run.
+ * </ul>
+ * Abandoned node detection is automatically enabled when a real pipeline runner (i.e. not a
+ * {@link CrashingRunner}) and/or a {@link NeedsRunner} or a {@link RunnableOnService} annotation
+ * are detected.
+ */
public TestPipeline enableAbandonedNodeEnforcement(final boolean enable) {
enforcement =
enable
@@ -318,6 +336,10 @@ public class TestPipeline extends Pipeline implements TestRule {
return this;
}
+ /**
+ * If enabled, a <code>pipeline.run()</code> statement will be added automatically in case it is
+ * missing in the test.
+ */
public TestPipeline enableAutoRunIfMissing(final boolean enable) {
enforcement.get().enableAutoRunIfMissing(enable);
return this;
[2/2] beam git commit: This closes #2089
Posted by st...@apache.org.
This closes #2089
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/4bba380c
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/4bba380c
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/4bba380c
Branch: refs/heads/master
Commit: 4bba380cb011e38bd78c1ec899a6672a6b02fd05
Parents: 38a01e9 acc1013
Author: Stas Levin <st...@apache.org>
Authored: Sun Feb 26 17:28:26 2017 +0200
Committer: Stas Levin <st...@apache.org>
Committed: Sun Feb 26 17:28:26 2017 +0200
----------------------------------------------------------------------
.../apache/beam/sdk/testing/TestPipeline.java | 42 +++++++++++++++-----
1 file changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------