You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by pa...@apache.org on 2022/11/04 21:30:26 UTC
[beam] branch master updated: Enable more portable-runner requiring tests. (#23970)
This is an automated email from the ASF dual-hosted git repository.
pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 6d42219ff54 Enable more portable-runner requiring tests. (#23970)
6d42219ff54 is described below
commit 6d42219ff547720996489aa29de0d64246db2541
Author: Robert Bradshaw <ro...@gmail.com>
AuthorDate: Fri Nov 4 14:30:18 2022 -0700
Enable more portable-runner requiring tests. (#23970)
* Enable more portable-runner requiring tests.
* Run all basic tests on portable runner as well.
* Mark ULR tests.
---
.github/workflows/typescript_tests.yml | 2 +-
sdks/typescript/src/apache_beam/runners/runner.ts | 11 ++--
sdks/typescript/test/docs/programming_guide.ts | 28 +++++++---
sdks/typescript/test/primitives_test.ts | 64 +++++++++++++++++++----
4 files changed, 83 insertions(+), 22 deletions(-)
diff --git a/.github/workflows/typescript_tests.yml b/.github/workflows/typescript_tests.yml
index be557f56b08..41b1ad4019e 100644
--- a/.github/workflows/typescript_tests.yml
+++ b/.github/workflows/typescript_tests.yml
@@ -99,7 +99,7 @@ jobs:
working-directory: ./sdks/typescript
- run: npm run build
working-directory: ./sdks/typescript
- - run: npm test -- --grep "@xlang"
+ - run: npm test -- --grep "@xlang" --grep "@ulr"
working-directory: ./sdks/typescript
env:
BEAM_SERVICE_OVERRIDES: '{"python:*": "python"}'
diff --git a/sdks/typescript/src/apache_beam/runners/runner.ts b/sdks/typescript/src/apache_beam/runners/runner.ts
index cd04c441f08..7f0d716ef7f 100644
--- a/sdks/typescript/src/apache_beam/runners/runner.ts
+++ b/sdks/typescript/src/apache_beam/runners/runner.ts
@@ -130,10 +130,15 @@ export function defaultRunner(defaultOptions: Object): Runner {
if (directRunner.unsupportedFeatures(pipeline, options).length === 0) {
return directRunner.runPipeline(pipeline, options);
} else {
- return require("./universal")
- .universalRunner({ environmentType: "LOOPBACK", ...defaultOptions })
- .runPipeline(pipeline, options);
+ return loopbackRunner(defaultOptions).runPipeline(pipeline, options);
}
}
})();
}
+
+export function loopbackRunner(defaultOptions: Object = {}): Runner {
+ return require("./universal").universalRunner({
+ environmentType: "LOOPBACK",
+ ...defaultOptions,
+ });
+}
diff --git a/sdks/typescript/test/docs/programming_guide.ts b/sdks/typescript/test/docs/programming_guide.ts
index 254d867d5f0..cd8d0735a9e 100644
--- a/sdks/typescript/test/docs/programming_guide.ts
+++ b/sdks/typescript/test/docs/programming_guide.ts
@@ -36,15 +36,30 @@ import {
pythonCallable,
} from "../../src/apache_beam/transforms/python";
import * as service from "../../src/apache_beam/utils/service";
+import { loopbackRunner } from "../../src/apache_beam/runners/runner";
import { assertDeepEqual } from "../../src/apache_beam/testing/assert";
let subprocessCache;
-before(() => {
+before(async function () {
+ this.timeout(30000);
subprocessCache = service.SubprocessService.createCache();
+ if (process.env.BEAM_SERVICE_OVERRIDES) {
+ // Start it up here so we don't timeout any individual test.
+ await loopbackRunner().run(function pipeline(root) {
+ root.apply(beam.impulse());
+ });
+ }
});
after(() => subprocessCache.stopAll());
+function needs_ulr_it(name, fn) {
+ return (process.env.BEAM_SERVICE_OVERRIDES ? it : it.skip)(
+ name + " @ulr",
+ fn
+ );
+}
+
describe("Programming Guide Tested Samples", function () {
describe("Pipelines", function () {
it("pipelines_constructing_creating", async function () {
@@ -593,8 +608,7 @@ describe("Programming Guide Tested Samples", function () {
});
});
- // TODO: Enable cross-language after next release or set up dev virtual env.
- xit("session_windows", async function () {
+ needs_ulr_it("session_windows", async function () {
await beam.createRunner().run(async (root: beam.Root) => {
const pcoll = root
.apply(beam.create([1, 2, 600, 1800, 1900]))
@@ -680,8 +694,8 @@ describe("Programming Guide Tested Samples", function () {
});
// TODO: Enable cross-language after next release or set up dev virtual env.
- xdescribe("MultiLangauge", function () {
- it("python_map", async function () {
+ describe("MultiLangauge", function () {
+ needs_ulr_it("python_map", async function () {
await beam.createRunner().run(async (root: beam.Root) => {
const pcoll = root.apply(
beam.create([
@@ -711,7 +725,7 @@ describe("Programming Guide Tested Samples", function () {
});
}).timeout(10000);
- it("stateful_dofn", async function () {
+ needs_ulr_it("stateful_dofn", async function () {
await beam.createRunner().run(async (root: beam.Root) => {
// [START stateful_dofn]
const pcoll = root.apply(
@@ -759,7 +773,7 @@ describe("Programming Guide Tested Samples", function () {
});
}).timeout(10000);
- it("cross_lang_transform", async function () {
+ needs_ulr_it("cross_lang_transform", async function () {
await beam.createRunner().run(async (root: beam.Root) => {
const pcoll = root.apply(beam.create(["a", "bb"]));
// [START cross_lang_transform]
diff --git a/sdks/typescript/test/primitives_test.ts b/sdks/typescript/test/primitives_test.ts
index 300fae0047d..8259754ede1 100644
--- a/sdks/typescript/test/primitives_test.ts
+++ b/sdks/typescript/test/primitives_test.ts
@@ -29,17 +29,50 @@ import * as combiners from "../src/apache_beam/transforms/combiners";
import { GeneralObjectCoder } from "../src/apache_beam/coders/js_coders";
import { DirectRunner } from "../src/apache_beam/runners/direct_runner";
-import { PortableRunner } from "../src/apache_beam/runners/portable_runner/runner";
+import { loopbackRunner } from "../src/apache_beam/runners/runner";
import { Pipeline } from "../src/apache_beam/internal/pipeline";
import * as testing from "../src/apache_beam/testing/assert";
import * as windowings from "../src/apache_beam/transforms/windowings";
import * as pardo from "../src/apache_beam/transforms/pardo";
import { withName } from "../src/apache_beam/transforms";
+import * as service from "../src/apache_beam/utils/service";
+
+let subprocessCache;
+before(async function () {
+ this.timeout(30000);
+ subprocessCache = service.SubprocessService.createCache();
+ if (process.env.BEAM_SERVICE_OVERRIDES) {
+ // Start it up here so we don't timeout any individual test.
+ await loopbackRunner().run(function pipeline(root) {
+ root.apply(beam.impulse());
+ });
+ }
+});
+
+after(() => subprocessCache.stopAll());
+
+export function suite(runner: beam.Runner = new DirectRunner()) {
+ describe("testing.assertDeepEqual", function () {
+ // The tests below won't catch failures if this doesn't fail.
+ it("fails on bad assert", async function () {
+ // TODO: There's probably a more idiomatic way to test failures.
+ var seenError = false;
+ try {
+ await runner.run((root) => {
+ const pcolls = root
+ .apply(beam.create([1, 2, 3]))
+ .apply(testing.assertDeepEqual([1, 2]));
+ });
+ } catch (Error) {
+ seenError = true;
+ }
+ assert.equal(true, seenError);
+ });
+ });
-describe("primitives module", function () {
describe("runs basic transforms", function () {
it("runs a map", async function () {
- await new DirectRunner().run((root) => {
+ await runner.run((root) => {
const pcolls = root
.apply(beam.create([1, 2, 3]))
.map((x) => x * x)
@@ -48,7 +81,7 @@ describe("primitives module", function () {
});
it("runs a flatmap", async function () {
- await new DirectRunner().run((root) => {
+ await runner.run((root) => {
const pcolls = root
.apply(beam.create(["a b", "c"]))
.flatMap((s) => s.split(/ +/))
@@ -57,7 +90,7 @@ describe("primitives module", function () {
});
it("runs a Splitter", async function () {
- await new DirectRunner().run((root) => {
+ await runner.run((root) => {
const pcolls = root
.apply(beam.create([{ a: 1 }, { b: 10 }, { a: 2, b: 20 }]))
.apply(beam.split(["a", "b"], { exclusive: false }));
@@ -67,7 +100,7 @@ describe("primitives module", function () {
});
it("runs a map with context", async function () {
- await new DirectRunner().run((root) => {
+ await runner.run((root) => {
root
.apply(beam.create([1, 2, 3]))
.map((a: number, b: number) => a + b, 100)
@@ -107,7 +140,7 @@ describe("primitives module", function () {
});
it("runs a map with singleton side input", async function () {
- await new DirectRunner().run((root) => {
+ await runner.run((root) => {
const input = root.apply(beam.create([1, 2, 1]));
const sideInput = root.apply(
beam.withName("createSide", beam.create([4]))
@@ -121,7 +154,7 @@ describe("primitives module", function () {
});
it("runs a map with a side input sharing input root", async function () {
- await new DirectRunner().run((root) => {
+ await runner.run((root) => {
const input = root.apply(beam.create([1, 2, 1]));
// TODO: Can this type be inferred?
const sideInput: beam.PCollection<{ sum: number }> = input.apply(
@@ -136,7 +169,7 @@ describe("primitives module", function () {
});
it("runs a map with window-sensitive context", async function () {
- await new DirectRunner().run((root) => {
+ await runner.run((root) => {
root
.apply(beam.create([1, 2, 3, 4, 5, 10, 11, 12]))
.apply(beam.assignTimestamps((t) => Long.fromValue(t * 1000)))
@@ -171,7 +204,7 @@ describe("primitives module", function () {
});
it("runs a WindowInto", async function () {
- await new DirectRunner().run((root) => {
+ await runner.run((root) => {
root
.apply(beam.create(["apple", "apricot", "banana"]))
.apply(beam.windowInto(windowings.globalWindows()))
@@ -186,7 +219,7 @@ describe("primitives module", function () {
});
it("runs a WindowInto IntervalWindow", async function () {
- await new DirectRunner().run((root) => {
+ await runner.run((root) => {
root
.apply(beam.create([1, 2, 3, 4, 5, 10, 11, 12]))
.apply(beam.assignTimestamps((t) => Long.fromValue(t * 1000)))
@@ -247,4 +280,13 @@ describe("primitives module", function () {
);
});
});
+}
+
+describe("primitives module", function () {
+ describe("direct runner", suite.bind(this));
+ if (process.env.BEAM_SERVICE_OVERRIDES) {
+ describe("portable runner @ulr", () => {
+ suite.bind(this)(loopbackRunner());
+ });
+ }
});