Skip to content

Commit

Permalink
sample: changes in three tests to resolve flaky tests and presubmit e…
Browse files Browse the repository at this point in the history
…rrors in samples (#819)

* changing google project in CreateClusterTest and adding ClusterConfig to SubmitTests

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
loferris and gcf-owl-bot[bot] committed Mar 29, 2022
1 parent 31a40e8 commit 48f8684
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
6 changes: 3 additions & 3 deletions dataproc/snippets/src/test/java/CreateClusterTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Google LLC
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,8 +40,8 @@ public class CreateClusterTest {
private static final String CLUSTER_NAME =
String.format("java-cc-test-%s", UUID.randomUUID().toString());
private static final String REGION = "us-central1";
// private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String PROJECT_ID = "gcloud-devel";
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
// private static final String PROJECT_ID = "gcloud-devel";
private ByteArrayOutputStream bout;

private static void requireEnv(String varName) {
Expand Down
23 changes: 21 additions & 2 deletions dataproc/snippets/src/test/java/SubmitHadoopFsJobTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Google LLC
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,9 +19,11 @@

import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.dataproc.v1.Cluster;
import com.google.cloud.dataproc.v1.ClusterConfig;
import com.google.cloud.dataproc.v1.ClusterControllerClient;
import com.google.cloud.dataproc.v1.ClusterControllerSettings;
import com.google.cloud.dataproc.v1.ClusterOperationMetadata;
import com.google.cloud.dataproc.v1.InstanceGroupConfig;
import com.google.protobuf.Empty;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -70,8 +72,25 @@ public void setUp() throws IOException, ExecutionException, InterruptedException

try (ClusterControllerClient clusterControllerClient =
ClusterControllerClient.create(clusterControllerSettings)) {
// Configure the settings for our cluster.
InstanceGroupConfig masterConfig =
InstanceGroupConfig.newBuilder()
.setMachineTypeUri("n1-standard-2")
.setNumInstances(1)
.build();
InstanceGroupConfig workerConfig =
InstanceGroupConfig.newBuilder()
.setMachineTypeUri("n1-standard-2")
.setNumInstances(2)
.build();
ClusterConfig clusterConfig =
ClusterConfig.newBuilder()
.setMasterConfig(masterConfig)
.setWorkerConfig(workerConfig)
.build();
// Create the Dataproc cluster.
Cluster cluster = Cluster.newBuilder().setClusterName(CLUSTER_NAME).build();
Cluster cluster =
Cluster.newBuilder().setClusterName(CLUSTER_NAME).setConfig(clusterConfig).build();
OperationFuture<Cluster, ClusterOperationMetadata> createClusterAsyncRequest =
clusterControllerClient.createClusterAsync(PROJECT_ID, REGION, cluster);
createClusterAsyncRequest.get();
Expand Down
23 changes: 21 additions & 2 deletions dataproc/snippets/src/test/java/SubmitJobTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Google LLC
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,9 +19,11 @@

import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.dataproc.v1.Cluster;
import com.google.cloud.dataproc.v1.ClusterConfig;
import com.google.cloud.dataproc.v1.ClusterControllerClient;
import com.google.cloud.dataproc.v1.ClusterControllerSettings;
import com.google.cloud.dataproc.v1.ClusterOperationMetadata;
import com.google.cloud.dataproc.v1.InstanceGroupConfig;
import com.google.protobuf.Empty;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -69,8 +71,25 @@ public void setUp() throws IOException, ExecutionException, InterruptedException

try (ClusterControllerClient clusterControllerClient =
ClusterControllerClient.create(clusterControllerSettings)) {
// Configure the settings for our cluster.
InstanceGroupConfig masterConfig =
InstanceGroupConfig.newBuilder()
.setMachineTypeUri("n1-standard-2")
.setNumInstances(1)
.build();
InstanceGroupConfig workerConfig =
InstanceGroupConfig.newBuilder()
.setMachineTypeUri("n1-standard-2")
.setNumInstances(2)
.build();
ClusterConfig clusterConfig =
ClusterConfig.newBuilder()
.setMasterConfig(masterConfig)
.setWorkerConfig(workerConfig)
.build();
// Create the Dataproc cluster.
Cluster cluster = Cluster.newBuilder().setClusterName(CLUSTER_NAME).build();
Cluster cluster =
Cluster.newBuilder().setClusterName(CLUSTER_NAME).setConfig(clusterConfig).build();
OperationFuture<Cluster, ClusterOperationMetadata> createClusterAsyncRequest =
clusterControllerClient.createClusterAsync(PROJECT_ID, REGION, cluster);
createClusterAsyncRequest.get();
Expand Down

0 comments on commit 48f8684

Please sign in to comment.