|
47 | 47 | import com.google.api.services.dataflow.model.Job; |
48 | 48 | import com.google.api.services.dataflow.model.Step; |
49 | 49 | import com.google.api.services.dataflow.model.WorkerPool; |
50 | | -import com.google.auto.value.AutoValue; |
51 | 50 | import java.io.File; |
52 | 51 | import java.io.IOException; |
53 | 52 | import java.io.Serializable; |
|
93 | 92 | import org.apache.beam.sdk.options.PipelineOptionsFactory; |
94 | 93 | import org.apache.beam.sdk.options.StreamingOptions; |
95 | 94 | import org.apache.beam.sdk.options.ValueProvider; |
96 | | -import org.apache.beam.sdk.schemas.AutoValueSchema; |
97 | | -import org.apache.beam.sdk.schemas.annotations.DefaultSchema; |
98 | 95 | import org.apache.beam.sdk.state.StateSpec; |
99 | 96 | import org.apache.beam.sdk.state.StateSpecs; |
100 | 97 | import org.apache.beam.sdk.state.ValueState; |
@@ -169,11 +166,15 @@ public class DataflowPipelineTranslatorTest implements Serializable { |
169 | 166 | @Rule public transient ExpectedException thrown = ExpectedException.none(); |
170 | 167 |
|
171 | 168 | private SdkComponents createSdkComponents(PipelineOptions options) { |
| 169 | + SdkComponents sdkComponents = SdkComponents.create(); |
| 170 | + |
172 | 171 | String containerImageURL = |
173 | 172 | DataflowRunner.getContainerImageForJob(options.as(DataflowPipelineOptions.class)); |
174 | 173 | RunnerApi.Environment defaultEnvironmentForDataflow = |
175 | 174 | Environments.createDockerEnvironment(containerImageURL); |
176 | | - return SdkComponents.create(options, defaultEnvironmentForDataflow); |
| 175 | + |
| 176 | + sdkComponents.registerEnvironment(defaultEnvironmentForDataflow); |
| 177 | + return sdkComponents; |
177 | 178 | } |
178 | 179 |
|
179 | 180 | // A Custom Mockito matcher for an initial Job that checks that all |
@@ -1293,16 +1294,15 @@ public String apply(byte[] input) { |
1293 | 1294 | file1.deleteOnExit(); |
1294 | 1295 | File file2 = File.createTempFile("file2-", ".txt"); |
1295 | 1296 | file2.deleteOnExit(); |
1296 | | - SdkComponents sdkComponents = |
1297 | | - SdkComponents.create( |
1298 | | - options, |
1299 | | - Environments.createDockerEnvironment(DataflowRunner.getContainerImageForJob(options)) |
1300 | | - .toBuilder() |
1301 | | - .addAllDependencies( |
1302 | | - Environments.getArtifacts( |
1303 | | - ImmutableList.of("file1.txt=" + file1, "file2.txt=" + file2))) |
1304 | | - .addAllCapabilities(Environments.getJavaCapabilities()) |
1305 | | - .build()); |
| 1297 | + SdkComponents sdkComponents = SdkComponents.create(); |
| 1298 | + sdkComponents.registerEnvironment( |
| 1299 | + Environments.createDockerEnvironment(DataflowRunner.getContainerImageForJob(options)) |
| 1300 | + .toBuilder() |
| 1301 | + .addAllDependencies( |
| 1302 | + Environments.getArtifacts( |
| 1303 | + ImmutableList.of("file1.txt=" + file1, "file2.txt=" + file2))) |
| 1304 | + .addAllCapabilities(Environments.getJavaCapabilities()) |
| 1305 | + .build()); |
1306 | 1306 |
|
1307 | 1307 | RunnerApi.Pipeline pipelineProto = PipelineTranslation.toProto(pipeline, sdkComponents, true); |
1308 | 1308 |
|
@@ -1870,53 +1870,4 @@ public OffsetRange getInitialRange(@SuppressWarnings("unused") @Element String e |
1870 | 1870 | return null; |
1871 | 1871 | } |
1872 | 1872 | } |
1873 | | - |
1874 | | - @AutoValue |
1875 | | - @DefaultSchema(AutoValueSchema.class) |
1876 | | - public abstract static class SimpleAutoValue { |
1877 | | - public abstract String getString(); |
1878 | | - |
1879 | | - public abstract int getInt32(); |
1880 | | - |
1881 | | - public abstract long getInt64(); |
1882 | | - |
1883 | | - public static DataflowPipelineTranslatorTest.SimpleAutoValue of( |
1884 | | - String string, int int32, long int64) { |
1885 | | - return new AutoValue_DataflowPipelineTranslatorTest_SimpleAutoValue(string, int32, int64); |
1886 | | - } |
1887 | | - } |
1888 | | - |
1889 | | - @Test |
1890 | | - public void testSchemaCoderTranslation() throws Exception { |
1891 | | - DataflowPipelineOptions options = buildPipelineOptions(); |
1892 | | - Pipeline pipeline = Pipeline.create(options); |
1893 | | - pipeline |
1894 | | - .apply(Impulse.create()) |
1895 | | - .apply( |
1896 | | - MapElements.via( |
1897 | | - new SimpleFunction<byte[], SimpleAutoValue>() { |
1898 | | - @Override |
1899 | | - public SimpleAutoValue apply(byte[] input) { |
1900 | | - return SimpleAutoValue.of("foo", 5, 10L); |
1901 | | - } |
1902 | | - })) |
1903 | | - .apply(Window.into(FixedWindows.of(Duration.standardMinutes(1)))); |
1904 | | - { |
1905 | | - SdkComponents sdkComponents = createSdkComponents(options); |
1906 | | - RunnerApi.Pipeline pipelineProto = PipelineTranslation.toProto(pipeline, sdkComponents, true); |
1907 | | - Map<String, RunnerApi.Coder> coders = pipelineProto.getComponents().getCodersMap(); |
1908 | | - assertTrue(coders.containsKey("SchemaCoder")); |
1909 | | - assertEquals("beam:coder:schema:v1", coders.get("SchemaCoder").getSpec().getUrn()); |
1910 | | - } |
1911 | | - |
1912 | | - // Prior to version 2.74, SchemaCoders are translated as custom java coders. |
1913 | | - { |
1914 | | - options.as(StreamingOptions.class).setUpdateCompatibilityVersion("2.73"); |
1915 | | - SdkComponents sdkComponents = createSdkComponents(options); |
1916 | | - RunnerApi.Pipeline pipelineProto = PipelineTranslation.toProto(pipeline, sdkComponents, true); |
1917 | | - Map<String, RunnerApi.Coder> coders = pipelineProto.getComponents().getCodersMap(); |
1918 | | - assertTrue(coders.containsKey("SchemaCoder")); |
1919 | | - assertEquals("beam:coders:javasdk:0.1", coders.get("SchemaCoder").getSpec().getUrn()); |
1920 | | - } |
1921 | | - } |
1922 | 1873 | } |
0 commit comments