Update TestAgent_GetCoordinate
The old test case was a very specific regresion test for a case that is no longer possible. Replaced with a new test that checks the default coordinate is returned.
This commit is contained in:
parent
56ecfce5fa
commit
0285956fac
|
@ -29,12 +29,14 @@ import (
|
||||||
"github.com/hashicorp/consul/api"
|
"github.com/hashicorp/consul/api"
|
||||||
"github.com/hashicorp/consul/internal/go-sso/oidcauth/oidcauthtest"
|
"github.com/hashicorp/consul/internal/go-sso/oidcauth/oidcauthtest"
|
||||||
"github.com/hashicorp/consul/ipaddr"
|
"github.com/hashicorp/consul/ipaddr"
|
||||||
|
"github.com/hashicorp/consul/lib"
|
||||||
"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"
|
||||||
"github.com/hashicorp/consul/testrpc"
|
"github.com/hashicorp/consul/testrpc"
|
||||||
"github.com/hashicorp/consul/types"
|
"github.com/hashicorp/consul/types"
|
||||||
"github.com/hashicorp/go-uuid"
|
"github.com/hashicorp/go-uuid"
|
||||||
|
"github.com/hashicorp/serf/coordinate"
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -3277,30 +3279,19 @@ func TestAgent_purgeCheckState(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAgent_GetCoordinate(t *testing.T) {
|
func TestAgent_GetCoordinate(t *testing.T) {
|
||||||
t.Parallel()
|
a := NewTestAgent(t, ``)
|
||||||
check := func(t *testing.T, server bool) {
|
defer a.Shutdown()
|
||||||
a := NewTestAgent(t, fmt.Sprintf(`
|
|
||||||
server = %v
|
|
||||||
bootstrap = %v
|
|
||||||
`, server, server))
|
|
||||||
defer a.Shutdown()
|
|
||||||
|
|
||||||
// This doesn't verify the returned coordinate, but it makes
|
coords, err := a.GetLANCoordinate()
|
||||||
// sure that the agent chooses the correct Serf instance,
|
require.NoError(t, err)
|
||||||
// depending on how it's configured as a client or a server.
|
expected := lib.CoordinateSet{
|
||||||
// If it chooses the wrong one, this will crash.
|
"": &coordinate.Coordinate{
|
||||||
if _, err := a.GetLANCoordinate(); err != nil {
|
Error: 1.5,
|
||||||
t.Fatalf("err: %s", err)
|
Height: 1e-05,
|
||||||
}
|
Vec: []float64{0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
require.Equal(t, expected, coords)
|
||||||
t.Run("server", func(t *testing.T) {
|
|
||||||
check(t, true)
|
|
||||||
})
|
|
||||||
t.Run("client", func(t *testing.T) {
|
|
||||||
check(t, false)
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAgent_reloadWatches(t *testing.T) {
|
func TestAgent_reloadWatches(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue