mirror of https://github.com/status-im/consul.git
consul: Fixing merge conflict
This commit is contained in:
commit
23b9c96169
|
@ -409,17 +409,17 @@ RPC:
|
|||
}
|
||||
|
||||
// Add the node record
|
||||
records := d.formatNodeRecord(&out.NodeServices.Node, req.Question[0].Name,
|
||||
qType, d.config.NodeTTL)
|
||||
records := d.formatNodeRecord(&out.NodeServices.Node, out.NodeServices.Node.Address,
|
||||
req.Question[0].Name, qType, d.config.NodeTTL)
|
||||
if records != nil {
|
||||
resp.Answer = append(resp.Answer, records...)
|
||||
}
|
||||
}
|
||||
|
||||
// formatNodeRecord takes a Node and returns an A, AAAA, or CNAME record
|
||||
func (d *DNSServer) formatNodeRecord(node *structs.Node, qName string, qType uint16, ttl time.Duration) (records []dns.RR) {
|
||||
func (d *DNSServer) formatNodeRecord(node *structs.Node, addr, qName string, qType uint16, ttl time.Duration) (records []dns.RR) {
|
||||
// Parse the IP
|
||||
ip := net.ParseIP(node.Address)
|
||||
ip := net.ParseIP(addr)
|
||||
var ipv4 net.IP
|
||||
if ip != nil {
|
||||
ipv4 = ip.To4()
|
||||
|
@ -457,7 +457,7 @@ func (d *DNSServer) formatNodeRecord(node *structs.Node, qName string, qType uin
|
|||
Class: dns.ClassINET,
|
||||
Ttl: uint32(ttl / time.Second),
|
||||
},
|
||||
Target: dns.Fqdn(node.Address),
|
||||
Target: dns.Fqdn(addr),
|
||||
}
|
||||
records = append(records, cnRec)
|
||||
|
||||
|
@ -584,13 +584,17 @@ func (d *DNSServer) serviceNodeRecords(nodes structs.CheckServiceNodes, req, res
|
|||
// Avoid duplicate entries, possible if a node has
|
||||
// the same service on multiple ports, etc.
|
||||
addr := node.Node.Address
|
||||
if node.Service.Address != "" {
|
||||
addr = node.Service.Address
|
||||
}
|
||||
|
||||
if _, ok := handled[addr]; ok {
|
||||
continue
|
||||
}
|
||||
handled[addr] = struct{}{}
|
||||
|
||||
// Add the node record
|
||||
records := d.formatNodeRecord(&node.Node, qName, qType, ttl)
|
||||
records := d.formatNodeRecord(&node.Node, addr, qName, qType, ttl)
|
||||
if records != nil {
|
||||
resp.Answer = append(resp.Answer, records...)
|
||||
}
|
||||
|
@ -624,8 +628,14 @@ func (d *DNSServer) serviceSRVRecords(dc string, nodes structs.CheckServiceNodes
|
|||
}
|
||||
resp.Answer = append(resp.Answer, srvRec)
|
||||
|
||||
// Determine advertised address
|
||||
addr := node.Node.Address
|
||||
if node.Service.Address != "" {
|
||||
addr = node.Service.Address
|
||||
}
|
||||
|
||||
// Add the extra record
|
||||
records := d.formatNodeRecord(&node.Node, srvRec.Target, dns.TypeANY, ttl)
|
||||
records := d.formatNodeRecord(&node.Node, addr, srvRec.Target, dns.TypeANY, ttl)
|
||||
if records != nil {
|
||||
resp.Extra = append(resp.Extra, records...)
|
||||
}
|
||||
|
|
|
@ -6,11 +6,12 @@ import (
|
|||
|
||||
// ServiceDefinition is used to JSON decode the Service definitions
|
||||
type ServiceDefinition struct {
|
||||
ID string
|
||||
Name string
|
||||
Tags []string
|
||||
Port int
|
||||
Check CheckType
|
||||
ID string
|
||||
Name string
|
||||
Tags []string
|
||||
Address string
|
||||
Port int
|
||||
Check CheckType
|
||||
}
|
||||
|
||||
func (s *ServiceDefinition) NodeService() *structs.NodeService {
|
||||
|
@ -18,6 +19,7 @@ func (s *ServiceDefinition) NodeService() *structs.NodeService {
|
|||
ID: s.ID,
|
||||
Service: s.Name,
|
||||
Tags: s.Tags,
|
||||
Address: s.Address,
|
||||
Port: s.Port,
|
||||
}
|
||||
if ns.ID == "" && ns.Service != "" {
|
||||
|
|
|
@ -490,7 +490,7 @@ func TestCatalogListServices(t *testing.T) {
|
|||
|
||||
// Just add a node
|
||||
s1.fsm.State().EnsureNode(1, structs.Node{"foo", "127.0.0.1"})
|
||||
s1.fsm.State().EnsureService(2, "foo", &structs.NodeService{"db", "db", []string{"primary"}, 5000})
|
||||
s1.fsm.State().EnsureService(2, "foo", &structs.NodeService{"db", "db", []string{"primary"}, "127.0.0.1", 5000})
|
||||
|
||||
if err := client.Call("Catalog.ListServices", &args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -544,7 +544,7 @@ func TestCatalogListServices_Blocking(t *testing.T) {
|
|||
go func() {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
s1.fsm.State().EnsureNode(1, structs.Node{"foo", "127.0.0.1"})
|
||||
s1.fsm.State().EnsureService(2, "foo", &structs.NodeService{"db", "db", []string{"primary"}, 5000})
|
||||
s1.fsm.State().EnsureService(2, "foo", &structs.NodeService{"db", "db", []string{"primary"}, "127.0.0.1", 5000})
|
||||
}()
|
||||
|
||||
// Re-run the query
|
||||
|
@ -625,7 +625,7 @@ func TestCatalogListServices_Stale(t *testing.T) {
|
|||
|
||||
// Inject a fake service
|
||||
s1.fsm.State().EnsureNode(1, structs.Node{"foo", "127.0.0.1"})
|
||||
s1.fsm.State().EnsureService(2, "foo", &structs.NodeService{"db", "db", []string{"primary"}, 5000})
|
||||
s1.fsm.State().EnsureService(2, "foo", &structs.NodeService{"db", "db", []string{"primary"}, "127.0.0.1", 5000})
|
||||
|
||||
// Run the query, do not wait for leader!
|
||||
if err := client.Call("Catalog.ListServices", &args, &out); err != nil {
|
||||
|
@ -666,7 +666,7 @@ func TestCatalogListServiceNodes(t *testing.T) {
|
|||
|
||||
// Just add a node
|
||||
s1.fsm.State().EnsureNode(1, structs.Node{"foo", "127.0.0.1"})
|
||||
s1.fsm.State().EnsureService(2, "foo", &structs.NodeService{"db", "db", []string{"primary"}, 5000})
|
||||
s1.fsm.State().EnsureService(2, "foo", &structs.NodeService{"db", "db", []string{"primary"}, "127.0.0.1", 5000})
|
||||
|
||||
if err := client.Call("Catalog.ServiceNodes", &args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -709,8 +709,8 @@ func TestCatalogNodeServices(t *testing.T) {
|
|||
|
||||
// Just add a node
|
||||
s1.fsm.State().EnsureNode(1, structs.Node{"foo", "127.0.0.1"})
|
||||
s1.fsm.State().EnsureService(2, "foo", &structs.NodeService{"db", "db", []string{"primary"}, 5000})
|
||||
s1.fsm.State().EnsureService(3, "foo", &structs.NodeService{"web", "web", nil, 80})
|
||||
s1.fsm.State().EnsureService(2, "foo", &structs.NodeService{"db", "db", []string{"primary"}, "127.0.0.1", 5000})
|
||||
s1.fsm.State().EnsureService(3, "foo", &structs.NodeService{"web", "web", nil, "127.0.0.1", 80})
|
||||
|
||||
if err := client.Call("Catalog.NodeServices", &args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
|
|
@ -337,10 +337,10 @@ func TestFSM_SnapshotRestore(t *testing.T) {
|
|||
// Add some state
|
||||
fsm.state.EnsureNode(1, structs.Node{"foo", "127.0.0.1"})
|
||||
fsm.state.EnsureNode(2, structs.Node{"baz", "127.0.0.2"})
|
||||
fsm.state.EnsureService(3, "foo", &structs.NodeService{"web", "web", nil, 80})
|
||||
fsm.state.EnsureService(4, "foo", &structs.NodeService{"db", "db", []string{"primary"}, 5000})
|
||||
fsm.state.EnsureService(5, "baz", &structs.NodeService{"web", "web", nil, 80})
|
||||
fsm.state.EnsureService(6, "baz", &structs.NodeService{"db", "db", []string{"secondary"}, 5000})
|
||||
fsm.state.EnsureService(3, "foo", &structs.NodeService{"web", "web", nil, "127.0.0.1", 80})
|
||||
fsm.state.EnsureService(4, "foo", &structs.NodeService{"db", "db", []string{"primary"}, "127.0.0.1", 5000})
|
||||
fsm.state.EnsureService(5, "baz", &structs.NodeService{"web", "web", nil, "127.0.0.2", 80})
|
||||
fsm.state.EnsureService(6, "baz", &structs.NodeService{"db", "db", []string{"secondary"}, "127.0.0.2", 5000})
|
||||
fsm.state.EnsureCheck(7, &structs.HealthCheck{
|
||||
Node: "foo",
|
||||
CheckID: "web",
|
||||
|
|
|
@ -587,11 +587,12 @@ func (s *StateStore) ensureServiceTxn(index uint64, node string, ns *structs.Nod
|
|||
|
||||
// Create the entry
|
||||
entry := structs.ServiceNode{
|
||||
Node: node,
|
||||
ServiceID: ns.ID,
|
||||
ServiceName: ns.Service,
|
||||
ServiceTags: ns.Tags,
|
||||
ServicePort: ns.Port,
|
||||
Node: node,
|
||||
ServiceID: ns.ID,
|
||||
ServiceName: ns.Service,
|
||||
ServiceTags: ns.Tags,
|
||||
ServiceAddress: ns.Address,
|
||||
ServicePort: ns.Port,
|
||||
}
|
||||
|
||||
// Ensure the service entry is set
|
||||
|
@ -655,6 +656,7 @@ func (s *StateStore) parseNodeServices(tables MDBTables, tx *MDBTxn, name string
|
|||
ID: service.ServiceID,
|
||||
Service: service.ServiceName,
|
||||
Tags: service.ServiceTags,
|
||||
Address: service.ServiceAddress,
|
||||
Port: service.ServicePort,
|
||||
}
|
||||
ns.Services[srv.ID] = srv
|
||||
|
@ -830,13 +832,17 @@ func (s *StateStore) parseServiceNodes(tx *MDBTxn, table *MDBTable, res []interf
|
|||
for i, r := range res {
|
||||
srv := r.(*structs.ServiceNode)
|
||||
|
||||
// Get the address of the node
|
||||
nodeRes, err := table.GetTxn(tx, "id", srv.Node)
|
||||
if err != nil || len(nodeRes) != 1 {
|
||||
s.logger.Printf("[ERR] consul.state: Failed to join service node %#v with node: %v", *srv, err)
|
||||
continue
|
||||
if srv.ServiceAddress != "" {
|
||||
srv.Address = srv.ServiceAddress
|
||||
} else {
|
||||
// Get the address of the node
|
||||
nodeRes, err := table.GetTxn(tx, "id", srv.Node)
|
||||
if err != nil || len(nodeRes) != 1 {
|
||||
s.logger.Printf("[ERR] consul.state: Failed to join service node %#v with node: %v", *srv, err)
|
||||
continue
|
||||
}
|
||||
srv.Address = nodeRes[0].(*structs.Node).Address
|
||||
}
|
||||
srv.Address = nodeRes[0].(*structs.Node).Address
|
||||
|
||||
nodes[i] = *srv
|
||||
}
|
||||
|
@ -1039,6 +1045,7 @@ func (s *StateStore) parseCheckServiceNodes(tx *MDBTxn, res []interface{}, err e
|
|||
ID: srv.ServiceID,
|
||||
Service: srv.ServiceName,
|
||||
Tags: srv.ServiceTags,
|
||||
Address: srv.ServiceAddress,
|
||||
Port: srv.ServicePort,
|
||||
}
|
||||
nodes[i].Checks = checks
|
||||
|
@ -1113,6 +1120,7 @@ func (s *StateStore) parseNodeInfo(tx *MDBTxn, res []interface{}, err error) str
|
|||
ID: service.ServiceID,
|
||||
Service: service.ServiceName,
|
||||
Tags: service.ServiceTags,
|
||||
Address: service.ServiceAddress,
|
||||
Port: service.ServicePort,
|
||||
}
|
||||
info.Services = append(info.Services, srv)
|
||||
|
|
|
@ -24,7 +24,7 @@ func TestEnsureRegistration(t *testing.T) {
|
|||
reg := &structs.RegisterRequest{
|
||||
Node: "foo",
|
||||
Address: "127.0.0.1",
|
||||
Service: &structs.NodeService{"api", "api", nil, 5000},
|
||||
Service: &structs.NodeService{"api", "api", nil, "", 5000},
|
||||
Check: &structs.HealthCheck{
|
||||
Node: "foo",
|
||||
CheckID: "api",
|
||||
|
@ -149,15 +149,15 @@ func TestEnsureService(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(11, "foo", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
|
||||
if err := store.EnsureService(11, "foo", &structs.NodeService{"api", "api", nil, "", 5000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, 5001}); err != nil {
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, "", 5001}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(13, "foo", &structs.NodeService{"db", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(13, "foo", &structs.NodeService{"db", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -194,15 +194,15 @@ func TestEnsureService_DuplicateNode(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(11, "foo", &structs.NodeService{"api1", "api", nil, 5000}); err != nil {
|
||||
if err := store.EnsureService(11, "foo", &structs.NodeService{"api1", "api", nil, "", 5000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api2", "api", nil, 5001}); err != nil {
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api2", "api", nil, "", 5001}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(13, "foo", &structs.NodeService{"api3", "api", nil, 5002}); err != nil {
|
||||
if err := store.EnsureService(13, "foo", &structs.NodeService{"api3", "api", nil, "", 5002}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ func TestDeleteNodeService(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, "", 5000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -295,11 +295,11 @@ func TestDeleteNodeService_One(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, "", 5000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(13, "foo", &structs.NodeService{"api2", "api", nil, 5001}); err != nil {
|
||||
if err := store.EnsureService(13, "foo", &structs.NodeService{"api2", "api", nil, "", 5001}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ func TestDeleteNode(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(21, "foo", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
|
||||
if err := store.EnsureService(21, "foo", &structs.NodeService{"api", "api", nil, "", 5000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -391,15 +391,15 @@ func TestGetServices(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(32, "foo", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
|
||||
if err := store.EnsureService(32, "foo", &structs.NodeService{"api", "api", nil, "", 5000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(33, "foo", &structs.NodeService{"db", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(33, "foo", &structs.NodeService{"db", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(34, "bar", &structs.NodeService{"db", "db", []string{"slave"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(34, "bar", &structs.NodeService{"db", "db", []string{"slave"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -441,23 +441,23 @@ func TestServiceNodes(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, "", 5000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(13, "bar", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
|
||||
if err := store.EnsureService(13, "bar", &structs.NodeService{"api", "api", nil, "", 5000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(14, "foo", &structs.NodeService{"db", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(14, "foo", &structs.NodeService{"db", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(15, "bar", &structs.NodeService{"db", "db", []string{"slave"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(15, "bar", &structs.NodeService{"db", "db", []string{"slave"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(16, "bar", &structs.NodeService{"db2", "db", []string{"slave"}, 8001}); err != nil {
|
||||
if err := store.EnsureService(16, "bar", &structs.NodeService{"db2", "db", []string{"slave"}, "", 8001}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -532,15 +532,15 @@ func TestServiceTagNodes(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(17, "foo", &structs.NodeService{"db", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(17, "foo", &structs.NodeService{"db", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(18, "foo", &structs.NodeService{"db2", "db", []string{"slave"}, 8001}); err != nil {
|
||||
if err := store.EnsureService(18, "foo", &structs.NodeService{"db2", "db", []string{"slave"}, "", 8001}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(19, "bar", &structs.NodeService{"db", "db", []string{"slave"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(19, "bar", &structs.NodeService{"db", "db", []string{"slave"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -580,15 +580,15 @@ func TestServiceTagNodes_MultipleTags(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(17, "foo", &structs.NodeService{"db", "db", []string{"master", "v2"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(17, "foo", &structs.NodeService{"db", "db", []string{"master", "v2"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(18, "foo", &structs.NodeService{"db2", "db", []string{"slave", "v2", "dev"}, 8001}); err != nil {
|
||||
if err := store.EnsureService(18, "foo", &structs.NodeService{"db2", "db", []string{"slave", "v2", "dev"}, "", 8001}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(19, "bar", &structs.NodeService{"db", "db", []string{"slave", "v2"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(19, "bar", &structs.NodeService{"db", "db", []string{"slave", "v2"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -656,15 +656,15 @@ func TestStoreSnapshot(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(10, "foo", &structs.NodeService{"db", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(10, "foo", &structs.NodeService{"db", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(11, "foo", &structs.NodeService{"db2", "db", []string{"slave"}, 8001}); err != nil {
|
||||
if err := store.EnsureService(11, "foo", &structs.NodeService{"db2", "db", []string{"slave"}, "", 8001}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if err := store.EnsureService(12, "bar", &structs.NodeService{"db", "db", []string{"slave"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(12, "bar", &structs.NodeService{"db", "db", []string{"slave"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -849,10 +849,10 @@ func TestStoreSnapshot(t *testing.T) {
|
|||
}
|
||||
|
||||
// Make some changes!
|
||||
if err := store.EnsureService(23, "foo", &structs.NodeService{"db", "db", []string{"slave"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(23, "foo", &structs.NodeService{"db", "db", []string{"slave"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureService(24, "bar", &structs.NodeService{"db", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(24, "bar", &structs.NodeService{"db", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureNode(25, structs.Node{"baz", "127.0.0.3"}); err != nil {
|
||||
|
@ -979,7 +979,7 @@ func TestEnsureCheck(t *testing.T) {
|
|||
if err := store.EnsureNode(1, structs.Node{"foo", "127.0.0.1"}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
check := &structs.HealthCheck{
|
||||
|
@ -1075,7 +1075,7 @@ func TestDeleteNodeCheck(t *testing.T) {
|
|||
if err := store.EnsureNode(1, structs.Node{"foo", "127.0.0.1"}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
check := &structs.HealthCheck{
|
||||
|
@ -1125,7 +1125,7 @@ func TestCheckServiceNodes(t *testing.T) {
|
|||
if err := store.EnsureNode(1, structs.Node{"foo", "127.0.0.1"}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
check := &structs.HealthCheck{
|
||||
|
@ -1206,7 +1206,7 @@ func BenchmarkCheckServiceNodes(t *testing.B) {
|
|||
if err := store.EnsureNode(1, structs.Node{"foo", "127.0.0.1"}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
check := &structs.HealthCheck{
|
||||
|
@ -1249,6 +1249,7 @@ func TestSS_Register_Deregister_Query(t *testing.T) {
|
|||
"statsite-box-stats",
|
||||
"statsite-box-stats",
|
||||
nil,
|
||||
"",
|
||||
0}
|
||||
if err := store.EnsureService(2, "foo", srv); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -1258,6 +1259,7 @@ func TestSS_Register_Deregister_Query(t *testing.T) {
|
|||
"statsite-share-stats",
|
||||
"statsite-share-stats",
|
||||
nil,
|
||||
"",
|
||||
0}
|
||||
if err := store.EnsureService(3, "foo", srv); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -1286,7 +1288,7 @@ func TestNodeInfo(t *testing.T) {
|
|||
if err := store.EnsureNode(1, structs.Node{"foo", "127.0.0.1"}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
check := &structs.HealthCheck{
|
||||
|
@ -1345,13 +1347,13 @@ func TestNodeDump(t *testing.T) {
|
|||
if err := store.EnsureNode(1, structs.Node{"foo", "127.0.0.1"}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureNode(3, structs.Node{"baz", "127.0.0.2"}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureService(4, "baz", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
|
||||
if err := store.EnsureService(4, "baz", &structs.NodeService{"db1", "db", []string{"master"}, "", 8000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -2459,7 +2461,7 @@ func TestSessionInvalidate_DeleteNodeService(t *testing.T) {
|
|||
if err := store.EnsureNode(11, structs.Node{"foo", "127.0.0.1"}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
|
||||
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, "", 5000}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
check := &structs.HealthCheck{
|
||||
|
|
|
@ -217,12 +217,13 @@ type Services map[string][]string
|
|||
|
||||
// ServiceNode represents a node that is part of a service
|
||||
type ServiceNode struct {
|
||||
Node string
|
||||
Address string
|
||||
ServiceID string
|
||||
ServiceName string
|
||||
ServiceTags []string
|
||||
ServicePort int
|
||||
Node string
|
||||
Address string
|
||||
ServiceID string
|
||||
ServiceName string
|
||||
ServiceTags []string
|
||||
ServiceAddress string
|
||||
ServicePort int
|
||||
}
|
||||
type ServiceNodes []ServiceNode
|
||||
|
||||
|
@ -231,6 +232,7 @@ type NodeService struct {
|
|||
ID string
|
||||
Service string
|
||||
Tags []string
|
||||
Address string
|
||||
Port int
|
||||
}
|
||||
type NodeServices struct {
|
||||
|
|
|
@ -12,6 +12,7 @@ func TestEncodeDecode(t *testing.T) {
|
|||
Address: "baz",
|
||||
Service: &NodeService{
|
||||
Service: "test",
|
||||
Address: "127.0.0.2",
|
||||
},
|
||||
}
|
||||
buf, err := Encode(RegisterRequestType, arg)
|
||||
|
|
Loading…
Reference in New Issue