Skip to content
Permalink
Browse files
docs(regen): update sample code to set total timeout, add API client …
…header test
  • Loading branch information
yoshi-automation committed Feb 10, 2020
1 parent a293517 commit 9d7dddc630a1b4c2d1b8330fdefd2297ac802019
Showing with 262 additions and 58 deletions.
  1. +6 −2 ...e-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/AutoscalingPolicyServiceSettings.java
  2. +6 −2 google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerSettings.java
  3. +6 −2 google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerSettings.java
  4. +6 −2 ...le-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/WorkflowTemplateServiceSettings.java
  5. +6 −2 ...ataproc/src/main/java/com/google/cloud/dataproc/v1/stub/AutoscalingPolicyServiceStubSettings.java
  6. +6 −2 ...cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/ClusterControllerStubSettings.java
  7. +6 −2 google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/JobControllerStubSettings.java
  8. +6 −2 ...dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/WorkflowTemplateServiceStubSettings.java
  9. +6 −2 ...ud-dataproc/src/main/java/com/google/cloud/dataproc/v1beta2/AutoscalingPolicyServiceSettings.java
  10. +6 −2 google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1beta2/ClusterControllerSettings.java
  11. +6 −2 google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1beta2/JobControllerSettings.java
  12. +6 −2 ...oud-dataproc/src/main/java/com/google/cloud/dataproc/v1beta2/WorkflowTemplateServiceSettings.java
  13. +6 −2 ...oc/src/main/java/com/google/cloud/dataproc/v1beta2/stub/AutoscalingPolicyServiceStubSettings.java
  14. +6 −2 ...-dataproc/src/main/java/com/google/cloud/dataproc/v1beta2/stub/ClusterControllerStubSettings.java
  15. +6 −2 ...loud-dataproc/src/main/java/com/google/cloud/dataproc/v1beta2/stub/JobControllerStubSettings.java
  16. +6 −2 ...roc/src/main/java/com/google/cloud/dataproc/v1beta2/stub/WorkflowTemplateServiceStubSettings.java
  17. +2 −5 google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/ClusterControllerClientTest.java
  18. +77 −5 google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/JobControllerClientTest.java
  19. +2 −5 ...e-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1beta2/ClusterControllerClientTest.java
  20. +79 −5 google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1beta2/JobControllerClientTest.java
  21. +6 −6 synth.metadata
