1
0
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:
Michael Crosby
2015-01-19 16:10:26 -08:00
parent 2f46b7601a
commit 76141a0077
7 changed files with 180 additions and 4 deletions

View File

@ -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")
}