|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * Copyright 2018-2020 The Feast Authors |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +package feast.core.job.dataflow; |
| 18 | + |
| 19 | +import static org.hamcrest.CoreMatchers.equalTo; |
| 20 | +import static org.hamcrest.Matchers.containsInAnyOrder; |
| 21 | +import static org.junit.Assert.*; |
| 22 | + |
| 23 | +import com.google.common.collect.Lists; |
| 24 | +import feast.proto.core.RunnerProto.DataflowRunnerConfigOptions; |
| 25 | +import java.util.Arrays; |
| 26 | +import java.util.List; |
| 27 | +import org.junit.Test; |
| 28 | + |
| 29 | +public class DataflowRunnerConfigTest { |
| 30 | + @Test |
| 31 | + public void shouldConvertToPipelineArgs() throws IllegalAccessException { |
| 32 | + DataflowRunnerConfigOptions opts = |
| 33 | + DataflowRunnerConfigOptions.newBuilder() |
| 34 | + .setProject("my-project") |
| 35 | + .setRegion("asia-east1") |
| 36 | + .setZone("asia-east1-a") |
| 37 | + .setTempLocation("gs://bucket/tempLocation") |
| 38 | + .setNetwork("default") |
| 39 | + .setSubnetwork("regions/asia-east1/subnetworks/mysubnetwork") |
| 40 | + .setMaxNumWorkers(1) |
| 41 | + .setAutoscalingAlgorithm("THROUGHPUT_BASED") |
| 42 | + .setUsePublicIps(false) |
| 43 | + .setWorkerMachineType("n1-standard-1") |
| 44 | + .setDeadLetterTableSpec("project_id:dataset_id.table_id") |
| 45 | + .putLabels("key", "value") |
| 46 | + .build(); |
| 47 | + |
| 48 | + DataflowRunnerConfig dataflowRunnerConfig = new DataflowRunnerConfig(opts); |
| 49 | + List<String> args = Lists.newArrayList(dataflowRunnerConfig.toArgs()); |
| 50 | + String[] expectedArgs = |
| 51 | + Arrays.asList( |
| 52 | + "--project=my-project", |
| 53 | + "--region=asia-east1", |
| 54 | + "--zone=asia-east1-a", |
| 55 | + "--tempLocation=gs://bucket/tempLocation", |
| 56 | + "--network=default", |
| 57 | + "--subnetwork=regions/asia-east1/subnetworks/mysubnetwork", |
| 58 | + "--maxNumWorkers=1", |
| 59 | + "--autoscalingAlgorithm=THROUGHPUT_BASED", |
| 60 | + "--usePublicIps=false", |
| 61 | + "--workerMachineType=n1-standard-1", |
| 62 | + "--deadLetterTableSpec=project_id:dataset_id.table_id", |
| 63 | + "--labels={\"key\":\"value\"}") |
| 64 | + .toArray(String[]::new); |
| 65 | + assertThat(args.size(), equalTo(expectedArgs.length)); |
| 66 | + assertThat(args, containsInAnyOrder(expectedArgs)); |
| 67 | + } |
| 68 | +} |
0 commit comments