FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docker/integration-cli/docker_cli_stats_test.go at master · Eagle-X/docker · GitHub
Eagle-X
/
docker
Public
forked from
moby/moby
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
docker
/
integration-cli
/
docker_cli_stats_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (41 loc) · 1.48 KB
Breadcrumbs
docker
/
integration-cli
/
docker_cli_stats_test.go
Copy path
File metadata and controls
50 lines (41 loc) · 1.48 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package
main
import
(
"os/exec"
"strings"
"time"
"github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
)
func
(
s
*
DockerSuite
)
TestStatsNoStream
(
c
*
check.
C
) {
testRequires
(
c
,
DaemonIsLinux
)
out
,
_
:=
dockerCmd
(
c
,
"run"
,
"-d"
,
"busybox"
,
"top"
)
id
:=
strings
.
TrimSpace
(
out
)
c
.
Assert
(
waitRun
(
id
),
checker
.
IsNil
)
statsCmd
:=
exec
.
Command
(
dockerBinary
,
"stats"
,
"--no-stream"
,
id
)
type
output
struct
{
out
[]
byte
err
error
}
ch
:=
make
(
chan
output
)
go
func
() {
out
,
err
:=
statsCmd
.
Output
()
ch
<-
output
{
out
,
err
}
}()
select
{
case
outerr
:=
<-
ch
:
c
.
Assert
(
outerr
.
err
,
checker
.
IsNil
,
check
.
Commentf
(
"Error running stats: %v"
,
outerr
.
err
))
c
.
Assert
(
string
(
outerr
.
out
),
checker
.
Contains
,
id
)
//running container wasn't present in output
case
<-
time
.
After
(
3
*
time
.
Second
):
statsCmd
.
Process
.
Kill
()
c
.
Fatalf
(
"stats did not return immediately when not streaming"
)
}
}
func
(
s
*
DockerSuite
)
TestStatsContainerNotFound
(
c
*
check.
C
) {
testRequires
(
c
,
DaemonIsLinux
)
out
,
_
,
err
:=
dockerCmdWithError
(
"stats"
,
"notfound"
)
c
.
Assert
(
err
,
checker
.
NotNil
)
c
.
Assert
(
out
,
checker
.
Contains
,
"no such id: notfound"
,
check
.
Commentf
(
"Expected to fail on not found container stats, got %q instead"
,
out
))
out
,
_
,
err
=
dockerCmdWithError
(
"stats"
,
"--no-stream"
,
"notfound"
)
c
.
Assert
(
err
,
checker
.
NotNil
)
c
.
Assert
(
out
,
checker
.
Contains
,
"no such id: notfound"
,
check
.
Commentf
(
"Expected to fail on not found container stats with --no-stream, got %q instead"
,
out
))
}
Back
|
FazBrowse Home
|
New Git URL