@@ -55,8 +55,12 @@
* <code>
* AutoscalingPolicyServiceSettings.Builder autoscalingPolicyServiceSettingsBuilder =
* AutoscalingPolicyServiceSettings.newBuilder();
* autoscalingPolicyServiceSettingsBuilder.createAutoscalingPolicySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* autoscalingPolicyServiceSettingsBuilder
* .createAutoscalingPolicySettings()
* .setRetrySettings(
* autoscalingPolicyServiceSettingsBuilder.createAutoscalingPolicySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* AutoscalingPolicyServiceSettings autoscalingPolicyServiceSettings = autoscalingPolicyServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -57,8 +57,12 @@
* <code>
* ClusterControllerSettings.Builder clusterControllerSettingsBuilder =
* ClusterControllerSettings.newBuilder();
* clusterControllerSettingsBuilder.getClusterSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* clusterControllerSettingsBuilder
* .getClusterSettings()
* .setRetrySettings(
* clusterControllerSettingsBuilder.getClusterSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* ClusterControllerSettings clusterControllerSettings = clusterControllerSettingsBuilder.build();
* </code>
* </pre>
@@ -55,8 +55,12 @@
* <code>
* JobControllerSettings.Builder jobControllerSettingsBuilder =
* JobControllerSettings.newBuilder();
* jobControllerSettingsBuilder.submitJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* jobControllerSettingsBuilder
* .submitJobSettings()
* .setRetrySettings(
* jobControllerSettingsBuilder.submitJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* JobControllerSettings jobControllerSettings = jobControllerSettingsBuilder.build();
* </code>
* </pre>
@@ -57,8 +57,12 @@
* <code>
* WorkflowTemplateServiceSettings.Builder workflowTemplateServiceSettingsBuilder =
* WorkflowTemplateServiceSettings.newBuilder();
* workflowTemplateServiceSettingsBuilder.createWorkflowTemplateSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* workflowTemplateServiceSettingsBuilder
* .createWorkflowTemplateSettings()
* .setRetrySettings(
* workflowTemplateServiceSettingsBuilder.createWorkflowTemplateSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* WorkflowTemplateServiceSettings workflowTemplateServiceSettings = workflowTemplateServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -77,8 +77,12 @@
* <code>
* AutoscalingPolicyServiceStubSettings.Builder autoscalingPolicyServiceSettingsBuilder =
* AutoscalingPolicyServiceStubSettings.newBuilder();
* autoscalingPolicyServiceSettingsBuilder.createAutoscalingPolicySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* autoscalingPolicyServiceSettingsBuilder
* .createAutoscalingPolicySettings()
* .setRetrySettings(
* autoscalingPolicyServiceSettingsBuilder.createAutoscalingPolicySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* AutoscalingPolicyServiceStubSettings autoscalingPolicyServiceSettings = autoscalingPolicyServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -85,8 +85,12 @@
* <code>
* ClusterControllerStubSettings.Builder clusterControllerSettingsBuilder =
* ClusterControllerStubSettings.newBuilder();
* clusterControllerSettingsBuilder.getClusterSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* clusterControllerSettingsBuilder
* .getClusterSettings()
* .setRetrySettings(
* clusterControllerSettingsBuilder.getClusterSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* ClusterControllerStubSettings clusterControllerSettings = clusterControllerSettingsBuilder.build();
* </code>
* </pre>
@@ -78,8 +78,12 @@
* <code>
* JobControllerStubSettings.Builder jobControllerSettingsBuilder =
* JobControllerStubSettings.newBuilder();
* jobControllerSettingsBuilder.submitJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* jobControllerSettingsBuilder
* .submitJobSettings()
* .setRetrySettings(
* jobControllerSettingsBuilder.submitJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* JobControllerStubSettings jobControllerSettings = jobControllerSettingsBuilder.build();
* </code>
* </pre>
@@ -85,8 +85,12 @@
* <code>
* WorkflowTemplateServiceStubSettings.Builder workflowTemplateServiceSettingsBuilder =
* WorkflowTemplateServiceStubSettings.newBuilder();
* workflowTemplateServiceSettingsBuilder.createWorkflowTemplateSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* workflowTemplateServiceSettingsBuilder
* .createWorkflowTemplateSettings()
* .setRetrySettings(
* workflowTemplateServiceSettingsBuilder.createWorkflowTemplateSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* WorkflowTemplateServiceStubSettings workflowTemplateServiceSettings = workflowTemplateServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -55,8 +55,12 @@
* <code>
* AutoscalingPolicyServiceSettings.Builder autoscalingPolicyServiceSettingsBuilder =
* AutoscalingPolicyServiceSettings.newBuilder();
* autoscalingPolicyServiceSettingsBuilder.createAutoscalingPolicySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* autoscalingPolicyServiceSettingsBuilder
* .createAutoscalingPolicySettings()
* .setRetrySettings(
* autoscalingPolicyServiceSettingsBuilder.createAutoscalingPolicySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* AutoscalingPolicyServiceSettings autoscalingPolicyServiceSettings = autoscalingPolicyServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -57,8 +57,12 @@
* <code>
* ClusterControllerSettings.Builder clusterControllerSettingsBuilder =
* ClusterControllerSettings.newBuilder();
* clusterControllerSettingsBuilder.getClusterSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* clusterControllerSettingsBuilder
* .getClusterSettings()
* .setRetrySettings(
* clusterControllerSettingsBuilder.getClusterSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* ClusterControllerSettings clusterControllerSettings = clusterControllerSettingsBuilder.build();
* </code>
* </pre>
@@ -55,8 +55,12 @@
* <code>
* JobControllerSettings.Builder jobControllerSettingsBuilder =
* JobControllerSettings.newBuilder();
* jobControllerSettingsBuilder.submitJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* jobControllerSettingsBuilder
* .submitJobSettings()
* .setRetrySettings(
* jobControllerSettingsBuilder.submitJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* JobControllerSettings jobControllerSettings = jobControllerSettingsBuilder.build();
* </code>
* </pre>
@@ -57,8 +57,12 @@
* <code>
* WorkflowTemplateServiceSettings.Builder workflowTemplateServiceSettingsBuilder =
* WorkflowTemplateServiceSettings.newBuilder();
* workflowTemplateServiceSettingsBuilder.createWorkflowTemplateSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* workflowTemplateServiceSettingsBuilder
* .createWorkflowTemplateSettings()
* .setRetrySettings(
* workflowTemplateServiceSettingsBuilder.createWorkflowTemplateSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* WorkflowTemplateServiceSettings workflowTemplateServiceSettings = workflowTemplateServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -77,8 +77,12 @@
* <code>
* AutoscalingPolicyServiceStubSettings.Builder autoscalingPolicyServiceSettingsBuilder =
* AutoscalingPolicyServiceStubSettings.newBuilder();
* autoscalingPolicyServiceSettingsBuilder.createAutoscalingPolicySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* autoscalingPolicyServiceSettingsBuilder
* .createAutoscalingPolicySettings()
* .setRetrySettings(
* autoscalingPolicyServiceSettingsBuilder.createAutoscalingPolicySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* AutoscalingPolicyServiceStubSettings autoscalingPolicyServiceSettings = autoscalingPolicyServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -85,8 +85,12 @@
* <code>
* ClusterControllerStubSettings.Builder clusterControllerSettingsBuilder =
* ClusterControllerStubSettings.newBuilder();
* clusterControllerSettingsBuilder.getClusterSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* clusterControllerSettingsBuilder
* .getClusterSettings()
* .setRetrySettings(
* clusterControllerSettingsBuilder.getClusterSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* ClusterControllerStubSettings clusterControllerSettings = clusterControllerSettingsBuilder.build();
* </code>
* </pre>
@@ -78,8 +78,12 @@
* <code>
* JobControllerStubSettings.Builder jobControllerSettingsBuilder =
* JobControllerStubSettings.newBuilder();
* jobControllerSettingsBuilder.submitJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* jobControllerSettingsBuilder
* .submitJobSettings()
* .setRetrySettings(
* jobControllerSettingsBuilder.submitJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* JobControllerStubSettings jobControllerSettings = jobControllerSettingsBuilder.build();
* </code>
* </pre>
@@ -85,8 +85,12 @@
* <code>
* WorkflowTemplateServiceStubSettings.Builder workflowTemplateServiceSettingsBuilder =
* WorkflowTemplateServiceStubSettings.newBuilder();
* workflowTemplateServiceSettingsBuilder.createWorkflowTemplateSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* workflowTemplateServiceSettingsBuilder
* .createWorkflowTemplateSettings()
* .setRetrySettings(
* workflowTemplateServiceSettingsBuilder.createWorkflowTemplateSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* WorkflowTemplateServiceStubSettings workflowTemplateServiceSettings = workflowTemplateServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -391,9 +391,8 @@ public void listClustersTest2() {

String projectId = "projectId-1969970175";
String region = "region-934795532";
String filter = "filter-1274492040";

ListClustersPagedResponse pagedListResponse = client.listClusters(projectId, region, filter);
ListClustersPagedResponse pagedListResponse = client.listClusters(projectId, region);

List<Cluster> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
@@ -405,7 +404,6 @@ public void listClustersTest2() {

Assert.assertEquals(projectId, actualRequest.getProjectId());
Assert.assertEquals(region, actualRequest.getRegion());
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -421,9 +419,8 @@ public void listClustersExceptionTest2() throws Exception {
try {
String projectId = "projectId-1969970175";
String region = "region-934795532";
String filter = "filter-1274492040";

client.listClusters(projectId, region, filter);
client.listClusters(projectId, region);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
@@ -27,6 +27,7 @@
import com.google.common.collect.Lists;
import com.google.protobuf.AbstractMessage;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import java.io.IOException;
@@ -253,9 +254,8 @@ public void listJobsTest2() {

String projectId = "projectId-1969970175";
String region = "region-934795532";
String filter = "filter-1274492040";

ListJobsPagedResponse pagedListResponse = client.listJobs(projectId, region, filter);
ListJobsPagedResponse pagedListResponse = client.listJobs(projectId, region);

List<Job> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
@@ -267,7 +267,6 @@ public void listJobsTest2() {

Assert.assertEquals(projectId, actualRequest.getProjectId());
Assert.assertEquals(region, actualRequest.getRegion());
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -283,9 +282,82 @@ public void listJobsExceptionTest2() throws Exception {
try {
String projectId = "projectId-1969970175";
String region = "region-934795532";
String filter = "filter-1274492040";

client.listJobs(projectId, region, filter);
client.listJobs(projectId, region);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}

@Test
@SuppressWarnings("all")
public void updateJobTest() {
String driverOutputResourceUri = "driverOutputResourceUri-542229086";
String driverControlFilesUri = "driverControlFilesUri207057643";
String jobUuid = "jobUuid-1615012099";
Job expectedResponse =
Job.newBuilder()
.setDriverOutputResourceUri(driverOutputResourceUri)
.setDriverControlFilesUri(driverControlFilesUri)
.setJobUuid(jobUuid)
.build();
mockJobController.addResponse(expectedResponse);

String projectId = "projectId-1969970175";
String region = "region-934795532";
String jobId = "jobId-1154752291";
Job job = Job.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateJobRequest request =
UpdateJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJobId(jobId)
.setJob(job)
.setUpdateMask(updateMask)
.build();

Job actualResponse = client.updateJob(request);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockJobController.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateJobRequest actualRequest = (UpdateJobRequest) actualRequests.get(0);

Assert.assertEquals(projectId, actualRequest.getProjectId());
Assert.assertEquals(region, actualRequest.getRegion());
Assert.assertEquals(jobId, actualRequest.getJobId());
Assert.assertEquals(job, actualRequest.getJob());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

@Test
@SuppressWarnings("all")
public void updateJobExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockJobController.addException(exception);

try {
String projectId = "projectId-1969970175";
String region = "region-934795532";
String jobId = "jobId-1154752291";
Job job = Job.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateJobRequest request =
UpdateJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJobId(jobId)
.setJob(job)
.setUpdateMask(updateMask)
.build();

client.updateJob(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception

0 comments on commit 9d7dddc

Please sign in to comment.