xds: enable circuit breaking, timeout, fault injection by default

This commit is contained in:
ZHANG Dapeng 2021-03-24 14:50:59 -07:00 committed by GitHub
parent b7afbc30d1
commit 3ccc6792d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 13 deletions

View File

@ -25,6 +25,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.CaseFormat;
import com.google.common.base.Joiner;
import com.google.common.base.Stopwatch;
import com.google.common.base.Strings;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.protobuf.Any;
@ -101,7 +102,8 @@ final class ClientXdsClient extends AbstractXdsClient {
static final String HASH_POLICY_FILTER_STATE_KEY = "io.grpc.channel_id";
@VisibleForTesting
static boolean enableFaultInjection =
Boolean.parseBoolean(System.getenv("GRPC_XDS_EXPERIMENTAL_FAULT_INJECTION"));
Strings.isNullOrEmpty(System.getenv("GRPC_XDS_EXPERIMENTAL_FAULT_INJECTION"))
|| Boolean.parseBoolean(System.getenv("GRPC_XDS_EXPERIMENTAL_FAULT_INJECTION"));
private static final String TYPE_URL_HTTP_CONNECTION_MANAGER_V2 =
"type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2"

View File

@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static io.grpc.xds.XdsSubchannelPickers.BUFFER_PICKER;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import io.grpc.Attributes;
import io.grpc.ClientStreamTracer;
import io.grpc.ClientStreamTracer.StreamInfo;
@ -65,7 +66,8 @@ final class ClusterImplLoadBalancer extends LoadBalancer {
static final long DEFAULT_PER_CLUSTER_MAX_CONCURRENT_REQUESTS = 1024L;
@VisibleForTesting
static boolean enableCircuitBreaking =
Boolean.parseBoolean(System.getenv("GRPC_XDS_EXPERIMENTAL_CIRCUIT_BREAKING"));
Strings.isNullOrEmpty(System.getenv("GRPC_XDS_EXPERIMENTAL_CIRCUIT_BREAKING"))
|| Boolean.parseBoolean(System.getenv("GRPC_XDS_EXPERIMENTAL_CIRCUIT_BREAKING"));
@VisibleForTesting
static boolean enableSecurity =
Boolean.parseBoolean(System.getenv("GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT"));

View File

@ -21,6 +21,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
@ -94,7 +95,8 @@ final class XdsNameResolver extends NameResolver {
new NamedFilterConfig(null, LameFilter.LAME_CONFIG);
@VisibleForTesting
static boolean enableTimeout =
Boolean.parseBoolean(System.getenv("GRPC_XDS_EXPERIMENTAL_ENABLE_TIMEOUT"));
Strings.isNullOrEmpty(System.getenv("GRPC_XDS_EXPERIMENTAL_ENABLE_TIMEOUT"))
|| Boolean.parseBoolean(System.getenv("GRPC_XDS_EXPERIMENTAL_ENABLE_TIMEOUT"));
private final InternalLogId logId;
private final XdsLogger logger;

View File

@ -305,16 +305,16 @@ public class ClusterImplLoadBalancerTest {
}
@Test
public void maxConcurrentRequests_appliedByLbConfig_enableCircuitBreaking() {
public void maxConcurrentRequests_appliedByLbConfig_disableCircuitBreaking() {
boolean originalEnableCircuitBreaking = ClusterImplLoadBalancer.enableCircuitBreaking;
ClusterImplLoadBalancer.enableCircuitBreaking = true;
subtest_maxConcurrentRequests_appliedByLbConfig(true);
ClusterImplLoadBalancer.enableCircuitBreaking = false;
subtest_maxConcurrentRequests_appliedByLbConfig(false);
ClusterImplLoadBalancer.enableCircuitBreaking = originalEnableCircuitBreaking;
}
@Test
public void maxConcurrentRequests_appliedByLbConfig_circuitBreakingDisabledByDefault() {
subtest_maxConcurrentRequests_appliedByLbConfig(false);
public void maxConcurrentRequests_appliedByLbConfig_circuitBreakingEnabledByDefault() {
subtest_maxConcurrentRequests_appliedByLbConfig(true);
}
private void subtest_maxConcurrentRequests_appliedByLbConfig(boolean enableCircuitBreaking) {
@ -393,16 +393,16 @@ public class ClusterImplLoadBalancerTest {
}
@Test
public void maxConcurrentRequests_appliedWithDefaultValue_enableCircuitBreaking() {
public void maxConcurrentRequests_appliedWithDefaultValue_disableCircuitBreaking() {
boolean originalEnableCircuitBreaking = ClusterImplLoadBalancer.enableCircuitBreaking;
ClusterImplLoadBalancer.enableCircuitBreaking = true;
subtest_maxConcurrentRequests_appliedWithDefaultValue(true);
ClusterImplLoadBalancer.enableCircuitBreaking = false;
subtest_maxConcurrentRequests_appliedWithDefaultValue(false);
ClusterImplLoadBalancer.enableCircuitBreaking = originalEnableCircuitBreaking;
}
@Test
public void maxConcurrentRequests_appliedWithDefaultValue_circuitBreakingDisabledByDefault() {
subtest_maxConcurrentRequests_appliedWithDefaultValue(false);
public void maxConcurrentRequests_appliedWithDefaultValue_circuitBreakingEnabledByDefault() {
subtest_maxConcurrentRequests_appliedWithDefaultValue(true);
}
private void subtest_maxConcurrentRequests_appliedWithDefaultValue(