Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
docs(regen): update sample code to set total timeout, add API client …
Browse files Browse the repository at this point in the history
…header test
  • Loading branch information
yoshi-automation committed Feb 10, 2020
1 parent a293517 commit 9d7dddc
Show file tree
Hide file tree
Showing 21 changed files with 262 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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(),
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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(),
Expand All @@ -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
Expand Down
Loading

0 comments on commit 9d7dddc

Please sign in to comment.