2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
2023-05-11 16:08:57 +00:00
|
|
|
"bufio"
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
"bytes"
|
|
|
|
"context"
|
|
|
|
"encoding/base64"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
2023-05-11 16:08:57 +00:00
|
|
|
"strconv"
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2022-07-25 18:37:56 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2022-06-14 14:39:23 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2023-05-11 16:08:57 +00:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
gpeer "google.golang.org/grpc/peer"
|
2022-06-14 14:39:23 +00:00
|
|
|
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
2022-05-25 18:43:35 +00:00
|
|
|
"github.com/hashicorp/consul/api"
|
2023-02-17 21:14:46 +00:00
|
|
|
"github.com/hashicorp/consul/proto/private/pbpeering"
|
2023-05-11 16:08:57 +00:00
|
|
|
"github.com/hashicorp/consul/sdk/testutil"
|
2022-06-14 01:50:59 +00:00
|
|
|
"github.com/hashicorp/consul/sdk/testutil/retry"
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
"github.com/hashicorp/consul/testrpc"
|
|
|
|
)
|
|
|
|
|
2023-05-11 16:08:57 +00:00
|
|
|
func TestHTTP_Peering_Integration(t *testing.T) {
|
|
|
|
// This is a full-stack integration test of the gRPC (internal) stack. We
|
|
|
|
// use peering CRUD b/c that is one of the few endpoints exposed over gRPC
|
|
|
|
// (internal).
|
|
|
|
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
|
|
|
// We advertise a wan address we are not using, so that incidental attempts
|
|
|
|
// to use it will loudly fail.
|
|
|
|
const ip = "192.0.2.2"
|
|
|
|
|
|
|
|
connectivityConfig := `
|
|
|
|
ports { serf_wan = -1 }
|
|
|
|
bind_addr = "0.0.0.0"
|
|
|
|
client_addr = "0.0.0.0"
|
|
|
|
advertise_addr = "127.0.0.1"
|
|
|
|
advertise_addr_wan = "` + ip + `" `
|
|
|
|
|
|
|
|
var (
|
|
|
|
buf1, buf2, buf3 bytes.Buffer
|
|
|
|
testLog = testutil.NewLogBuffer(t)
|
|
|
|
|
|
|
|
log1 = io.MultiWriter(testLog, &buf1)
|
|
|
|
log2 = io.MultiWriter(testLog, &buf2)
|
|
|
|
log3 = io.MultiWriter(testLog, &buf3)
|
|
|
|
)
|
|
|
|
|
|
|
|
a1 := StartTestAgent(t, TestAgent{LogOutput: log1, HCL: `
|
|
|
|
server = true
|
|
|
|
bootstrap = false
|
|
|
|
bootstrap_expect = 3
|
|
|
|
` + connectivityConfig})
|
|
|
|
t.Cleanup(func() { a1.Shutdown() })
|
|
|
|
|
|
|
|
a2 := StartTestAgent(t, TestAgent{LogOutput: log2, HCL: `
|
|
|
|
server = true
|
|
|
|
bootstrap = false
|
|
|
|
bootstrap_expect = 3
|
|
|
|
` + connectivityConfig})
|
|
|
|
t.Cleanup(func() { a2.Shutdown() })
|
|
|
|
|
|
|
|
a3 := StartTestAgent(t, TestAgent{LogOutput: log3, HCL: `
|
|
|
|
server = true
|
|
|
|
bootstrap = false
|
|
|
|
bootstrap_expect = 3
|
|
|
|
` + connectivityConfig})
|
|
|
|
t.Cleanup(func() { a3.Shutdown() })
|
|
|
|
|
|
|
|
{ // join a2 to a1
|
|
|
|
addr := fmt.Sprintf("127.0.0.1:%d", a2.Config.SerfPortLAN)
|
|
|
|
_, err := a1.JoinLAN([]string{addr}, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
{ // join a3 to a1
|
|
|
|
addr := fmt.Sprintf("127.0.0.1:%d", a3.Config.SerfPortLAN)
|
|
|
|
_, err := a1.JoinLAN([]string{addr}, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
testrpc.WaitForLeader(t, a1.RPC, "dc1")
|
|
|
|
testrpc.WaitForActiveCARoot(t, a1.RPC, "dc1", nil)
|
|
|
|
|
|
|
|
testrpc.WaitForTestAgent(t, a1.RPC, "dc1")
|
|
|
|
testrpc.WaitForTestAgent(t, a2.RPC, "dc1")
|
|
|
|
testrpc.WaitForTestAgent(t, a3.RPC, "dc1")
|
|
|
|
|
|
|
|
retry.Run(t, func(r *retry.R) {
|
|
|
|
require.Len(r, a1.LANMembersInAgentPartition(), 3)
|
|
|
|
require.Len(r, a2.LANMembersInAgentPartition(), 3)
|
|
|
|
require.Len(r, a3.LANMembersInAgentPartition(), 3)
|
|
|
|
})
|
|
|
|
|
|
|
|
type testcase struct {
|
|
|
|
agent *TestAgent
|
|
|
|
peerName string
|
|
|
|
prevCount int
|
|
|
|
}
|
|
|
|
|
|
|
|
checkPeeringList := func(t *testing.T, a *TestAgent, expect int) {
|
|
|
|
req, err := http.NewRequest("GET", "/v1/peerings", nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code)
|
|
|
|
|
|
|
|
var apiResp []*api.Peering
|
|
|
|
require.NoError(t, json.NewDecoder(resp.Body).Decode(&apiResp))
|
|
|
|
|
|
|
|
require.Len(t, apiResp, expect)
|
|
|
|
}
|
|
|
|
|
|
|
|
testConn := func(t *testing.T, conn *grpc.ClientConn, peers map[string]int) {
|
|
|
|
rpcClientPeering := pbpeering.NewPeeringServiceClient(conn)
|
|
|
|
|
|
|
|
peer := &gpeer.Peer{}
|
|
|
|
_, err := rpcClientPeering.PeeringList(
|
|
|
|
context.Background(),
|
|
|
|
&pbpeering.PeeringListRequest{},
|
|
|
|
grpc.Peer(peer),
|
|
|
|
)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
peers[peer.Addr.String()]++
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
standardPeers = make(map[string]int)
|
|
|
|
leaderPeers = make(map[string]int)
|
|
|
|
)
|
|
|
|
runOnce := func(t *testing.T, tc testcase) {
|
|
|
|
conn, err := tc.agent.baseDeps.GRPCConnPool.ClientConn("dc1")
|
|
|
|
require.NoError(t, err)
|
|
|
|
testConn(t, conn, standardPeers)
|
|
|
|
|
|
|
|
leaderConn, err := tc.agent.baseDeps.GRPCConnPool.ClientConnLeader()
|
|
|
|
require.NoError(t, err)
|
|
|
|
testConn(t, leaderConn, leaderPeers)
|
|
|
|
|
|
|
|
checkPeeringList(t, tc.agent, tc.prevCount)
|
|
|
|
|
|
|
|
body := &pbpeering.GenerateTokenRequest{
|
|
|
|
PeerName: tc.peerName,
|
|
|
|
}
|
|
|
|
|
|
|
|
bodyBytes, err := json.Marshal(body)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/token", bytes.NewReader(bodyBytes))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
tc.agent.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code, "expected 200, got %d: %v", resp.Code, resp.Body.String())
|
|
|
|
|
|
|
|
var r pbpeering.GenerateTokenResponse
|
|
|
|
require.NoError(t, json.NewDecoder(resp.Body).Decode(&r))
|
|
|
|
|
|
|
|
checkPeeringList(t, tc.agent, tc.prevCount+1)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try the procedure on all agents to force N-1 of them to leader-forward.
|
|
|
|
cases := []testcase{
|
|
|
|
{agent: a1, peerName: "peer-1", prevCount: 0},
|
|
|
|
{agent: a2, peerName: "peer-2", prevCount: 1},
|
|
|
|
{agent: a3, peerName: "peer-3", prevCount: 2},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, tc := range cases {
|
|
|
|
tc := tc
|
|
|
|
testutil.RunStep(t, "server-"+strconv.Itoa(i+1), func(t *testing.T) {
|
|
|
|
runOnce(t, tc)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
testutil.RunStep(t, "ensure we got the right mixture of responses", func(t *testing.T) {
|
|
|
|
assert.Len(t, standardPeers, 3)
|
|
|
|
|
|
|
|
// Each server talks to a single leader.
|
|
|
|
assert.Len(t, leaderPeers, 1)
|
|
|
|
for p, n := range leaderPeers {
|
|
|
|
assert.Equal(t, 3, n, "peer %q expected 3 uses", p)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
testutil.RunStep(t, "no server experienced the server resolution error", func(t *testing.T) {
|
|
|
|
// Check them all for the bad error
|
|
|
|
const grpcError = `failed to find Consul server for global address`
|
|
|
|
|
|
|
|
var buf bytes.Buffer
|
|
|
|
buf.ReadFrom(&buf1)
|
|
|
|
buf.ReadFrom(&buf2)
|
|
|
|
buf.ReadFrom(&buf3)
|
|
|
|
|
|
|
|
scan := bufio.NewScanner(&buf)
|
|
|
|
for scan.Scan() {
|
|
|
|
line := scan.Text()
|
|
|
|
require.NotContains(t, line, grpcError)
|
|
|
|
}
|
|
|
|
require.NoError(t, scan.Err())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
func TestHTTP_Peering_GenerateToken(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Parallel()
|
|
|
|
a := NewTestAgent(t, "")
|
|
|
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
|
2022-09-29 03:27:11 +00:00
|
|
|
testrpc.WaitForActiveCARoot(t, a.RPC, "dc1", nil)
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
|
|
|
|
t.Run("No Body", func(t *testing.T) {
|
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/token", nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusBadRequest, resp.Code)
|
|
|
|
body, _ := io.ReadAll(resp.Body)
|
|
|
|
require.Contains(t, string(body), "The peering arguments must be provided in the body")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Body Invalid", func(t *testing.T) {
|
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/token", bytes.NewReader([]byte("abc")))
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusBadRequest, resp.Code)
|
|
|
|
body, _ := io.ReadAll(resp.Body)
|
|
|
|
require.Contains(t, string(body), "Body decoding failed:")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("No Name", func(t *testing.T) {
|
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/token",
|
|
|
|
bytes.NewReader([]byte(`{}`)))
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusBadRequest, resp.Code)
|
|
|
|
body, _ := io.ReadAll(resp.Body)
|
|
|
|
require.Contains(t, string(body), "PeerName is required")
|
|
|
|
})
|
|
|
|
|
|
|
|
// TODO(peering): add more failure cases
|
|
|
|
|
|
|
|
t.Run("Success", func(t *testing.T) {
|
|
|
|
body := &pbpeering.GenerateTokenRequest{
|
|
|
|
PeerName: "peering-a",
|
|
|
|
}
|
|
|
|
|
|
|
|
bodyBytes, err := json.Marshal(body)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/token", bytes.NewReader(bodyBytes))
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code, "expected 200, got %d: %v", resp.Code, resp.Body.String())
|
|
|
|
|
|
|
|
var r pbpeering.GenerateTokenResponse
|
|
|
|
require.NoError(t, json.NewDecoder(resp.Body).Decode(&r))
|
|
|
|
|
|
|
|
tokenJSON, err := base64.StdEncoding.DecodeString(r.PeeringToken)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
var token structs.PeeringToken
|
|
|
|
require.NoError(t, json.Unmarshal(tokenJSON, &token))
|
|
|
|
|
2022-09-29 03:27:11 +00:00
|
|
|
require.NotNil(t, token.CA)
|
|
|
|
require.Equal(t, []string{fmt.Sprintf("127.0.0.1:%d", a.config.GRPCTLSPort)}, token.ServerAddresses)
|
|
|
|
require.Equal(t, "server.dc1.peering.11111111-2222-3333-4444-555555555555.consul", token.ServerName)
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
|
|
|
|
// The PeerID in the token is randomly generated so we don't assert on its value.
|
|
|
|
require.NotEmpty(t, token.PeerID)
|
|
|
|
})
|
2022-11-08 20:55:18 +00:00
|
|
|
|
|
|
|
t.Run("Success with external address", func(t *testing.T) {
|
|
|
|
externalAddress := "32.1.2.3"
|
|
|
|
body := &pbpeering.GenerateTokenRequest{
|
|
|
|
PeerName: "peering-a",
|
|
|
|
ServerExternalAddresses: []string{externalAddress},
|
|
|
|
}
|
|
|
|
|
|
|
|
bodyBytes, err := json.Marshal(body)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/token", bytes.NewReader(bodyBytes))
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code, "expected 200, got %d: %v", resp.Code, resp.Body.String())
|
|
|
|
|
|
|
|
var r pbpeering.GenerateTokenResponse
|
|
|
|
require.NoError(t, json.NewDecoder(resp.Body).Decode(&r))
|
|
|
|
|
|
|
|
tokenJSON, err := base64.StdEncoding.DecodeString(r.PeeringToken)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
var token structs.PeeringToken
|
|
|
|
require.NoError(t, json.Unmarshal(tokenJSON, &token))
|
|
|
|
|
|
|
|
require.NotNil(t, token.CA)
|
|
|
|
require.Equal(t, []string{externalAddress}, token.ManualServerAddresses)
|
|
|
|
require.Equal(t, []string{fmt.Sprintf("127.0.0.1:%d", a.config.GRPCTLSPort)}, token.ServerAddresses)
|
|
|
|
require.Equal(t, "server.dc1.peering.11111111-2222-3333-4444-555555555555.consul", token.ServerName)
|
|
|
|
|
|
|
|
// The PeerID in the token is randomly generated so we don't assert on its value.
|
|
|
|
require.NotEmpty(t, token.PeerID)
|
|
|
|
})
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
}
|
|
|
|
|
2022-07-25 18:37:56 +00:00
|
|
|
// Test for GenerateToken calls at various points in a peer's lifecycle
|
|
|
|
func TestHTTP_Peering_GenerateToken_EdgeCases(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
a := NewTestAgent(t, "")
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
|
2022-09-29 03:27:11 +00:00
|
|
|
testrpc.WaitForActiveCARoot(t, a.RPC, "dc1", nil)
|
2022-07-25 18:37:56 +00:00
|
|
|
|
|
|
|
body := &pbpeering.GenerateTokenRequest{
|
|
|
|
PeerName: "peering-a",
|
|
|
|
}
|
|
|
|
|
|
|
|
bodyBytes, err := json.Marshal(body)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
getPeering := func(t *testing.T) *api.Peering {
|
|
|
|
t.Helper()
|
|
|
|
// Check state of peering
|
|
|
|
req, err := http.NewRequest("GET", "/v1/peering/peering-a", bytes.NewReader(bodyBytes))
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code, "expected 200, got %d: %v", resp.Code, resp.Body.String())
|
|
|
|
|
|
|
|
var p *api.Peering
|
|
|
|
require.NoError(t, json.NewDecoder(resp.Body).Decode(&p))
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// Call once
|
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/token", bytes.NewReader(bodyBytes))
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code, "expected 200, got %d: %v", resp.Code, resp.Body.String())
|
|
|
|
// Assertions tested in TestHTTP_Peering_GenerateToken
|
|
|
|
}
|
|
|
|
|
|
|
|
if !t.Run("generate token called again", func(t *testing.T) {
|
|
|
|
before := getPeering(t)
|
|
|
|
require.Equal(t, api.PeeringStatePending, before.State)
|
|
|
|
|
|
|
|
// Call again
|
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/token", bytes.NewReader(bodyBytes))
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code, "expected 200, got %d: %v", resp.Code, resp.Body.String())
|
|
|
|
|
|
|
|
after := getPeering(t)
|
|
|
|
assert.NotEqual(t, before.ModifyIndex, after.ModifyIndex)
|
|
|
|
// blank out modify index so we can compare rest of struct
|
|
|
|
before.ModifyIndex, after.ModifyIndex = 0, 0
|
|
|
|
assert.Equal(t, before, after)
|
|
|
|
|
|
|
|
}) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-10 16:10:46 +00:00
|
|
|
func TestHTTP_Peering_Establish(t *testing.T) {
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
|
|
|
a := NewTestAgent(t, "")
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
|
2022-09-29 03:27:11 +00:00
|
|
|
testrpc.WaitForActiveCARoot(t, a.RPC, "dc1", nil)
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
|
|
|
|
t.Run("No Body", func(t *testing.T) {
|
2022-06-10 16:10:46 +00:00
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/establish", nil)
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusBadRequest, resp.Code)
|
|
|
|
body, _ := io.ReadAll(resp.Body)
|
|
|
|
require.Contains(t, string(body), "The peering arguments must be provided in the body")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Body Invalid", func(t *testing.T) {
|
2022-06-10 16:10:46 +00:00
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/establish", bytes.NewReader([]byte("abc")))
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusBadRequest, resp.Code)
|
|
|
|
body, _ := io.ReadAll(resp.Body)
|
|
|
|
require.Contains(t, string(body), "Body decoding failed:")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("No Name", func(t *testing.T) {
|
2022-06-10 16:10:46 +00:00
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/establish",
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
bytes.NewReader([]byte(`{}`)))
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusBadRequest, resp.Code)
|
|
|
|
body, _ := io.ReadAll(resp.Body)
|
|
|
|
require.Contains(t, string(body), "PeerName is required")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("No Token", func(t *testing.T) {
|
2022-06-10 16:10:46 +00:00
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/establish",
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
bytes.NewReader([]byte(`{"PeerName": "peer1-usw1"}`)))
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusBadRequest, resp.Code)
|
|
|
|
body, _ := io.ReadAll(resp.Body)
|
|
|
|
require.Contains(t, string(body), "PeeringToken is required")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Success", func(t *testing.T) {
|
2022-09-09 21:09:32 +00:00
|
|
|
a2 := NewTestAgent(t, `datacenter = "dc2"`)
|
|
|
|
testrpc.WaitForTestAgent(t, a2.RPC, "dc2")
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
|
2022-08-01 14:33:18 +00:00
|
|
|
bodyBytes, err := json.Marshal(&pbpeering.GenerateTokenRequest{
|
|
|
|
PeerName: "foo",
|
|
|
|
})
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-08-01 14:33:18 +00:00
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/token", bytes.NewReader(bodyBytes))
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code, "expected 200, got %d: %v", resp.Code, resp.Body.String())
|
|
|
|
|
2022-08-01 14:33:18 +00:00
|
|
|
var r pbpeering.GenerateTokenResponse
|
|
|
|
require.NoError(t, json.NewDecoder(resp.Body).Decode(&r))
|
|
|
|
|
|
|
|
b, err := json.Marshal(&pbpeering.EstablishRequest{
|
|
|
|
PeerName: "zip",
|
|
|
|
PeeringToken: r.PeeringToken,
|
|
|
|
Meta: map[string]string{"foo": "bar"},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-09-29 03:27:11 +00:00
|
|
|
retry.Run(t, func(r *retry.R) {
|
|
|
|
req, err = http.NewRequest("POST", "/v1/peering/establish", bytes.NewReader(b))
|
|
|
|
require.NoError(r, err)
|
|
|
|
|
|
|
|
resp = httptest.NewRecorder()
|
|
|
|
a2.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(r, http.StatusOK, resp.Code, "expected 200, got %d: %v", resp.Code, resp.Body.String())
|
2022-08-01 14:33:18 +00:00
|
|
|
|
2022-09-29 03:27:11 +00:00
|
|
|
// success response does not currently return a value so {} is correct
|
|
|
|
require.Equal(r, "{}", resp.Body.String())
|
|
|
|
})
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-05-02 18:49:05 +00:00
|
|
|
func TestHTTP_Peering_MethodNotAllowed(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Parallel()
|
|
|
|
a := NewTestAgent(t, "")
|
|
|
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// Insert peerings directly to state store.
|
|
|
|
// Note that the state store holds reference to the underlying
|
|
|
|
// variables; do not modify them after writing.
|
|
|
|
foo := &pbpeering.PeeringWriteRequest{
|
|
|
|
Peering: &pbpeering.Peering{
|
|
|
|
Name: "foo",
|
2022-07-04 14:47:58 +00:00
|
|
|
State: pbpeering.PeeringState_ESTABLISHING,
|
2022-05-02 18:49:05 +00:00
|
|
|
PeerCAPems: nil,
|
|
|
|
PeerServerName: "fooservername",
|
|
|
|
PeerServerAddresses: []string{"addr1"},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
_, err := a.rpcClientPeering.PeeringWrite(ctx, foo)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
req, err := http.NewRequest("PUT", "/v1/peering/foo", nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusMethodNotAllowed, resp.Code)
|
|
|
|
}
|
|
|
|
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
func TestHTTP_Peering_Read(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Parallel()
|
|
|
|
a := NewTestAgent(t, "")
|
|
|
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// Insert peerings directly to state store.
|
|
|
|
// Note that the state store holds reference to the underlying
|
|
|
|
// variables; do not modify them after writing.
|
|
|
|
foo := &pbpeering.PeeringWriteRequest{
|
|
|
|
Peering: &pbpeering.Peering{
|
|
|
|
Name: "foo",
|
2022-07-04 14:47:58 +00:00
|
|
|
State: pbpeering.PeeringState_ESTABLISHING,
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
PeerCAPems: nil,
|
|
|
|
PeerServerName: "fooservername",
|
|
|
|
PeerServerAddresses: []string{"addr1"},
|
2022-05-09 20:47:37 +00:00
|
|
|
Meta: map[string]string{"foo": "bar"},
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
_, err := a.rpcClientPeering.PeeringWrite(ctx, foo)
|
|
|
|
require.NoError(t, err)
|
|
|
|
bar := &pbpeering.PeeringWriteRequest{
|
|
|
|
Peering: &pbpeering.Peering{
|
|
|
|
Name: "bar",
|
|
|
|
State: pbpeering.PeeringState_ACTIVE,
|
|
|
|
PeerCAPems: nil,
|
|
|
|
PeerServerName: "barservername",
|
|
|
|
PeerServerAddresses: []string{"addr1"},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
_, err = a.rpcClientPeering.PeeringWrite(ctx, bar)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
t.Run("return foo", func(t *testing.T) {
|
|
|
|
req, err := http.NewRequest("GET", "/v1/peering/foo", nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code)
|
|
|
|
|
2023-05-23 21:29:10 +00:00
|
|
|
httpResult := resp.Result()
|
|
|
|
_, ok := httpResult.Header["X-Consul-Index"]
|
|
|
|
require.True(t, ok)
|
|
|
|
idx, err := strconv.Atoi(httpResult.Header.Get("X-Consul-Index"))
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Greater(t, idx, 0) // the raft index is not deterministic at this point
|
|
|
|
|
2022-05-25 18:43:35 +00:00
|
|
|
var apiResp api.Peering
|
|
|
|
require.NoError(t, json.NewDecoder(resp.Body).Decode(&apiResp))
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
|
2022-05-25 18:43:35 +00:00
|
|
|
require.Equal(t, foo.Peering.Name, apiResp.Name)
|
|
|
|
require.Equal(t, foo.Peering.Meta, apiResp.Meta)
|
2022-06-29 21:07:30 +00:00
|
|
|
|
2022-09-23 21:51:41 +00:00
|
|
|
require.Equal(t, 0, len(apiResp.StreamStatus.ImportedServices))
|
|
|
|
require.Equal(t, 0, len(apiResp.StreamStatus.ExportedServices))
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("not found", func(t *testing.T) {
|
|
|
|
req, err := http.NewRequest("GET", "/v1/peering/baz", nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusNotFound, resp.Code)
|
2022-05-09 22:22:42 +00:00
|
|
|
require.Equal(t, "Peering not found for \"baz\"", resp.Body.String())
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-05-02 18:49:05 +00:00
|
|
|
func TestHTTP_Peering_Delete(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Parallel()
|
|
|
|
a := NewTestAgent(t, "")
|
|
|
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
|
2022-09-29 03:27:11 +00:00
|
|
|
testrpc.WaitForActiveCARoot(t, a.RPC, "dc1", nil)
|
2022-05-02 18:49:05 +00:00
|
|
|
|
2022-08-01 14:33:18 +00:00
|
|
|
bodyBytes, err := json.Marshal(&pbpeering.GenerateTokenRequest{
|
|
|
|
PeerName: "foo",
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
2022-05-02 18:49:05 +00:00
|
|
|
|
2022-08-01 14:33:18 +00:00
|
|
|
req, err := http.NewRequest("POST", "/v1/peering/token", bytes.NewReader(bodyBytes))
|
2022-05-02 18:49:05 +00:00
|
|
|
require.NoError(t, err)
|
2022-08-01 14:33:18 +00:00
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code, "expected 200, got %d: %v", resp.Code, resp.Body.String())
|
2022-05-02 18:49:05 +00:00
|
|
|
|
|
|
|
t.Run("read existing token before attempting delete", func(t *testing.T) {
|
|
|
|
req, err := http.NewRequest("GET", "/v1/peering/foo", nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code)
|
|
|
|
|
2022-05-25 18:43:35 +00:00
|
|
|
var apiResp api.Peering
|
|
|
|
require.NoError(t, json.NewDecoder(resp.Body).Decode(&apiResp))
|
2022-08-01 14:33:18 +00:00
|
|
|
require.Equal(t, "foo", apiResp.Name)
|
2022-05-02 18:49:05 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("delete the existing token we just read", func(t *testing.T) {
|
|
|
|
req, err := http.NewRequest("DELETE", "/v1/peering/foo", nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code)
|
2022-05-25 18:43:35 +00:00
|
|
|
require.Equal(t, "", resp.Body.String())
|
2022-05-02 18:49:05 +00:00
|
|
|
})
|
|
|
|
|
2022-06-14 01:50:59 +00:00
|
|
|
t.Run("now the token is deleted and reads should yield a 404", func(t *testing.T) {
|
|
|
|
retry.Run(t, func(r *retry.R) {
|
|
|
|
req, err := http.NewRequest("GET", "/v1/peering/foo", nil)
|
2022-06-14 14:39:23 +00:00
|
|
|
require.NoError(r, err)
|
2022-06-14 01:50:59 +00:00
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(r, http.StatusNotFound, resp.Code)
|
|
|
|
})
|
2022-05-02 18:49:05 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("delete a token that does not exist", func(t *testing.T) {
|
|
|
|
req, err := http.NewRequest("DELETE", "/v1/peering/baz", nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
func TestHTTP_Peering_List(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Parallel()
|
|
|
|
a := NewTestAgent(t, "")
|
|
|
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// Insert peerings directly to state store.
|
|
|
|
// Note that the state store holds reference to the underlying
|
|
|
|
// variables; do not modify them after writing.
|
|
|
|
foo := &pbpeering.PeeringWriteRequest{
|
|
|
|
Peering: &pbpeering.Peering{
|
|
|
|
Name: "foo",
|
2022-07-04 14:47:58 +00:00
|
|
|
State: pbpeering.PeeringState_ESTABLISHING,
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
PeerCAPems: nil,
|
|
|
|
PeerServerName: "fooservername",
|
|
|
|
PeerServerAddresses: []string{"addr1"},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
_, err := a.rpcClientPeering.PeeringWrite(ctx, foo)
|
|
|
|
require.NoError(t, err)
|
|
|
|
bar := &pbpeering.PeeringWriteRequest{
|
|
|
|
Peering: &pbpeering.Peering{
|
|
|
|
Name: "bar",
|
|
|
|
State: pbpeering.PeeringState_ACTIVE,
|
|
|
|
PeerCAPems: nil,
|
|
|
|
PeerServerName: "barservername",
|
|
|
|
PeerServerAddresses: []string{"addr1"},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
_, err = a.rpcClientPeering.PeeringWrite(ctx, bar)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
t.Run("return all", func(t *testing.T) {
|
|
|
|
req, err := http.NewRequest("GET", "/v1/peerings", nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
|
|
|
require.Equal(t, http.StatusOK, resp.Code)
|
|
|
|
|
2023-05-23 21:29:10 +00:00
|
|
|
httpResult := resp.Result()
|
|
|
|
_, ok := httpResult.Header["X-Consul-Index"]
|
|
|
|
require.True(t, ok)
|
|
|
|
idx, err := strconv.Atoi(httpResult.Header.Get("X-Consul-Index"))
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Greater(t, idx, 0) // the raft index is not deterministic at this point
|
|
|
|
|
2022-05-25 18:43:35 +00:00
|
|
|
var apiResp []*api.Peering
|
|
|
|
require.NoError(t, json.NewDecoder(resp.Body).Decode(&apiResp))
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
|
2022-05-25 18:43:35 +00:00
|
|
|
require.Len(t, apiResp, 2)
|
2022-06-29 21:07:30 +00:00
|
|
|
|
|
|
|
for _, p := range apiResp {
|
2022-09-23 21:51:41 +00:00
|
|
|
require.Equal(t, 0, len(p.StreamStatus.ImportedServices))
|
|
|
|
require.Equal(t, 0, len(p.StreamStatus.ExportedServices))
|
2022-06-29 21:07:30 +00:00
|
|
|
}
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
})
|
|
|
|
}
|