2018-03-07 01:32:41 +00:00
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mitchellh/go-testing-interface"
|
|
|
|
)
|
|
|
|
|
2018-03-09 16:34:55 +00:00
|
|
|
// TestRegisterRequest returns a RegisterRequest for registering a typical service.
|
|
|
|
func TestRegisterRequest(t testing.T) *RegisterRequest {
|
|
|
|
return &RegisterRequest{
|
|
|
|
Datacenter: "dc1",
|
|
|
|
Node: "foo",
|
|
|
|
Address: "127.0.0.1",
|
|
|
|
Service: &NodeService{
|
|
|
|
Service: "web",
|
|
|
|
Address: "",
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-07 01:32:41 +00:00
|
|
|
// TestRegisterRequestProxy returns a RegisterRequest for registering a
|
|
|
|
// Connect proxy.
|
|
|
|
func TestRegisterRequestProxy(t testing.T) *RegisterRequest {
|
|
|
|
return &RegisterRequest{
|
|
|
|
Datacenter: "dc1",
|
|
|
|
Node: "foo",
|
|
|
|
Address: "127.0.0.1",
|
2018-03-09 06:13:35 +00:00
|
|
|
Service: TestNodeServiceProxy(t),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-04 21:10:03 +00:00
|
|
|
// TestNodeService returns a *NodeService representing a valid regular service.
|
|
|
|
func TestNodeService(t testing.T) *NodeService {
|
|
|
|
return &NodeService{
|
|
|
|
Kind: ServiceKindTypical,
|
|
|
|
Service: "web",
|
2019-07-12 19:16:21 +00:00
|
|
|
Port: 8080,
|
2018-05-04 21:10:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-09 06:13:35 +00:00
|
|
|
// TestNodeServiceProxy returns a *NodeService representing a valid
|
|
|
|
// Connect proxy.
|
|
|
|
func TestNodeServiceProxy(t testing.T) *NodeService {
|
|
|
|
return &NodeService{
|
2018-09-12 16:07:47 +00:00
|
|
|
Kind: ServiceKindConnectProxy,
|
|
|
|
Service: "web-proxy",
|
|
|
|
Address: "127.0.0.2",
|
|
|
|
Port: 2222,
|
|
|
|
Proxy: TestConnectProxyConfig(t),
|
2018-03-07 01:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-27 13:33:12 +00:00
|
|
|
|
2019-06-18 00:52:01 +00:00
|
|
|
// TestNodeServiceMeshGateway returns a *NodeService representing a valid Mesh Gateway
|
|
|
|
func TestNodeServiceMeshGateway(t testing.T) *NodeService {
|
|
|
|
return TestNodeServiceMeshGatewayWithAddrs(t,
|
|
|
|
"10.1.2.3",
|
|
|
|
8443,
|
|
|
|
ServiceAddress{Address: "10.1.2.3", Port: 8443},
|
|
|
|
ServiceAddress{Address: "198.18.4.5", Port: 443})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNodeServiceMeshGatewayWithAddrs(t testing.T, address string, port int, lanAddr, wanAddr ServiceAddress) *NodeService {
|
|
|
|
return &NodeService{
|
|
|
|
Kind: ServiceKindMeshGateway,
|
|
|
|
Service: "mesh-gateway",
|
|
|
|
Address: address,
|
|
|
|
Port: port,
|
|
|
|
Proxy: ConnectProxyConfig{
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TaggedAddresses: map[string]ServiceAddress{
|
|
|
|
"lan": lanAddr,
|
|
|
|
"wan": wanAddr,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-27 13:33:12 +00:00
|
|
|
// TestNodeServiceSidecar returns a *NodeService representing a service
|
|
|
|
// registration with a nested Sidecar registration.
|
|
|
|
func TestNodeServiceSidecar(t testing.T) *NodeService {
|
|
|
|
return &NodeService{
|
|
|
|
Service: "web",
|
|
|
|
Port: 2222,
|
|
|
|
Connect: ServiceConnect{
|
|
|
|
SidecarService: &ServiceDefinition{},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|