Merge pull request #10217 from hashicorp/dnephin/test-flakes
testing: attempt to fix some test flakes
This commit is contained in:
commit
1a22454704
|
@ -36,7 +36,7 @@ steps:
|
||||||
install-gotestsum: &install-gotestsum
|
install-gotestsum: &install-gotestsum
|
||||||
name: install gotestsum
|
name: install gotestsum
|
||||||
environment:
|
environment:
|
||||||
GOTESTSUM_RELEASE: 0.6.0
|
GOTESTSUM_RELEASE: 1.6.4
|
||||||
command: |
|
command: |
|
||||||
url=https://github.com/gotestyourself/gotestsum/releases/download
|
url=https://github.com/gotestyourself/gotestsum/releases/download
|
||||||
curl -sSL "${url}/v${GOTESTSUM_RELEASE}/gotestsum_${GOTESTSUM_RELEASE}_linux_amd64.tar.gz" | \
|
curl -sSL "${url}/v${GOTESTSUM_RELEASE}/gotestsum_${GOTESTSUM_RELEASE}_linux_amd64.tar.gz" | \
|
||||||
|
|
|
@ -10,6 +10,11 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
uuid "github.com/hashicorp/go-uuid"
|
||||||
|
msgpackrpc "github.com/hashicorp/net-rpc-msgpackrpc"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"gopkg.in/square/go-jose.v2/jwt"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/acl"
|
"github.com/hashicorp/consul/acl"
|
||||||
"github.com/hashicorp/consul/agent/consul/authmethod/kubeauth"
|
"github.com/hashicorp/consul/agent/consul/authmethod/kubeauth"
|
||||||
"github.com/hashicorp/consul/agent/consul/authmethod/testauth"
|
"github.com/hashicorp/consul/agent/consul/authmethod/testauth"
|
||||||
|
@ -18,10 +23,6 @@ import (
|
||||||
"github.com/hashicorp/consul/sdk/freeport"
|
"github.com/hashicorp/consul/sdk/freeport"
|
||||||
"github.com/hashicorp/consul/sdk/testutil"
|
"github.com/hashicorp/consul/sdk/testutil"
|
||||||
"github.com/hashicorp/consul/sdk/testutil/retry"
|
"github.com/hashicorp/consul/sdk/testutil/retry"
|
||||||
uuid "github.com/hashicorp/go-uuid"
|
|
||||||
msgpackrpc "github.com/hashicorp/net-rpc-msgpackrpc"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"gopkg.in/square/go-jose.v2/jwt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestACLEndpoint_Bootstrap(t *testing.T) {
|
func TestACLEndpoint_Bootstrap(t *testing.T) {
|
||||||
|
@ -4981,7 +4982,7 @@ func TestACLEndpoint_Login_with_TokenLocality(t *testing.T) {
|
||||||
t.Skip("too slow for testing.Short")
|
t.Skip("too slow for testing.Short")
|
||||||
}
|
}
|
||||||
|
|
||||||
go t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
_, s1, codec := testACLServerWithConfig(t, func(c *Config) {
|
_, s1, codec := testACLServerWithConfig(t, func(c *Config) {
|
||||||
c.ACLTokenMinExpirationTTL = 10 * time.Millisecond
|
c.ACLTokenMinExpirationTTL = 10 * time.Millisecond
|
||||||
|
|
|
@ -16,10 +16,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
metrics "github.com/armon/go-metrics"
|
metrics "github.com/armon/go-metrics"
|
||||||
"github.com/hashicorp/errwrap"
|
|
||||||
"github.com/hashicorp/go-hclog"
|
"github.com/hashicorp/go-hclog"
|
||||||
uuid "github.com/hashicorp/go-uuid"
|
uuid "github.com/hashicorp/go-uuid"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
|
|
||||||
"github.com/hashicorp/consul/acl"
|
"github.com/hashicorp/consul/acl"
|
||||||
"github.com/hashicorp/consul/agent/config"
|
"github.com/hashicorp/consul/agent/config"
|
||||||
|
@ -99,6 +97,7 @@ func NewTestAgent(t *testing.T, hcl string) *TestAgent {
|
||||||
func StartTestAgent(t *testing.T, a TestAgent) *TestAgent {
|
func StartTestAgent(t *testing.T, a TestAgent) *TestAgent {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
retry.RunWith(retry.ThreeTimes(), t, func(r *retry.R) {
|
retry.RunWith(retry.ThreeTimes(), t, func(r *retry.R) {
|
||||||
|
t.Helper()
|
||||||
if err := a.Start(t); err != nil {
|
if err := a.Start(t); err != nil {
|
||||||
r.Fatal(err)
|
r.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -130,7 +129,7 @@ func TestConfigHCL(nodeID string) string {
|
||||||
|
|
||||||
// Start starts a test agent. It returns an error if the agent could not be started.
|
// Start starts a test agent. It returns an error if the agent could not be started.
|
||||||
// If no error is returned, the caller must call Shutdown() when finished.
|
// If no error is returned, the caller must call Shutdown() when finished.
|
||||||
func (a *TestAgent) Start(t *testing.T) (err error) {
|
func (a *TestAgent) Start(t *testing.T) error {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if a.Agent != nil {
|
if a.Agent != nil {
|
||||||
return fmt.Errorf("TestAgent already started")
|
return fmt.Errorf("TestAgent already started")
|
||||||
|
@ -187,7 +186,9 @@ func (a *TestAgent) Start(t *testing.T) (err error) {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
bd, err := NewBaseDeps(loader, logOutput)
|
bd, err := NewBaseDeps(loader, logOutput)
|
||||||
require.NoError(t, err)
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create base deps: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
bd.Logger = logger
|
bd.Logger = logger
|
||||||
bd.MetricsHandler = metrics.NewInmemSink(1*time.Second, time.Minute)
|
bd.MetricsHandler = metrics.NewInmemSink(1*time.Second, time.Minute)
|
||||||
|
@ -215,8 +216,8 @@ func (a *TestAgent) Start(t *testing.T) (err error) {
|
||||||
|
|
||||||
if err := a.waitForUp(); err != nil {
|
if err := a.waitForUp(); err != nil {
|
||||||
a.Shutdown()
|
a.Shutdown()
|
||||||
t.Logf("Error while waiting for test agent to start: %v", err)
|
a.Agent = nil
|
||||||
return errwrap.Wrapf(name+": {{err}}", err)
|
return fmt.Errorf("error waiting for test agent to start: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
a.dns = a.dnsServers[0]
|
a.dns = a.dnsServers[0]
|
||||||
|
@ -280,17 +281,6 @@ func (a *TestAgent) waitForUp() error {
|
||||||
// Shutdown stops the agent and removes the data directory if it is
|
// Shutdown stops the agent and removes the data directory if it is
|
||||||
// managed by the test agent.
|
// managed by the test agent.
|
||||||
func (a *TestAgent) Shutdown() error {
|
func (a *TestAgent) Shutdown() error {
|
||||||
/* Removed this because it was breaking persistence tests where we would
|
|
||||||
persist a service and load it through a new agent with the same data-dir.
|
|
||||||
Not sure if we still need this for other things, everywhere we manually make
|
|
||||||
a data dir we already do 'defer os.RemoveAll()'
|
|
||||||
defer func() {
|
|
||||||
if a.DataDir != "" {
|
|
||||||
os.RemoveAll(a.DataDir)
|
|
||||||
}
|
|
||||||
}()*/
|
|
||||||
|
|
||||||
// already shut down
|
|
||||||
if a.Agent == nil {
|
if a.Agent == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -30,7 +30,6 @@ require (
|
||||||
github.com/google/tcpproxy v0.0.0-20180808230851-dfa16c61dad2
|
github.com/google/tcpproxy v0.0.0-20180808230851-dfa16c61dad2
|
||||||
github.com/hashicorp/consul/api v1.8.0
|
github.com/hashicorp/consul/api v1.8.0
|
||||||
github.com/hashicorp/consul/sdk v0.7.0
|
github.com/hashicorp/consul/sdk v0.7.0
|
||||||
github.com/hashicorp/errwrap v1.0.0
|
|
||||||
github.com/hashicorp/go-bexpr v0.1.2
|
github.com/hashicorp/go-bexpr v0.1.2
|
||||||
github.com/hashicorp/go-checkpoint v0.5.0
|
github.com/hashicorp/go-checkpoint v0.5.0
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.1
|
github.com/hashicorp/go-cleanhttp v0.5.1
|
||||||
|
|
|
@ -99,6 +99,7 @@ func decorate(s string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run(t Failer, f func(r *R)) {
|
func Run(t Failer, f func(r *R)) {
|
||||||
|
t.Helper()
|
||||||
run(DefaultFailer(), t, f)
|
run(DefaultFailer(), t, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue