本文整理汇总了Golang中github.com/docker/docker/integration-cli/checker.Not函数的典型用法代码示例。如果您正苦于以下问题:Golang Not函数的具体用法?Golang Not怎么用?Golang Not使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Not函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestAPIImagesSizeCompatibility
// Test case for 30027: image size reported as -1 in v1.12 client against v1.13 daemon.
// This test checks to make sure both v1.12 and v1.13 client against v1.13 daemon get correct `Size` after the fix.
func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *check.C) {
status, b, err := request.SockRequest("GET", "/images/json", nil, daemonHost())
c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusOK)
var images []types.ImageSummary
err = json.Unmarshal(b, &images)
c.Assert(err, checker.IsNil)
c.Assert(len(images), checker.Not(checker.Equals), 0)
for _, image := range images {
c.Assert(image.Size, checker.Not(checker.Equals), int64(-1))
}
type v124Image struct {
ID string `json:"Id"`
ParentID string `json:"ParentId"`
RepoTags []string
RepoDigests []string
Created int64
Size int64
VirtualSize int64
Labels map[string]string
}
status, b, err = request.SockRequest("GET", "/v1.24/images/json", nil, daemonHost())
c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusOK)
var v124Images []v124Image
err = json.Unmarshal(b, &v124Images)
c.Assert(err, checker.IsNil)
c.Assert(len(v124Images), checker.Not(checker.Equals), 0)
for _, image := range v124Images {
c.Assert(image.Size, checker.Not(checker.Equals), int64(-1))
}
}
示例2: TestLogsSinceFutureFollow
func (s *DockerSuite) TestLogsSinceFutureFollow(c *check.C) {
// TODO Windows TP5 - Figure out why this test is so flakey. Disabled for now.
testRequires(c, DaemonIsLinux)
name := "testlogssincefuturefollow"
out, _ := dockerCmd(c, "run", "-d", "--name", name, "busybox", "/bin/sh", "-c", `for i in $(seq 1 5); do echo log$i; sleep 1; done`)
// Extract one timestamp from the log file to give us a starting point for
// our `--since` argument. Because the log producer runs in the background,
// we need to check repeatedly for some output to be produced.
var timestamp string
for i := 0; i != 100 && timestamp == ""; i++ {
if out, _ = dockerCmd(c, "logs", "-t", name); out == "" {
time.Sleep(time.Millisecond * 100) // Retry
} else {
timestamp = strings.Split(strings.Split(out, "\n")[0], " ")[0]
}
}
c.Assert(timestamp, checker.Not(checker.Equals), "")
t, err := time.Parse(time.RFC3339Nano, timestamp)
c.Assert(err, check.IsNil)
since := t.Unix() + 2
out, _ = dockerCmd(c, "logs", "-t", "-f", fmt.Sprintf("--since=%v", since), name)
c.Assert(out, checker.Not(checker.HasLen), 0, check.Commentf("cannot read from empty log"))
lines := strings.Split(strings.TrimSpace(out), "\n")
for _, v := range lines {
ts, err := time.Parse(time.RFC3339Nano, strings.Split(v, " ")[0])
c.Assert(err, checker.IsNil, check.Commentf("cannot parse timestamp output from log: '%v'", v))
c.Assert(ts.Unix() >= since, checker.Equals, true, check.Commentf("earlier log found. since=%v logdate=%v", since, ts))
}
}
示例3: TestEventsFilterImageName
func (s *DockerSuite) TestEventsFilterImageName(c *check.C) {
since := daemonUnixTime(c)
out, _ := dockerCmd(c, "run", "--name", "container_1", "-d", "busybox:latest", "true")
container1 := strings.TrimSpace(out)
out, _ = dockerCmd(c, "run", "--name", "container_2", "-d", "busybox", "true")
container2 := strings.TrimSpace(out)
name := "busybox"
out, _ = dockerCmd(c, "events", "--since", since, "--until", daemonUnixTime(c), "--filter", fmt.Sprintf("image=%s", name))
events := strings.Split(out, "\n")
events = events[:len(events)-1]
c.Assert(events, checker.Not(checker.HasLen), 0) //Expected events but found none for the image busybox:latest
count1 := 0
count2 := 0
for _, e := range events {
if strings.Contains(e, container1) {
count1++
} else if strings.Contains(e, container2) {
count2++
}
}
c.Assert(count1, checker.Not(checker.Equals), 0, check.Commentf("Expected event from container but got %d from %s", count1, container1))
c.Assert(count2, checker.Not(checker.Equals), 0, check.Commentf("Expected event from container but got %d from %s", count2, container2))
}
示例4: TestServiceCreateWithSecretSourceTarget
func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTarget(c *check.C) {
d := s.AddDaemon(c, true, true)
serviceName := "test-service-secret"
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Name: testName,
},
[]byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
testTarget := "testing"
out, err := d.Cmd("service", "create", "--name", serviceName, "--secret", fmt.Sprintf("source=%s,target=%s", testName, testTarget), "busybox", "top")
c.Assert(err, checker.IsNil, check.Commentf(out))
out, err = d.Cmd("service", "inspect", "--format", "{{ json .Spec.TaskTemplate.ContainerSpec.Secrets }}", serviceName)
c.Assert(err, checker.IsNil)
var refs []swarm.SecretReference
c.Assert(json.Unmarshal([]byte(out), &refs), checker.IsNil)
c.Assert(refs, checker.HasLen, 1)
c.Assert(refs[0].SecretName, checker.Equals, testName)
c.Assert(refs[0].File, checker.Not(checker.IsNil))
c.Assert(refs[0].File.Name, checker.Equals, testTarget)
}
示例5: TestSaveLoadNoTag
func (s *DockerSuite) TestSaveLoadNoTag(c *check.C) {
testRequires(c, DaemonIsLinux)
name := "saveloadnotag"
_, err := buildImage(name, "FROM busybox\nENV foo=bar", true)
c.Assert(err, checker.IsNil, check.Commentf("%v", err))
id := inspectField(c, name, "Id")
// Test to make sure that save w/o name just shows imageID during load
out, _, err := testutil.RunCommandPipelineWithOutput(
exec.Command(dockerBinary, "save", id),
exec.Command(dockerBinary, "load"))
c.Assert(err, checker.IsNil, check.Commentf("failed to save and load repo: %s, %v", out, err))
// Should not show 'name' but should show the image ID during the load
c.Assert(out, checker.Not(checker.Contains), "Loaded image: ")
c.Assert(out, checker.Contains, "Loaded image ID:")
c.Assert(out, checker.Contains, id)
// Test to make sure that save by name shows that name during load
out, _, err = testutil.RunCommandPipelineWithOutput(
exec.Command(dockerBinary, "save", name),
exec.Command(dockerBinary, "load"))
c.Assert(err, checker.IsNil, check.Commentf("failed to save and load repo: %s, %v", out, err))
c.Assert(out, checker.Contains, "Loaded image: "+name+":latest")
c.Assert(out, checker.Not(checker.Contains), "Loaded image ID:")
}
示例6: TestPruneImageDangling
func (s *DockerDaemonSuite) TestPruneImageDangling(c *check.C) {
s.d.StartWithBusybox(c)
out, _, err := s.d.BuildImageWithOut("test",
`FROM busybox
LABEL foo=bar`, true, "-q")
c.Assert(err, checker.IsNil)
id := strings.TrimSpace(out)
out, err = s.d.Cmd("images", "-q", "--no-trunc")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Contains, id)
out, err = s.d.Cmd("image", "prune", "--force")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id)
out, err = s.d.Cmd("images", "-q", "--no-trunc")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Contains, id)
out, err = s.d.Cmd("image", "prune", "--force", "--all")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Contains, id)
out, err = s.d.Cmd("images", "-q", "--no-trunc")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id)
}
示例7: TestSearchWithLimit
// test case for #23055
func (s *DockerSuite) TestSearchWithLimit(c *check.C) {
testRequires(c, Network, DaemonIsLinux)
limit := 10
out, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
c.Assert(err, checker.IsNil)
outSlice := strings.Split(out, "\n")
c.Assert(outSlice, checker.HasLen, limit+2) // 1 header, 1 carriage return
limit = 50
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
c.Assert(err, checker.IsNil)
outSlice = strings.Split(out, "\n")
c.Assert(outSlice, checker.HasLen, limit+2) // 1 header, 1 carriage return
limit = 100
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
c.Assert(err, checker.IsNil)
outSlice = strings.Split(out, "\n")
c.Assert(outSlice, checker.HasLen, limit+2) // 1 header, 1 carriage return
limit = 0
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
c.Assert(err, checker.Not(checker.IsNil))
limit = 200
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
c.Assert(err, checker.Not(checker.IsNil))
}
示例8: TestPsByOrder
func (s *DockerSuite) TestPsByOrder(c *check.C) {
name1 := "xyz-abc"
out, err := runSleepingContainer(c, "--name", name1)
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
container1 := strings.TrimSpace(out)
name2 := "xyz-123"
out, err = runSleepingContainer(c, "--name", name2)
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
container2 := strings.TrimSpace(out)
name3 := "789-abc"
out, err = runSleepingContainer(c, "--name", name3)
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
name4 := "789-123"
out, err = runSleepingContainer(c, "--name", name4)
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
// Run multiple time should have the same result
out, err = dockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz")
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%s\n%s", container2, container1))
// Run multiple time should have the same result
out, err = dockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz")
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%s\n%s", container2, container1))
}
示例9: TestSecretCreateWithFile
func (s *DockerSwarmSuite) TestSecretCreateWithFile(c *check.C) {
d := s.AddDaemon(c, true, true)
testFile, err := ioutil.TempFile("", "secretCreateTest")
c.Assert(err, checker.IsNil, check.Commentf("failed to create temporary file"))
defer os.Remove(testFile.Name())
testData := "TESTINGDATA"
_, err = testFile.Write([]byte(testData))
c.Assert(err, checker.IsNil, check.Commentf("failed to write to temporary file"))
testName := "test_secret"
out, err := d.Cmd("secret", "create", "--file", testFile.Name(), testName)
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "", check.Commentf(out))
id := strings.TrimSpace(out)
secret := d.GetSecret(c, id)
c.Assert(secret.Spec.Name, checker.Equals, testName)
testName = "test_secret_2"
out, err = d.Cmd("secret", "create", testName, "-f", testFile.Name())
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "", check.Commentf(out))
id = strings.TrimSpace(out)
secret = d.GetSecret(c, id)
c.Assert(secret.Spec.Name, checker.Equals, testName)
}
示例10: TestInspectStopWhenNotFound
func (s *DockerSuite) TestInspectStopWhenNotFound(c *check.C) {
runSleepingContainer(c, "--name=busybox", "-d")
runSleepingContainer(c, "--name=not-shown", "-d")
out, _, err := dockerCmdWithError("inspect", "--type=container", "--format='{{.Name}}'", "busybox", "missing", "not-shown")
c.Assert(err, checker.Not(check.IsNil))
c.Assert(out, checker.Contains, "busybox")
c.Assert(out, checker.Not(checker.Contains), "not-shown")
c.Assert(out, checker.Contains, "Error: No such container: missing")
}
示例11: TestDaemonEventsWithFilters
func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *check.C) {
testRequires(c, SameHostDaemon, DaemonIsLinux)
// daemon config file
configFilePath := "test.json"
configFile, err := os.Create(configFilePath)
c.Assert(err, checker.IsNil)
defer os.Remove(configFilePath)
daemonConfig := `{"labels":["foo=bar"]}`
fmt.Fprintf(configFile, "%s", daemonConfig)
configFile.Close()
s.d.Start(c, fmt.Sprintf("--config-file=%s", configFilePath))
// Get daemon ID
out, err := s.d.Cmd("info")
c.Assert(err, checker.IsNil)
daemonID := ""
daemonName := ""
for _, line := range strings.Split(out, "\n") {
if strings.HasPrefix(line, "ID: ") {
daemonID = strings.TrimPrefix(line, "ID: ")
} else if strings.HasPrefix(line, "Name: ") {
daemonName = strings.TrimPrefix(line, "Name: ")
}
}
c.Assert(daemonID, checker.Not(checker.Equals), "")
c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil)
time.Sleep(3 * time.Second)
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c), "--filter", fmt.Sprintf("daemon=%s", daemonID))
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, fmt.Sprintf("daemon reload %s", daemonID))
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c), "--filter", fmt.Sprintf("daemon=%s", daemonName))
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, fmt.Sprintf("daemon reload %s", daemonID))
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c), "--filter", "daemon=foo")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Not(checker.Contains), fmt.Sprintf("daemon reload %s", daemonID))
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c), "--filter", "type=daemon")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, fmt.Sprintf("daemon reload %s", daemonID))
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c), "--filter", "type=container")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Not(checker.Contains), fmt.Sprintf("daemon reload %s", daemonID))
}
示例12: TestPluginIDPrefix
func (s *DockerSuite) TestPluginIDPrefix(c *check.C) {
testRequires(c, DaemonIsLinux, Network)
_, _, err := dockerCmdWithError("plugin", "install", "--disable", "--grant-all-permissions", pNameWithTag)
c.Assert(err, checker.IsNil)
// Find ID first
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
id = strings.TrimSpace(id)
c.Assert(err, checker.IsNil)
// List current state
out, _, err := dockerCmdWithError("plugin", "ls")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, pName)
c.Assert(out, checker.Contains, pTag)
c.Assert(out, checker.Contains, "false")
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
dockerCmd(c, "plugin", "set", id[:5], "DEBUG=1")
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
// Enable
_, _, err = dockerCmdWithError("plugin", "enable", id[:5])
c.Assert(err, checker.IsNil)
out, _, err = dockerCmdWithError("plugin", "ls")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, pName)
c.Assert(out, checker.Contains, pTag)
c.Assert(out, checker.Contains, "true")
// Disable
_, _, err = dockerCmdWithError("plugin", "disable", id[:5])
c.Assert(err, checker.IsNil)
out, _, err = dockerCmdWithError("plugin", "ls")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, pName)
c.Assert(out, checker.Contains, pTag)
c.Assert(out, checker.Contains, "false")
// Remove
out, _, err = dockerCmdWithError("plugin", "remove", id[:5])
c.Assert(err, checker.IsNil)
// List returns none
out, _, err = dockerCmdWithError("plugin", "ls")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Not(checker.Contains), pName)
c.Assert(out, checker.Not(checker.Contains), pTag)
}
示例13: TestLinksPingLinkedContainersOnRename
func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
// Problematic on Windows as Windows does not support links
testRequires(c, DaemonIsLinux)
var out string
out, _ = dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
idA := strings.TrimSpace(out)
c.Assert(idA, checker.Not(checker.Equals), "", check.Commentf("%s, id should not be nil", out))
out, _ = dockerCmd(c, "run", "-d", "--link", "container1:alias1", "--name", "container2", "busybox", "top")
idB := strings.TrimSpace(out)
c.Assert(idB, checker.Not(checker.Equals), "", check.Commentf("%s, id should not be nil", out))
dockerCmd(c, "exec", "container2", "ping", "-c", "1", "alias1", "-W", "1")
dockerCmd(c, "rename", "container1", "container_new")
dockerCmd(c, "exec", "container2", "ping", "-c", "1", "alias1", "-W", "1")
}
示例14: TestCLIProxyProxyTCPSock
// Can't use localhost here since go has a special case to not use proxy if connecting to localhost
// See https://golang.org/pkg/net/http/#ProxyFromEnvironment
func (s *DockerDaemonSuite) TestCLIProxyProxyTCPSock(c *check.C) {
testRequires(c, SameHostDaemon)
// get the IP to use to connect since we can't use localhost
addrs, err := net.InterfaceAddrs()
c.Assert(err, checker.IsNil)
var ip string
for _, addr := range addrs {
sAddr := addr.String()
if !strings.Contains(sAddr, "127.0.0.1") {
addrArr := strings.Split(sAddr, "/")
ip = addrArr[0]
break
}
}
c.Assert(ip, checker.Not(checker.Equals), "")
s.d.Start(c, "-H", "tcp://"+ip+":2375")
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "info"},
Env: []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999"},
}).Assert(c, icmd.Expected{Error: "exit status 1", ExitCode: 1})
// Test with no_proxy
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "info"},
Env: []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999", "NO_PROXY=" + ip},
}).Assert(c, icmd.Success)
}
示例15: TestServiceLogs
func (s *DockerSwarmSuite) TestServiceLogs(c *check.C) {
testRequires(c, ExperimentalDaemon)
d := s.AddDaemon(c, true, true)
// we have multiple services here for detecting the goroutine issue #28915
services := map[string]string{
"TestServiceLogs1": "hello1",
"TestServiceLogs2": "hello2",
}
for name, message := range services {
out, err := d.Cmd("service", "create", "--name", name, "busybox",
"sh", "-c", fmt.Sprintf("echo %s; tail -f /dev/null", message))
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
}
// make sure task has been deployed.
waitAndAssert(c, defaultReconciliationTimeout,
d.CheckActiveContainerCount, checker.Equals, len(services))
for name, message := range services {
out, err := d.Cmd("service", "logs", name)
c.Assert(err, checker.IsNil)
c.Logf("log for %q: %q", name, out)
c.Assert(out, checker.Contains, message)
}
}