fernando-wizeline commented on a change in pull request #17015: URL: https://github.com/apache/beam/pull/17015#discussion_r826215537
########## File path: examples/java/src/test/java/org/apache/beam/examples/complete/game/GameStatsIT.java ########## @@ -0,0 +1,248 @@ +/* + * 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.examples.complete.game; + +import static org.junit.Assert.assertEquals; + +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.rpc.FixedTransportChannelProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.services.bigquery.model.QueryResponse; +import com.google.cloud.pubsub.v1.SubscriptionAdminClient; +import com.google.cloud.pubsub.v1.SubscriptionAdminSettings; +import com.google.cloud.pubsub.v1.TopicAdminClient; +import com.google.cloud.pubsub.v1.TopicAdminSettings; +import com.google.pubsub.v1.PushConfig; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import java.io.IOException; +import java.util.concurrent.ThreadLocalRandom; +import org.apache.beam.examples.complete.game.utils.GameConstants; +import org.apache.beam.runners.direct.DirectOptions; +import org.apache.beam.sdk.extensions.gcp.options.GcpOptions; +import org.apache.beam.sdk.io.TextIO; +import org.apache.beam.sdk.io.gcp.pubsub.PubsubClient; +import org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath; +import org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.TopicPath; +import org.apache.beam.sdk.io.gcp.pubsub.PubsubIO; +import org.apache.beam.sdk.io.gcp.pubsub.PubsubOptions; +import org.apache.beam.sdk.io.gcp.testing.BigqueryClient; +import org.apache.beam.sdk.options.PipelineOptionsFactory; +import org.apache.beam.sdk.testing.TestPipeline; +import org.apache.beam.sdk.testing.TestPipelineOptions; +import org.apache.beam.sdk.util.FluentBackoff; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.joda.time.Duration; +import org.joda.time.Instant; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link GameStats}. */ +@RunWith(JUnit4.class) +public class GameStatsIT { + private static final DateTimeFormatter DATETIME_FORMAT = + DateTimeFormat.forPattern("YYYY-MM-dd-HH-mm-ss-SSS"); + private static final String EVENTS_TOPIC_NAME = "events"; + public static final String GAME_STATS_TEAM_TABLE = "game_stats_team"; + private static final Integer DEFAULT_ACK_DEADLINE_SECONDS = 60; + public static final String SELECT_COUNT_AS_TOTAL_QUERY = + "SELECT total_score FROM `%s.%s.%s` where team like(\"AmaranthKoala\")"; + private GameStatsOptions options = + TestPipeline.testingPipelineOptions().as(GameStatsIT.GameStatsOptions.class); + @Rule public final transient TestPipeline testPipeline = TestPipeline.fromOptions(options); + private static String pubsubEndpoint; + private @Nullable ManagedChannel channel = null; + private @Nullable TransportChannelProvider channelProvider = null; + private @Nullable TopicAdminClient topicAdmin = null; + private @Nullable SubscriptionAdminClient subscriptionAdmin = null; + private @Nullable TopicPath eventsTopicPath = null; + private @Nullable SubscriptionPath subscriptionPath = null; + private String projectId; + private static final String TOPIC_PREFIX = "gamestats-"; + private BigqueryClient bqClient; + private final String OUTPUT_DATASET = "game_stats_e2e"; + + public interface GameStatsOptions extends TestPipelineOptions, GameStats.Options {}; + + @Before + public void setupTestEnvironment() throws Exception { + PipelineOptionsFactory.register(TestPipelineOptions.class); + projectId = TestPipeline.testingPipelineOptions().as(GcpOptions.class).getProject(); + + setupBigQuery(); Review comment: About the setup/breakdown of the BigQuery dataset, which part from ExampleUtils should I take a look? The test requires only the dataset and WriteWindowedToBigQuery provides the rest of the configs needed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
