From 6ce163197d5da03d4750fc89bf617863b385d071 Mon Sep 17 00:00:00 2001 From: Thomas Groh Date: Wed, 3 May 2017 10:53:12 -0700 Subject: [PATCH] Shade Additional Direct Runner Dependencies Add a DirectRunner API Surface Test. Repackaging runners-core appears to cause the direct runner to hang. Investigations in progress. --- runners/direct-java/pom.xml | 68 +++++++++++++++++-- .../direct/DirectRunnerApiSurfaceTest.java | 55 +++++++++++++++ .../apache/beam/runners/direct/MockClock.java | 2 +- 3 files changed, 118 insertions(+), 7 deletions(-) create mode 100644 runners/direct-java/src/test/java/org/apache/beam/runners/direct/DirectRunnerApiSurfaceTest.java diff --git a/runners/direct-java/pom.xml b/runners/direct-java/pom.xml index ba3cd3ea04b1..1ef2f3843aa5 100644 --- a/runners/direct-java/pom.xml +++ b/runners/direct-java/pom.xml @@ -77,6 +77,68 @@ + + org.apache.maven.plugins + maven-shade-plugin + + + bundle-and-repackage + package + + shade + + + + + com.google.guava:guava + com.google.protobuf:protobuf-java + org.apache.beam:beam-runners-core-construction-java + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + org.apache.beam.runners.core.construction + + org.apache.beam.runners.direct.repackaged.runners.core.construction + + + + com.google.common + + org.apache.beam.runners.direct.repackaged.com.google.common + + + + com.google.protobuf + + org.apache.beam.runners.direct.repackaged.com.google.protobuf + + + + com.google.thirdparty + + org.apache.beam.runners.direct.repackaged.com.google.thirdparty + + + + + + + + + + + org.jacoco @@ -101,12 +163,6 @@ beam-runners-core-java - - com.google.http-client - google-http-client-protobuf - runtime - - com.google.guava guava diff --git a/runners/direct-java/src/test/java/org/apache/beam/runners/direct/DirectRunnerApiSurfaceTest.java b/runners/direct-java/src/test/java/org/apache/beam/runners/direct/DirectRunnerApiSurfaceTest.java new file mode 100644 index 000000000000..9928cb0d36b7 --- /dev/null +++ b/runners/direct-java/src/test/java/org/apache/beam/runners/direct/DirectRunnerApiSurfaceTest.java @@ -0,0 +1,55 @@ +/* + * 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.direct; + +import static org.apache.beam.sdk.util.ApiSurface.containsOnlyPackages; +import static org.junit.Assert.assertThat; + +import com.google.common.collect.ImmutableSet; +import java.util.Set; +import javax.annotation.Nullable; +import org.apache.beam.sdk.util.ApiSurface; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** API surface verification for {@link org.apache.beam.runners.direct}. */ +@RunWith(JUnit4.class) +public class DirectRunnerApiSurfaceTest { + @Test + public void testDirectRunnerApiSurface() throws Exception { + // The DirectRunner can expose the Core SDK, anything exposed by the Core SDK, and itself + @SuppressWarnings("unchecked") + final Set allowed = + ImmutableSet.of("org.apache.beam.sdk", "org.apache.beam.runners.direct", "org.joda.time"); + + final Package thisPackage = getClass().getPackage(); + final ClassLoader thisClassLoader = getClass().getClassLoader(); + ApiSurface apiSurface = + ApiSurface.ofPackage(thisPackage, thisClassLoader) + .pruningPattern("org[.]apache[.]beam[.].*Test.*") + .pruningPattern("org[.]apache[.]beam[.].*IT") + .pruningClass(Nullable.class) + .pruningPattern("java[.]io.*") + .pruningPattern("java[.]lang.*") + .pruningPattern("java[.]util.*"); + + assertThat(apiSurface, containsOnlyPackages(allowed)); + } +} diff --git a/runners/direct-java/src/test/java/org/apache/beam/runners/direct/MockClock.java b/runners/direct-java/src/test/java/org/apache/beam/runners/direct/MockClock.java index 11ecbff91d52..9275e3c1096b 100644 --- a/runners/direct-java/src/test/java/org/apache/beam/runners/direct/MockClock.java +++ b/runners/direct-java/src/test/java/org/apache/beam/runners/direct/MockClock.java @@ -28,7 +28,7 @@ * *

For uses of the {@link Clock} interface in unit tests. */ -public class MockClock implements Clock { +class MockClock implements Clock { private Instant now;