mirror of https://github.com/status-im/consul.git
Merge pull request #3788 from fastest963/checkID
Added CheckID and Name to AgentServiceCheck struct
This commit is contained in:
commit
3278716ff5
|
@ -81,6 +81,8 @@ type AgentCheckRegistration struct {
|
||||||
|
|
||||||
// AgentServiceCheck is used to define a node or service level check
|
// AgentServiceCheck is used to define a node or service level check
|
||||||
type AgentServiceCheck struct {
|
type AgentServiceCheck struct {
|
||||||
|
CheckID string `json:",omitempty"`
|
||||||
|
Name string `json:",omitempty"`
|
||||||
Args []string `json:"ScriptArgs,omitempty"`
|
Args []string `json:"ScriptArgs,omitempty"`
|
||||||
Script string `json:",omitempty"` // Deprecated, use Args.
|
Script string `json:",omitempty"` // Deprecated, use Args.
|
||||||
DockerContainerID string `json:",omitempty"`
|
DockerContainerID string `json:",omitempty"`
|
||||||
|
|
|
@ -246,6 +246,34 @@ func TestAPI_AgentServices_CheckBadStatus(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAPI_AgentServices_CheckID(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
c, s := makeClient(t)
|
||||||
|
defer s.Stop()
|
||||||
|
|
||||||
|
agent := c.Agent()
|
||||||
|
reg := &AgentServiceRegistration{
|
||||||
|
Name: "foo",
|
||||||
|
Tags: []string{"bar", "baz"},
|
||||||
|
Port: 8000,
|
||||||
|
Check: &AgentServiceCheck{
|
||||||
|
CheckID: "foo-ttl",
|
||||||
|
TTL: "15s",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if err := agent.ServiceRegister(reg); err != nil {
|
||||||
|
t.Fatalf("err: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
checks, err := agent.Checks()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %v", err)
|
||||||
|
}
|
||||||
|
if _, ok := checks["foo-ttl"]; !ok {
|
||||||
|
t.Fatalf("missing check: %v", checks)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAPI_AgentServiceAddress(t *testing.T) {
|
func TestAPI_AgentServiceAddress(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c, s := makeClient(t)
|
c, s := makeClient(t)
|
||||||
|
|
Loading…
Reference in New Issue