mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
integration: TestPingSwarmHeader(): fix incorrect ping, and cleanup
I noticed I made a mistake in the first ping ("before swarm init"), which was not specifying the daemon's socket path and because of that testing against the main integration daemon (not the locally spun up daemon). While fixing that, I wondered why the test didn't actually use the client for the requests (to also verify the client converted the response), so I rewrote the test to use `client.Ping()` and to verify the ping response has the expected values set. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
69adaa894d
commit
a3b1b66bb3
1 changed files with 9 additions and 9 deletions
|
@ -66,30 +66,30 @@ func TestPingSwarmHeader(t *testing.T) {
|
|||
ctx := context.TODO()
|
||||
|
||||
t.Run("before swarm init", func(t *testing.T) {
|
||||
res, _, err := request.Get("/_ping")
|
||||
p, err := client.Ping(ctx)
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, res.StatusCode, http.StatusOK)
|
||||
assert.Equal(t, hdr(res, "Swarm"), "inactive")
|
||||
assert.Equal(t, p.SwarmStatus.NodeState, swarm.LocalNodeStateInactive)
|
||||
assert.Equal(t, p.SwarmStatus.ControlAvailable, false)
|
||||
})
|
||||
|
||||
_, err := client.SwarmInit(ctx, swarm.InitRequest{ListenAddr: "127.0.0.1", AdvertiseAddr: "127.0.0.1:2377"})
|
||||
assert.NilError(t, err)
|
||||
|
||||
t.Run("after swarm init", func(t *testing.T) {
|
||||
res, _, err := request.Get("/_ping", request.Host(d.Sock()))
|
||||
p, err := client.Ping(ctx)
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, res.StatusCode, http.StatusOK)
|
||||
assert.Equal(t, hdr(res, "Swarm"), "active/manager")
|
||||
assert.Equal(t, p.SwarmStatus.NodeState, swarm.LocalNodeStateActive)
|
||||
assert.Equal(t, p.SwarmStatus.ControlAvailable, true)
|
||||
})
|
||||
|
||||
err = client.SwarmLeave(ctx, true)
|
||||
assert.NilError(t, err)
|
||||
|
||||
t.Run("after swarm leave", func(t *testing.T) {
|
||||
res, _, err := request.Get("/_ping", request.Host(d.Sock()))
|
||||
p, err := client.Ping(ctx)
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, res.StatusCode, http.StatusOK)
|
||||
assert.Equal(t, hdr(res, "Swarm"), "inactive")
|
||||
assert.Equal(t, p.SwarmStatus.NodeState, swarm.LocalNodeStateInactive)
|
||||
assert.Equal(t, p.SwarmStatus.ControlAvailable, false)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue