本文整理匯總了Golang中github.com/eris-ltd/eris-cli/testutils.RemoveAllContainers函數的典型用法代碼示例。如果您正苦於以下問題:Golang RemoveAllContainers函數的具體用法?Golang RemoveAllContainers怎麽用?Golang RemoveAllContainers使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了RemoveAllContainers函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestServiceLinkBadChainWithoutChainInDefinition
func TestServiceLinkBadChainWithoutChainInDefinition(t *testing.T) {
defer tests.RemoveAllContainers()
if err := tests.FakeServiceDefinition(erisDir, "fake", `
[service]
name = "fake"
image = "quay.io/eris/ipfs"
`); err != nil {
t.Fatalf("can't create a fake service definition: %v", err)
}
do := def.NowDo()
do.Operations.Args = []string{"fake"}
do.Operations.ContainerNumber = 1
do.ChainName = "non-existent-chain"
// [pv]: is this a bug? the service which doesn't have a
// "chain" in its definition file doesn't care about linking at all.
if err := services.StartService(do); err != nil {
t.Fatalf("expect service to start, got %v", err)
}
if n := util.HowManyContainersRunning("fake", def.TypeService); n != 1 {
t.Fatalf("expecting 1 service containers, got %v", n)
}
if n := util.HowManyContainersExisting("fake", def.TypeData); n != 0 {
t.Fatalf("expecting 0 data containers, got %v", n)
}
}
示例2: TestStopDataContainer
func TestStopDataContainer(t *testing.T) {
const (
name = "ipfs"
number = 99
)
if n := util.HowManyContainersExisting(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 containers, got %v", n)
}
srv, err := loaders.LoadServiceDefinition(name, true, number)
if err != nil {
t.Fatalf("could not load service definition %v", err)
}
if err := DockerRunService(srv.Service, srv.Operations); err != nil {
t.Fatalf("expected service container created, got %v", err)
}
srv.Operations.SrvContainerName = srv.Operations.DataContainerName
if err := DockerStop(srv.Service, srv.Operations, 5); err == nil {
t.Fatalf("expected stop to fail, got %v", err)
}
tests.RemoveAllContainers()
}
示例3: TestRunServiceNoDataContainer
func TestRunServiceNoDataContainer(t *testing.T) {
const (
name = "ipfs"
number = 99
)
if n := util.HowManyContainersExisting(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 containers, got %v", n)
}
srv, err := loaders.LoadServiceDefinition(name, true, number)
if err != nil {
t.Fatalf("could not load service definition %v", err)
}
srv.Service.AutoData = false
if err := DockerRunService(srv.Service, srv.Operations); err != nil {
t.Fatalf("expected service container created, got %v", err)
}
if n := util.HowManyContainersRunning(name, def.TypeService); n != 1 {
t.Fatalf("expecting 1 service container running, got %v", n)
}
if n := util.HowManyContainersExisting(name, def.TypeData); n != 0 {
t.Fatalf("expecting no dependent data containers, got %v", n)
}
tests.RemoveAllContainers()
}
示例4: TestExecServiceAfterRunService
func TestExecServiceAfterRunService(t *testing.T) {
const (
name = "ipfs"
number = 99
)
if n := util.HowManyContainersExisting(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 containers, got %v", n)
}
srv, err := loaders.LoadServiceDefinition(name, true, number)
if err != nil {
t.Fatalf("could not load service definition %v", err)
}
if err := DockerRunService(srv.Service, srv.Operations); err != nil {
t.Fatalf("expected service container created, got %v", err)
}
srv.Operations.Interactive = true
srv.Operations.Args = []string{"uptime"}
if err := DockerExecService(srv.Service, srv.Operations); err == nil {
t.Fatalf("expected failure due to unpublished ports, got %v", err)
}
tests.RemoveAllContainers()
}
示例5: TestContainerRunningBadName
func TestContainerRunningBadName(t *testing.T) {
const (
name = "ipfs"
number = 99
)
if n := util.HowManyContainersExisting(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 containers, got %v", n)
}
srv, err := loaders.LoadServiceDefinition(name, true, number)
if err != nil {
t.Fatalf("could not load service definition %v", err)
}
if err := DockerRunService(srv.Service, srv.Operations); err != nil {
t.Fatalf("expected service container created, got %v", err)
}
if _, exists := ContainerRunning(srv.Operations); exists == false {
t.Fatalf("expecting service container running, got false")
}
srv.Operations.SrvContainerName = "random-bad-name"
if _, exists := ContainerRunning(srv.Operations); exists == true {
t.Fatalf("expecting data container not running, got true")
}
tests.RemoveAllContainers()
}
示例6: TestExecServiceAfterRunServiceWithPublishedPorts2
func TestExecServiceAfterRunServiceWithPublishedPorts2(t *testing.T) {
const (
name = "ipfs"
number = 99
)
if n := util.HowManyContainersExisting(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 containers, got %v", n)
}
srv, err := loaders.LoadServiceDefinition(name, true, number)
if err != nil {
t.Fatalf("could not load service definition %v", err)
}
if err := DockerRunService(srv.Service, srv.Operations); err != nil {
t.Fatalf("expected service container created, got %v", err)
}
srv.Operations.PublishAllPorts = true
srv.Operations.Interactive = true
srv.Operations.Args = []string{"uptime"}
if err := DockerExecService(srv.Service, srv.Operations); err != nil {
t.Fatalf("expected exec container created, got %v", err)
}
if n := util.HowManyContainersRunning(name, def.TypeService); n != 1 {
t.Fatalf("expecting 1 service container running, got %v", n)
}
if n := util.HowManyContainersExisting(name, def.TypeData); n != 1 {
t.Fatalf("expecting 1 dependent data container, got %v", n)
}
tests.RemoveAllContainers()
}
示例7: TestExecServiceBadCommandLine
func TestExecServiceBadCommandLine(t *testing.T) {
const (
name = "ipfs"
number = 99
)
if n := util.HowManyContainersExisting(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 containers, got %v", n)
}
srv, err := loaders.LoadServiceDefinition(name, true, number)
if err != nil {
t.Fatalf("could not load service definition %v", err)
}
srv.Operations.Interactive = false
srv.Operations.Args = []string{"/bad/command/line"}
if err := DockerExecService(srv.Service, srv.Operations); err == nil {
t.Fatalf("expected failure, got %v", err)
}
if n := util.HowManyContainersRunning(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 service container running, got %v", n)
}
if n := util.HowManyContainersExisting(name, def.TypeData); n != 1 {
t.Fatalf("expecting 1 dependent data container, got %v", n)
}
tests.RemoveAllContainers()
}
示例8: TestCreateDataSimple
func TestCreateDataSimple(t *testing.T) {
const (
name = "testdata"
number = 199
)
if n := util.HowManyContainersExisting(name, def.TypeData); n != 0 {
t.Fatalf("expecting 0 containers, got %v", n)
}
ops := loaders.LoadDataDefinition(name, number)
if err := DockerCreateData(ops); err != nil {
t.Fatalf("expected data container created, got %v", err)
}
if n := util.HowManyContainersExisting(name, def.TypeData); n != 1 {
t.Fatalf("expecting 1 containers, got %v", n)
}
// Try to create a duplicate.
if err := DockerCreateData(ops); err == nil {
t.Fatalf("expected an error, got nil")
}
tests.RemoveAllContainers()
}
示例9: TestServiceLinkKeys
func TestServiceLinkKeys(t *testing.T) {
defer tests.RemoveAllContainers()
do := def.NowDo()
do.Name = chainName
do.Operations.ContainerNumber = 1
if err := NewChain(do); err != nil {
t.Fatalf("could not start a new chain, got %v", err)
}
if n := util.HowManyContainersExisting(chainName, def.TypeChain); n != 1 {
t.Fatalf("expecting 1 test chain containers, got %v", n)
}
do = def.NowDo()
do.Operations.Args = []string{"keys"}
do.Operations.ContainerNumber = 1
do.ChainName = chainName
if err := services.StartService(do); err != nil {
t.Fatalf("expecting service to start, got %v", err)
}
if n := util.HowManyContainersExisting("keys", def.TypeService); n != 1 {
t.Fatalf("expecting 1 test chain containers, got %v", n)
}
links := tests.Links("keys", def.TypeService, 1)
if len(links) != 0 {
t.Fatalf("expected service links be empty, got %v", links)
}
}
示例10: TestDataContainerExistsAfterRemove
func TestDataContainerExistsAfterRemove(t *testing.T) {
const (
name = "ipfs"
number = 99
)
if n := util.HowManyContainersExisting(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 containers, got %v", n)
}
srv, err := loaders.LoadServiceDefinition(name, true, number)
if err != nil {
t.Fatalf("could not load service definition %v", err)
}
if err := DockerRunService(srv.Service, srv.Operations); err != nil {
t.Fatalf("expected service container created, got %v", err)
}
srv.Operations.SrvContainerName = srv.Operations.DataContainerName
if _, exists := DataContainerExists(srv.Operations); exists == false {
t.Fatalf("expecting service container exists, got false")
}
tests.RemoveContainer(name, def.TypeData, number)
if _, exists := DataContainerExists(srv.Operations); exists == true {
t.Fatalf("expecting service container not existing after remove, got true")
}
tests.RemoveAllContainers()
}
示例11: TestServiceLinkWithDataContainer
func TestServiceLinkWithDataContainer(t *testing.T) {
defer tests.RemoveAllContainers()
do := def.NowDo()
do.Name = chainName
do.Operations.ContainerNumber = 1
if err := NewChain(do); err != nil {
t.Fatalf("could not start a new chain, got %v", err)
}
if err := tests.FakeServiceDefinition(erisDir, "fake", `
chain = "$chain:fake"
[service]
name = "fake"
image = "quay.io/eris/ipfs"
data_container = true
`); err != nil {
t.Fatalf("can't create a fake service definition: %v", err)
}
if n := util.HowManyContainersExisting(chainName, def.TypeChain); n != 1 {
t.Fatalf("expecting 1 test chain containers, got %v", n)
}
if n := util.HowManyContainersExisting("fake", def.TypeService); n != 0 {
t.Fatalf("expecting 0 service containers, got %v", n)
}
if n := util.HowManyContainersExisting("fake", def.TypeData); n != 0 {
t.Fatalf("expecting 0 data containers, got %v", n)
}
do = def.NowDo()
do.Operations.Args = []string{"fake"}
do.Operations.ContainerNumber = 1
do.ChainName = chainName
if err := services.StartService(do); err != nil {
t.Fatalf("expecting service to start, got %v", err)
}
if n := util.HowManyContainersRunning("fake", def.TypeService); n != 1 {
t.Fatalf("expecting 1 service containers, got %v", n)
}
if n := util.HowManyContainersExisting("fake", def.TypeData); n != 1 {
t.Fatalf("expecting 1 data containers, got %v", n)
}
links := tests.Links("fake", def.TypeService, 1)
if len(links) != 1 || !strings.Contains(links[0], chainName) {
t.Fatalf("expected service be linked to a test chain, got %v", links)
}
}
示例12: TestRemoveWithoutData
func TestRemoveWithoutData(t *testing.T) {
const (
name = "ipfs"
number = 99
)
if n := util.HowManyContainersExisting(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 containers, got %v", n)
}
srv, err := loaders.LoadServiceDefinition(name, true, number)
if err != nil {
t.Fatalf("could not load service definition %v", err)
}
if err := DockerRunService(srv.Service, srv.Operations); err != nil {
t.Fatalf("expected service container created, got %v", err)
}
if err := DockerStop(srv.Service, srv.Operations, 5); err != nil {
t.Fatal("expected service container stopped, got %v", err)
}
if n := util.HowManyContainersExisting(name, def.TypeService); n != 1 {
t.Fatalf("expecting 1 service container running (before removal), got %v", n)
}
if err := DockerRemove(srv.Service, srv.Operations, false, true); err != nil {
t.Fatal("expected service container removed, got %v", err)
}
if n := util.HowManyContainersExisting(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 service container running (after removal), got %v", n)
}
srv.Operations.SrvContainerName = srv.Operations.DataContainerName
if n := util.HowManyContainersExisting(name, def.TypeData); n != 1 {
t.Fatalf("expecting 1 data container existing (before removal), got %v", n)
}
if err := DockerRemove(srv.Service, srv.Operations, false, true); err != nil {
t.Fatal("expected service container removed, got %v", err)
}
if n := util.HowManyContainersExisting(name, def.TypeData); n != 0 {
t.Fatalf("expecting 0 data container running (after removal), got %v", n)
}
tests.RemoveAllContainers()
}
示例13: TestStopSimple
func TestStopSimple(t *testing.T) {
const (
name = "ipfs"
number = 99
)
if n := util.HowManyContainersExisting(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 containers, got %v", n)
}
srv, err := loaders.LoadServiceDefinition(name, true, number)
if err != nil {
t.Fatalf("could not load service definition %v", err)
}
if err := DockerRunService(srv.Service, srv.Operations); err != nil {
t.Fatalf("expected service container created, got %v", err)
}
if n := util.HowManyContainersRunning(name, def.TypeService); n != 1 {
t.Fatalf("expecting 1 service containers running, got %v", n)
}
if n := util.HowManyContainersRunning(name, def.TypeService); n != 1 {
t.Fatalf("expecting 1 service containers existing, got %v", n)
}
if err := DockerStop(srv.Service, srv.Operations, 5); err != nil {
t.Fatalf("expected service container to stop, got %v", err)
}
if n := util.HowManyContainersRunning(name, def.TypeService); n != 0 {
t.Fatalf("expecting 0 service containers running (after stop), got %v", n)
}
if n := util.HowManyContainersRunning(name, def.TypeService); n != 0 {
t.Fatalf("expecting 1 service containers existing (after stop), got %v", n)
}
tests.RemoveAllContainers()
}
示例14: TestMain
func TestMain(m *testing.M) {
var logLevel log.LogLevel
logLevel = 0
// logLevel = 1
// logLevel = 3
log.SetLoggers(logLevel, os.Stdout, os.Stderr)
tests.IfExit(tests.TestsInit("perform"))
tests.RemoveAllContainers()
exitCode := m.Run()
if os.Getenv("TEST_IN_CIRCLE") != "true" {
tests.IfExit(tests.TestsTearDown())
}
os.Exit(exitCode)
}
示例15: TestServiceLinkBadChain
func TestServiceLinkBadChain(t *testing.T) {
defer tests.RemoveAllContainers()
if err := tests.FakeServiceDefinition(erisDir, "fake", `
chain = "$chain:fake"
[service]
name = "fake"
image = "quay.io/eris/ipfs"
`); err != nil {
t.Fatalf("can't create a fake service definition: %v", err)
}
do := def.NowDo()
do.Operations.Args = []string{"fake"}
do.Operations.ContainerNumber = 1
do.ChainName = "non-existent-chain"
if err := services.StartService(do); err == nil {
t.Fatalf("expect start service to fail, got nil")
}
}