diff --git a/.github/trigger_files/beam_PostCommit_Java_ValidatesRunner_Dataflow_V2_Streaming.json b/.github/trigger_files/beam_PostCommit_Java_ValidatesRunner_Dataflow_V2_Streaming.json
index 7dab8be7160a..c4edaa85a89d 100644
--- a/.github/trigger_files/beam_PostCommit_Java_ValidatesRunner_Dataflow_V2_Streaming.json
+++ b/.github/trigger_files/beam_PostCommit_Java_ValidatesRunner_Dataflow_V2_Streaming.json
@@ -1,7 +1,3 @@
{
- "https://github.com/apache/beam/pull/34902": "Introducing OutputBuilder",
- "comment": "Modify this file in a trivial way to cause this test suite to run",
- "https://github.com/apache/beam/pull/31156": "noting that PR #31156 should run this test",
- "https://github.com/apache/beam/pull/31268": "noting that PR #31268 should run this test",
- "https://github.com/apache/beam/pull/31490": "noting that PR #31490 should run this test"
+ "comment": "Modify this file in a trivial way to cause this test suite to run"
}
diff --git a/runners/google-cloud-dataflow-java/build.gradle b/runners/google-cloud-dataflow-java/build.gradle
index bafba869b3c1..17594ded5ed7 100644
--- a/runners/google-cloud-dataflow-java/build.gradle
+++ b/runners/google-cloud-dataflow-java/build.gradle
@@ -276,7 +276,7 @@ def createRunnerV2ValidatesRunnerTest = { Map args ->
testClassesDirs = files(project(":sdks:java:core").sourceSets.test.output.classesDirs) +
files(project(project.path).sourceSets.test.output.classesDirs)
useJUnit {
- includeCategories 'org.apache.beam.sdk.testing.ValidatesRunner'
+ includeCategories 'org.apache.beam.sdk.testing.RerunTest'
commonRunnerV2ExcludeCategories.each {
excludeCategories it
}
@@ -440,6 +440,7 @@ task validatesRunnerStreaming {
name: 'validatesRunnerLegacyWorkerTestStreaming',
pipelineOptions: legacyPipelineOptions + ['--streaming'],
excludedCategories: [
+ 'org.apache.beam.sdk.testing.BatchOnly',
'org.apache.beam.sdk.testing.UsesCommittedMetrics',
'org.apache.beam.sdk.testing.UsesMapState',
'org.apache.beam.sdk.testing.UsesRequiresTimeSortedInput',
@@ -550,6 +551,7 @@ task validatesRunnerV2Streaming {
name: 'validatesRunnerV2TestStreaming',
pipelineOptions: runnerV2PipelineOptions + ['--streaming', '--experiments=enable_streaming_engine'],
excludedCategories: [
+ 'org.apache.beam.sdk.testing.BatchOnly',
'org.apache.beam.sdk.testing.LargeKeys$Above10KB',
'org.apache.beam.sdk.testing.UsesBoundedSplittableParDo',
'org.apache.beam.sdk.testing.UsesCommittedMetrics',
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/BatchOnly.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/BatchOnly.java
new file mode 100644
index 000000000000..80f85722e123
--- /dev/null
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/BatchOnly.java
@@ -0,0 +1,29 @@
+/*
+ * 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.sdk.testing;
+
+import org.apache.beam.sdk.annotations.Internal;
+
+/**
+ * Category tag for validation tests run on batch mode only.
+ *
+ *
Used to dedup tests from streaming test suites as long as its batch counterpart running the
+ * same test is considered sufficient.
+ */
+@Internal
+public interface BatchOnly {}
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/RerunTest.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/RerunTest.java
new file mode 100644
index 000000000000..5e78e61e8a0e
--- /dev/null
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/RerunTest.java
@@ -0,0 +1,29 @@
+/*
+ * 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.sdk.testing;
+
+import org.apache.beam.sdk.annotations.Internal;
+
+/**
+ * Category tag for validation tests run on batch mode only.
+ *
+ *
Used to dedup tests from streaming test suites as long as its batch counterpart running the
+ * same test is considered sufficient.
+ */
+@Internal
+public interface RerunTest {}
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/CombineTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/CombineTest.java
index 993b84a528d7..8ee23947c31d 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/CombineTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/CombineTest.java
@@ -53,6 +53,7 @@
import org.apache.beam.sdk.coders.StringUtf8Coder;
import org.apache.beam.sdk.coders.VarIntCoder;
import org.apache.beam.sdk.coders.VoidCoder;
+import org.apache.beam.sdk.testing.BatchOnly;
import org.apache.beam.sdk.testing.NeedsRunner;
import org.apache.beam.sdk.testing.PAssert;
import org.apache.beam.sdk.testing.TestPipeline;
@@ -665,13 +666,13 @@ public void testSimpleCombine() {
}
@Test
- @Category({ValidatesRunner.class, UsesSideInputs.class})
+ @Category({ValidatesRunner.class, UsesSideInputs.class, BatchOnly.class})
public void testSimpleCombineEmpty() {
runTestSimpleCombine(EMPTY_TABLE, 0, Collections.emptyList());
}
@Test
- @Category({ValidatesRunner.class, UsesSideInputs.class})
+ @Category({ValidatesRunner.class, UsesSideInputs.class, BatchOnly.class})
public void testBasicCombine() {
runTestBasicCombine(
Arrays.asList(KV.of("a", 1), KV.of("a", 1), KV.of("a", 4), KV.of("b", 1), KV.of("b", 13)),
@@ -682,7 +683,7 @@ public void testBasicCombine() {
}
@Test
- @Category({ValidatesRunner.class, UsesSideInputs.class})
+ @Category({ValidatesRunner.class, UsesSideInputs.class, BatchOnly.class})
public void testBasicCombineEmpty() {
runTestBasicCombine(EMPTY_TABLE, ImmutableSet.of(), Collections.emptyList());
}
@@ -702,7 +703,7 @@ public void testCombinerNames() {
}
@Test
- @Category({ValidatesRunner.class})
+ @Category({ValidatesRunner.class, BatchOnly.class})
public void testHotKeyCombining() {
PCollection> input =
copy(
@@ -839,7 +840,7 @@ public void populateDisplayData(DisplayData.Builder builder) {
}
@Test
- @Category(ValidatesRunner.class)
+ @Category({ValidatesRunner.class, BatchOnly.class})
public void testCombinePerKeyPrimitiveDisplayData() {
DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
@@ -909,7 +910,7 @@ public void testCombinePerKeyLambda() {
/** Tests creation of a per-key binary {@link Combine} via a Java 8 lambda. */
@Test
- @Category(ValidatesRunner.class)
+ @Category({ValidatesRunner.class, BatchOnly.class})
public void testBinaryCombinePerKeyLambda() {
PCollection> output =
@@ -923,7 +924,7 @@ public void testBinaryCombinePerKeyLambda() {
/** Tests creation of a per-key {@link Combine} via a Java 8 method reference. */
@Test
- @Category(ValidatesRunner.class)
+ @Category({ValidatesRunner.class, BatchOnly.class})
public void testCombinePerKeyInstanceMethodReference() {
PCollection> output =
@@ -937,7 +938,7 @@ public void testCombinePerKeyInstanceMethodReference() {
/** Tests creation of a per-key binary {@link Combine} via a Java 8 method reference. */
@Test
- @Category(ValidatesRunner.class)
+ @Category({ValidatesRunner.class, BatchOnly.class})
public void testBinaryCombinePerKeyInstanceMethodReference() {
PCollection> output =
@@ -1001,7 +1002,7 @@ public void testSimpleCombineWithContext() {
}
@Test
- @Category({ValidatesRunner.class, UsesSideInputs.class})
+ @Category({ValidatesRunner.class, UsesSideInputs.class, BatchOnly.class})
public void testSimpleCombineWithContextEmpty() {
runTestSimpleCombineWithContext(EMPTY_TABLE, 0, Collections.emptyList(), new String[] {});
}
@@ -1031,7 +1032,7 @@ public void testWithFanoutPreservesSideInputs() {
}
@Test
- @Category({ValidatesRunner.class, UsesSideInputs.class})
+ @Category({ValidatesRunner.class, UsesSideInputs.class, BatchOnly.class})
public void testHotKeyCombineWithSideInputs() {
PCollection> input =
createInput(
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/CreateTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/CreateTest.java
index 03f4f1c67c67..90ea453ab4e3 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/CreateTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/CreateTest.java
@@ -52,6 +52,7 @@
import org.apache.beam.sdk.options.ValueProvider.StaticValueProvider;
import org.apache.beam.sdk.schemas.Schema;
import org.apache.beam.sdk.schemas.SchemaCoder;
+import org.apache.beam.sdk.testing.BatchOnly;
import org.apache.beam.sdk.testing.NeedsRunner;
import org.apache.beam.sdk.testing.PAssert;
import org.apache.beam.sdk.testing.SourceTestUtils;
@@ -101,7 +102,7 @@ public void testCreate() {
}
@Test
- @Category(ValidatesRunner.class)
+ @Category({ValidatesRunner.class, BatchOnly.class})
public void testCreateEmpty() {
PCollection output = p.apply(Create.empty(StringUtf8Coder.of()));
@@ -125,7 +126,7 @@ public void testCreateEmptyIterableRequiresCoder() {
}
@Test
- @Category(NeedsRunner.class)
+ @Category({NeedsRunner.class, BatchOnly.class})
public void testCreateEmptyIterableWithCoder() {
PCollection output =
p.apply(Create.of(Collections.emptyList()).withCoder(VoidCoder.of()));
@@ -161,7 +162,7 @@ public void testPolymorphicType() throws Exception {
}
@Test
- @Category(ValidatesRunner.class)
+ @Category({ValidatesRunner.class, BatchOnly.class})
public void testCreateWithNullsAndValues() throws Exception {
PCollection output =
p.apply(
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MapViewTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MapViewTest.java
new file mode 100644
index 000000000000..0fd7f269a9a7
--- /dev/null
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MapViewTest.java
@@ -0,0 +1,1017 @@
+/*
+ * 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.sdk.transforms;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.beam.sdk.coders.AtomicCoder;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.CoderException;
+import org.apache.beam.sdk.coders.KvCoder;
+import org.apache.beam.sdk.coders.NullableCoder;
+import org.apache.beam.sdk.coders.StringUtf8Coder;
+import org.apache.beam.sdk.coders.VarIntCoder;
+import org.apache.beam.sdk.testing.NeedsRunner;
+import org.apache.beam.sdk.testing.PAssert;
+import org.apache.beam.sdk.testing.RerunTest;
+import org.apache.beam.sdk.testing.TestPipeline;
+import org.apache.beam.sdk.testing.UsesSideInputs;
+import org.apache.beam.sdk.testing.ValidatesRunner;
+import org.apache.beam.sdk.transforms.windowing.FixedWindows;
+import org.apache.beam.sdk.transforms.windowing.Window;
+import org.apache.beam.sdk.values.KV;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.PCollectionView;
+import org.apache.beam.sdk.values.TimestampedValue;
+import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.Timeout;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for (multi)map {@link View}. See also {@link ParDoTest}, which provides additional coverage
+ * since views can only be observed via {@link ParDo}.
+ */
+@RunWith(JUnit4.class)
+@Category({UsesSideInputs.class, RerunTest.class})
+public class MapViewTest implements Serializable {
+ // This test is Serializable, just so that it's easy to have
+ // anonymous inner classes inside the non-static test methods.
+
+ @Rule public final transient TestPipeline pipeline = TestPipeline.create();
+
+ @Rule public transient ExpectedException thrown = ExpectedException.none();
+
+ @Rule public transient Timeout globalTimeout = Timeout.seconds(1200);
+
+ @Test
+ @Category(ValidatesRunner.class)
+ public void testMultimapSideInput() {
+
+ final PCollectionView