Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ below are temporary and better ones will be coming.
java_gapic_library2(
name = "showcase_java_gapic",
srcs = [":showcase_proto_with_info"],
# The gapic_yaml file is needed only for APIs that have batching configs.
grpc_service_config = "showcase_grpc_service_config.json",
package = "google.showcase.v1beta1",
test_deps = [
Expand Down Expand Up @@ -100,21 +99,26 @@ below are temporary and better ones will be coming.
bazel run //src/test/java/com/google/api/generator/engine:JavaCodeGeneratorTest
```

- Update goldens files based on code generation in unit test, for example `JavaCodeGeneratorTest.java`
- Update goldens files based on code generation in unit test, for example
`JavaCodeGeneratorTest.java`

```sh
bazel run //src/test/java/com/google/api/generator/engine:JavaCodeGeneratorTest_update
```

- Run a single integration test for API like `Redis`, it generates Java source code using
the Java microgenerator and compares them with the goldens files in `test/integration/goldens/redis`.
- Run a single integration test for API like `Redis`, it generates Java source
code using the Java microgenerator and compares them with the goldens files
in `test/integration/goldens/redis`.

```sh
bazel test //test/integration:redis
```

- Update goldens files based on code generation in integration test, for example `Redis`. It generates Java source code using the Java microgenerator and overwrites the goldens files in `test/integration/goldens/redis` based on code generation.
- Update goldens files based on code generation in integration test, for
example `Redis`. It generates Java source code using the Java microgenerator
and overwrites the goldens files in `test/integration/goldens/redis` based
on code generation.

```sh
bazel run //test/integration:redis_update
```
```
4 changes: 0 additions & 4 deletions rules_java_gapic/java_gapic.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def java_gapic_library(
package = None,
service_yaml = None,
grpc_service_config = None,
gapic_yaml = None,
deps = [],
test_deps = [],
**kwargs):
Expand All @@ -92,9 +91,6 @@ def java_gapic_library(
if grpc_service_config:
file_args_dict[grpc_service_config] = "grpc-service-config"

if gapic_yaml:
file_args_dict[gapic_yaml] = "gapic-config"

# Currently a no-op.
if service_yaml:
file_args_dict[service_yaml] = "gapic-service-config"
Expand Down
8 changes: 1 addition & 7 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ DEFINE_string --alias=s service_config '' 'Path to the JSON service config'
# Optional flags.
DEFINE_bool --alias=c use_cached false 'If true, does not rebuild the plugin.'
DEFINE_string --alias=o out '/tmp/test' 'Output directory'
DEFINE_string gapic_config '' 'Path to the config ending in gapic.yaml. Optional'

gbash::init_google "$@"

Expand Down Expand Up @@ -78,19 +77,14 @@ if [ -n "$FLAGS_service_config" ]
then
SERVICE_CONFIG_OPT="grpc-service-config=$FLAGS_service_config"
fi
GAPIC_CONFIG_OPT=""
if [ -n "$FLAGS_gapic_config" ]
then
GAPIC_CONFIG_OPT="gapic-config=$FLAGS_gapic_config"
fi

# Run protoc.
protoc -I="${PROTOC_INCLUDE_DIR}" -I="${FLAGS_googleapis}" -I="${FLAGS_protos}" \
-I="${FLAGS_googleapis}/google/longrunning" \
--include_source_info \
--plugin=bazel-bin/protoc-gen-java_gapic ${FLAGS_protos}/*.proto \
--java_gapic_out="${FLAGS_out}" \
--java_gapic_opt="${SERVICE_CONFIG_OPT},${GAPIC_CONFIG_OPT}" \
--java_gapic_opt="${SERVICE_CONFIG_OPT}" \
--experimental_allow_proto3_optional

echo_success "Output files written to ${FLAGS_out}"
1 change: 0 additions & 1 deletion test/integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ java_gapic_assembly_gradle_pkg(
java_gapic_library(
name = "logging_java_gapic",
srcs = ["@com_google_googleapis//google/logging/v2:logging_proto_with_info"],
gapic_yaml = "@com_google_googleapis//google/logging/v2:logging_gapic.yaml",
grpc_service_config = "@com_google_googleapis//google/logging/v2:logging_grpc_service_config.json",
package = "google.logging.v2",
service_yaml = "@com_google_googleapis//google/logging/v2:logging.yaml",
Expand Down
97 changes: 5 additions & 92 deletions test/integration/goldens/logging/LoggingServiceV2StubSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
import com.google.api.core.ApiFunction;
import com.google.api.core.ApiFuture;
import com.google.api.core.BetaApi;
import com.google.api.gax.batching.BatchingSettings;
import com.google.api.gax.batching.FlowControlSettings;
import com.google.api.gax.batching.FlowController;
import com.google.api.gax.batching.PartitionKey;
import com.google.api.gax.batching.RequestBuilder;
import com.google.api.gax.core.GaxProperties;
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
Expand All @@ -38,9 +33,6 @@
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiCallContext;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.BatchedRequestIssuer;
import com.google.api.gax.rpc.BatchingCallSettings;
import com.google.api.gax.rpc.BatchingDescriptor;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.PagedCallSettings;
Expand All @@ -67,7 +59,6 @@
import com.google.logging.v2.WriteLogEntriesResponse;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import javax.annotation.Generated;
Expand Down Expand Up @@ -104,7 +95,7 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
.build();

private final UnaryCallSettings<DeleteLogRequest, Empty> deleteLogSettings;
private final BatchingCallSettings<WriteLogEntriesRequest, WriteLogEntriesResponse>
private final UnaryCallSettings<WriteLogEntriesRequest, WriteLogEntriesResponse>
writeLogEntriesSettings;
private final PagedCallSettings<
ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse>
Expand Down Expand Up @@ -305,73 +296,13 @@ public ApiFuture<ListLogsPagedResponse> getFuturePagedResponse(
}
};

private static final BatchingDescriptor<WriteLogEntriesRequest, WriteLogEntriesResponse>
WRITE_LOG_ENTRIES_BATCHING_DESC =
new BatchingDescriptor<WriteLogEntriesRequest, WriteLogEntriesResponse>() {
@Override
public PartitionKey getBatchPartitionKey(WriteLogEntriesRequest request) {
return new PartitionKey(
request.getLogName(), request.getResource(), request.getLabels());
}

@Override
public RequestBuilder<WriteLogEntriesRequest> getRequestBuilder() {
return new RequestBuilder<WriteLogEntriesRequest>() {
private WriteLogEntriesRequest.Builder builder;

@Override
public void appendRequest(WriteLogEntriesRequest request) {
if (Objects.isNull(builder)) {
builder = request.toBuilder();
} else {
builder.addAllEntries(request.getEntriesList());
}
}

@Override
public WriteLogEntriesRequest build() {
return builder.build();
}
};
}

@Override
public void splitResponse(
WriteLogEntriesResponse batchResponse,
Collection<? extends BatchedRequestIssuer<WriteLogEntriesResponse>> batch) {
for (BatchedRequestIssuer<WriteLogEntriesResponse> responder : batch) {
WriteLogEntriesResponse response = WriteLogEntriesResponse.newBuilder().build();
responder.setResponse(response);
}
}

@Override
public void splitException(
Throwable throwable,
Collection<? extends BatchedRequestIssuer<WriteLogEntriesResponse>> batch) {
for (BatchedRequestIssuer<WriteLogEntriesResponse> responder : batch) {
responder.setException(throwable);
}
}

@Override
public long countElements(WriteLogEntriesRequest request) {
return request.getEntriesCount();
}

@Override
public long countBytes(WriteLogEntriesRequest request) {
return request.getSerializedSize();
}
};

/** Returns the object with the settings used for calls to deleteLog. */
public UnaryCallSettings<DeleteLogRequest, Empty> deleteLogSettings() {
return deleteLogSettings;
}

/** Returns the object with the settings used for calls to writeLogEntries. */
public BatchingCallSettings<WriteLogEntriesRequest, WriteLogEntriesResponse>
public UnaryCallSettings<WriteLogEntriesRequest, WriteLogEntriesResponse>
writeLogEntriesSettings() {
return writeLogEntriesSettings;
}
Expand Down Expand Up @@ -479,7 +410,7 @@ protected LoggingServiceV2StubSettings(Builder settingsBuilder) throws IOExcepti
public static class Builder extends StubSettings.Builder<LoggingServiceV2StubSettings, Builder> {
private final ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders;
private final UnaryCallSettings.Builder<DeleteLogRequest, Empty> deleteLogSettings;
private final BatchingCallSettings.Builder<WriteLogEntriesRequest, WriteLogEntriesResponse>
private final UnaryCallSettings.Builder<WriteLogEntriesRequest, WriteLogEntriesResponse>
writeLogEntriesSettings;
private final PagedCallSettings.Builder<
ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse>
Expand Down Expand Up @@ -535,9 +466,7 @@ protected Builder(ClientContext clientContext) {
super(clientContext);

deleteLogSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
writeLogEntriesSettings =
BatchingCallSettings.newBuilder(WRITE_LOG_ENTRIES_BATCHING_DESC)
.setBatchingSettings(BatchingSettings.newBuilder().build());
writeLogEntriesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
listLogEntriesSettings = PagedCallSettings.newBuilder(LIST_LOG_ENTRIES_PAGE_STR_FACT);
listMonitoredResourceDescriptorsSettings =
PagedCallSettings.newBuilder(LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_FACT);
Expand Down Expand Up @@ -589,22 +518,6 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.writeLogEntriesSettings()
.setBatchingSettings(
BatchingSettings.newBuilder()
.setElementCountThreshold(1000L)
.setRequestByteThreshold(1048576L)
.setDelayThreshold(Duration.ofMillis(50L))
.setFlowControlSettings(
FlowControlSettings.newBuilder()
.setMaxOutstandingElementCount(100000L)
.setMaxOutstandingRequestBytes(10485760L)
.setLimitExceededBehavior(
FlowController.LimitExceededBehavior.ThrowException)
.build())
.build());

builder
.writeLogEntriesSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
Expand Down Expand Up @@ -650,7 +563,7 @@ public UnaryCallSettings.Builder<DeleteLogRequest, Empty> deleteLogSettings() {
}

/** Returns the builder for the settings used for calls to writeLogEntries. */
public BatchingCallSettings.Builder<WriteLogEntriesRequest, WriteLogEntriesResponse>
public UnaryCallSettings.Builder<WriteLogEntriesRequest, WriteLogEntriesResponse>
writeLogEntriesSettings() {
return writeLogEntriesSettings;
}
Expand Down