mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
Add documentation for stats feature
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@ -9,7 +9,9 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/stats"
|
||||
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
|
||||
)
|
||||
|
||||
@ -251,3 +253,31 @@ func TestVolumesFromHasPriority(t *testing.T) {
|
||||
|
||||
logDone("container REST API - check VolumesFrom has priority")
|
||||
}
|
||||
|
||||
func TestGetContainerStats(t *testing.T) {
|
||||
defer deleteAllContainers()
|
||||
name := "statscontainer"
|
||||
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "--name", name, "busybox", "top")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
if err != nil {
|
||||
t.Fatalf("Error on container creation: %v, output: %q", err, out)
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(4 * time.Second)
|
||||
runCommand(exec.Command(dockerBinary, "kill", name))
|
||||
runCommand(exec.Command(dockerBinary, "rm", name))
|
||||
}()
|
||||
|
||||
body, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("GET containers/stats sockRequest failed: %v", err)
|
||||
}
|
||||
|
||||
var s *stats.Stats
|
||||
if err := json.Unmarshal(body, &s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
logDone("container REST API - check GET containers/stats")
|
||||
}
|
||||
|
Reference in New Issue
Block a user