Skip to content

Commit

Permalink
experiment with gRPC outlier detection balancer
Browse files Browse the repository at this point in the history
Signed-off-by: Chao Chen <[email protected]>
  • Loading branch information
chaochn47 committed Sep 20, 2023
1 parent e07b8e1 commit d6401d4
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions tests/e2e/failover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
_ "google.golang.org/grpc/health"
_ "google.golang.org/grpc/xds"

clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/tests/v3/framework/config"
Expand Down Expand Up @@ -98,15 +99,38 @@ func TestFailover(t *testing.T) {
Endpoints: endpoints,
DialOptions: []grpc.DialOption{
grpc.WithDisableServiceConfig(),
grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy": "round_robin", "healthCheckConfig": {"serviceName": ""}}`),
//grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy": "round_robin", "healthCheckConfig": {"serviceName": ""}}`),
grpc.WithDefaultServiceConfig(`
{
"loadBalancingConfig": [
{
"outlier_detection_experimental": {
"interval": "2s",
"baseEjectionTime": "30s",
"maxEjectionTime": "300s",
"maxEjectionPercent": 10,
"failurePercentageEjection": {
"threshold": 85,
"enforcementPercentage": 100,
"minimumHosts": 3,
"requestVolume": 5
},
"childPolicy": [{"round_robin": {}}]
}
}
],
"healthCheckConfig": {
"serviceName": ""
}
}`),
// the following service config will disable grpc client health check
//grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy": "round_robin"}`),
},
})
require.NoError(t, cerr)
timeout := time.After(clientRuntime)

time.Sleep(tc.failureDetectionLatency)
//time.Sleep(tc.failureDetectionLatency)
for {
select {
case <-timeout:
Expand Down Expand Up @@ -136,7 +160,7 @@ func TestFailover(t *testing.T) {
}
t.Logf("request failure rate is %.2f%%, traffic volume success %d requests, total %d requests", (1-float64(success)/float64(cnt))*100, success, cnt)
// expect no more than 5 failed requests
require.InDelta(t, cnt, success, failedRequests)
//require.InDelta(t, cnt, success, failedRequests)
})
}
}
Expand Down

0 comments on commit d6401d4

Please sign in to comment.