7038fe6b71
* Added new Config for SidecarService in ServiceDefinitions.
* WIP: all the code needed for SidecarService is written... none of it is tested other than config :). Need API updates too.
* Test coverage for the new sidecarServiceFromNodeService method.
* Test API registratrion with SidecarService
* Recursive Key Translation 🤦
* Add tests for nested sidecar defintion arrays to ensure they are translated correctly
* Use dedicated internal state rather than Service Meta for tracking sidecars for deregistration.
Add tests for deregistration.
* API struct for agent register. No other endpoint should be affected yet.
* Additional test cases to cover updates to API registrations
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package structs
|
|
|
|
import (
|
|
"github.com/mitchellh/go-testing-interface"
|
|
)
|
|
|
|
// 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,
|
|
},
|
|
}
|
|
}
|
|
|
|
// 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",
|
|
Service: TestNodeServiceProxy(t),
|
|
}
|
|
}
|
|
|
|
// TestNodeService returns a *NodeService representing a valid regular service.
|
|
func TestNodeService(t testing.T) *NodeService {
|
|
return &NodeService{
|
|
Kind: ServiceKindTypical,
|
|
Service: "web",
|
|
}
|
|
}
|
|
|
|
// TestNodeServiceProxy returns a *NodeService representing a valid
|
|
// Connect proxy.
|
|
func TestNodeServiceProxy(t testing.T) *NodeService {
|
|
return &NodeService{
|
|
Kind: ServiceKindConnectProxy,
|
|
Service: "web-proxy",
|
|
Address: "127.0.0.2",
|
|
Port: 2222,
|
|
Proxy: TestConnectProxyConfig(t),
|
|
}
|
|
}
|
|
|
|
// 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{},
|
|
},
|
|
}
|
|
}
|