mirror of
https://github.com/status-im/consul.git
synced 2025-01-17 01:01:14 +00:00
efe279f802
* Add a make target to run lint-consul-retry on all the modules * Cleanup sdk/testutil/retry * Fix a bunch of retry.Run* usage to not use the outer testing.T * Fix some more recent retry lint issues and pin to v1.4.0 of lint-consul-retry * Fix codegen copywrite lint issues * Don’t perform cleanup after each retry attempt by default. * Use the common testutil.TestingTB interface in test-integ/tenancy * Fix retry tests * Update otel access logging extension test to perform requests within the retry block
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package assert
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"fortio.org/fortio/fgrpc"
|
|
"github.com/hashicorp/consul/sdk/testutil/retry"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/credentials/insecure"
|
|
)
|
|
|
|
// GRPCPing sends a fgrpc.PingMessage to a fortio server at addr, analogous to
|
|
// the CLI command `fortio grpcping`. It retries for up to 1m, with a 25ms gap.
|
|
func GRPCPing(t *testing.T, addr string) {
|
|
t.Helper()
|
|
pingConn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
|
require.NoError(t, err)
|
|
pingCl := fgrpc.NewPingServerClient(pingConn)
|
|
var msg *fgrpc.PingMessage
|
|
retries := 0
|
|
retry.RunWith(&retry.Timer{Timeout: time.Minute, Wait: 25 * time.Millisecond}, t, func(r *retry.R) {
|
|
r.Logf("making grpc call to %s", addr)
|
|
retries += 1
|
|
msg, err = pingCl.Ping(context.Background(), &fgrpc.PingMessage{
|
|
// use addr as payload so we have something variable to check against
|
|
Payload: addr,
|
|
})
|
|
if err != nil {
|
|
r.Error(err)
|
|
}
|
|
})
|
|
assert.Equal(t, addr, msg.Payload)
|
|
}
|