本文整理匯總了Golang中github.com/eris-ltd/eris-cli/util.HowManyContainersRunning函數的典型用法代碼示例。如果您正苦於以下問題:Golang HowManyContainersRunning函數的具體用法?Golang HowManyContainersRunning怎麽用?Golang HowManyContainersRunning使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了HowManyContainersRunning函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestRmService
func TestRmService(t *testing.T) {
defer tests.RemoveAllContainers()
start(t, servName, false)
if n := util.HowManyContainersRunning(servName, def.TypeService); n != 1 {
t.Fatalf("expecting 1 running service container, got %v", n)
}
if n := util.HowManyContainersExisting(servName, def.TypeData); n != 1 {
t.Fatalf("expecting 1 data container, got %v", n)
}
do := def.NowDo()
do.Name = servName
do.Operations.Args = []string{servName}
do.Force = true
do.File = false
do.RmD = true
if err := RmService(do); err != nil {
t.Fatalf("expected service to be removed, got %v", err)
}
if n := util.HowManyContainersRunning(servName, def.TypeService); n != 0 {
t.Fatalf("expecting 0 running service container, got %v", n)
}
if n := util.HowManyContainersExisting(servName, def.TypeService); n != 0 {
t.Fatalf("expecting 0 existing service container, got %v", n)
}
if n := util.HowManyContainersExisting(servName, def.TypeData); n != 0 {
t.Fatalf("expecting 0 data container, got %v", n)
}
}
示例2: TestRenameService
func TestRenameService(t *testing.T) {
defer tests.RemoveAllContainers()
start(t, "keys", false)
if n := util.HowManyContainersRunning("keys", def.TypeService); n != 1 {
t.Fatalf("#1. expecting 1 running service container, got %v", n)
}
if n := util.HowManyContainersExisting("keys", def.TypeData); n != 1 {
t.Fatalf("#1. expecting 1 data container, got %v", n)
}
do := def.NowDo()
do.Name = "keys"
do.NewName = "syek"
if err := RenameService(do); err != nil {
t.Fatalf("expected service to be renamed, got %v", err)
}
if n := util.HowManyContainersRunning("keys", def.TypeService); n != 0 {
t.Fatalf("#2. expecting 0 running service container, got %v", n)
}
if n := util.HowManyContainersExisting("keys", def.TypeData); n != 0 {
t.Fatalf("#2. expecting 0 data container, got %v", n)
}
if n := util.HowManyContainersRunning("syek", def.TypeService); n != 1 {
t.Fatalf("#3. expecting 1 running service container, got %v", n)
}
if n := util.HowManyContainersExisting("syek", def.TypeData); n != 1 {
t.Fatalf("#3. expecting 1 data container, got %v", n)
}
do = def.NowDo()
do.Name = "syek"
do.NewName = "keys"
if err := RenameService(do); err != nil {
t.Fatalf("expected service to be renamed back, got %v", err)
}
if n := util.HowManyContainersRunning("syek", def.TypeService); n != 0 {
t.Fatalf("#4. expecting 0 running service container, got %v", n)
}
if n := util.HowManyContainersExisting("syek", def.TypeData); n != 0 {
t.Fatalf("#4. expecting 0 data container, got %v", n)
}
if n := util.HowManyContainersRunning("keys", def.TypeService); n != 1 {
t.Fatalf("#5. expecting 1 running service container, got %v", n)
}
if n := util.HowManyContainersExisting("keys", def.TypeData); n != 1 {
t.Fatalf("#5. expecting 1 data container, got %v", n)
}
}
示例3: TestNewService
func TestNewService(t *testing.T) {
defer tests.RemoveAllContainers()
do := def.NowDo()
servName := "keys"
do.Name = servName
do.Operations.Args = []string{path.Join(ver.ERIS_REG_DEF, ver.ERIS_IMG_KEYS)}
if err := NewService(do); err != nil {
t.Fatalf("expected a new service to be created, got %v", err)
}
do = def.NowDo()
do.Operations.Args = []string{servName}
if err := StartService(do); err != nil {
t.Fatalf("expected service to be started, got %v", err)
}
if n := util.HowManyContainersRunning(servName, def.TypeService); n != 1 {
t.Fatalf("expecting 1 running service container, got %v", n)
}
if n := util.HowManyContainersExisting(servName, def.TypeData); n != 1 {
t.Fatalf("expecting 1 data container, got %v", n)
}
kill(t, servName, true)
if n := util.HowManyContainersExisting(servName, def.TypeService); n != 0 {
t.Fatalf("expecting 0 service containers, got %v", n)
}
if n := util.HowManyContainersExisting(servName, def.TypeData); n != 0 {
t.Fatalf("expecting 0 data container, got %v", n)
}
}
示例4: 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)
}
}
示例5: 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()
}
示例6: 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()
}
示例7: 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()
}
示例8: testNumbersExistAndRun
//[zr] TODO move to testings package
func testNumbersExistAndRun(t *testing.T, servName string, containerExist, containerRun int) {
log.WithFields(log.Fields{
"=>": servName,
"existing#": containerExist,
"running#": containerRun,
}).Info("Checking number of containers for")
log.WithField("=>", servName).Debug("Checking existing containers for")
exist := util.HowManyContainersExisting(servName, "service")
log.WithField("=>", servName).Debug("Checking running containers for")
run := util.HowManyContainersRunning(servName, "service")
if exist != containerExist {
log.WithFields(log.Fields{
"name": servName,
"expected": containerExist,
"got": exist,
}).Error("Wrong number of existing containers")
fatal(t, nil)
}
if run != containerRun {
log.WithFields(log.Fields{
"name": servName,
"expected": containerExist,
"got": run,
}).Error("Wrong number of running containers")
fatal(t, nil)
}
log.Info("All good")
}
示例9: TestRestartChain
func TestRestartChain(t *testing.T) {
defer tests.RemoveAllContainers()
do := def.NowDo()
do.ConfigFile = filepath.Join(common.ChainsPath, "default", "config.toml")
do.Name = chainName
do.Operations.ContainerNumber = 1
do.Operations.PublishAllPorts = true
if err := NewChain(do); err != nil {
t.Fatalf("expected a new chain to be created, got %v", err)
}
if n := util.HowManyContainersRunning(chainName, def.TypeChain); n != 1 {
t.Fatalf("expecting 1 chain container, got %v", n)
}
if n := util.HowManyContainersExisting(chainName, def.TypeData); n != 1 {
t.Fatalf("expecting 1 data containers, got %v", n)
}
kill(t, chainName)
if n := util.HowManyContainersRunning(chainName, def.TypeChain); n != 0 {
t.Fatalf("expecting 0 chain container, got %v", n)
}
if n := util.HowManyContainersExisting(chainName, def.TypeData); n != 0 {
t.Fatalf("expecting 0 data containers, got %v", n)
}
start(t, chainName)
if n := util.HowManyContainersRunning(chainName, def.TypeChain); n != 1 {
t.Fatalf("expecting 1 chain container, got %v", n)
}
if n := util.HowManyContainersExisting(chainName, def.TypeData); n != 1 {
t.Fatalf("expecting 1 data containers, got %v", n)
}
kill(t, chainName)
if n := util.HowManyContainersRunning(chainName, def.TypeChain); n != 0 {
t.Fatalf("expecting 0 chain container, got %v", n)
}
if n := util.HowManyContainersExisting(chainName, def.TypeData); n != 0 {
t.Fatalf("expecting 0 data containers, got %v", n)
}
}
示例10: TestStartChain
func TestStartChain(t *testing.T) {
defer tests.RemoveAllContainers()
start(t, chainName)
if n := util.HowManyContainersRunning(chainName, def.TypeChain); n != 1 {
t.Fatalf("expecting 1 chain container, got %v", n)
}
if n := util.HowManyContainersExisting(chainName, def.TypeData); n != 1 {
t.Fatalf("expecting 1 data containers, got %v", n)
}
kill(t, chainName)
if n := util.HowManyContainersRunning(chainName, def.TypeChain); n != 0 {
t.Fatalf("expecting 0 chain container, got %v", n)
}
if n := util.HowManyContainersExisting(chainName, def.TypeData); n != 0 {
t.Fatalf("expecting 0 data containers, got %v", n)
}
}
示例11: TestStartKillService
func TestStartKillService(t *testing.T) {
defer tests.RemoveAllContainers()
start(t, servName, false)
if n := util.HowManyContainersRunning(servName, def.TypeService); n != 1 {
t.Fatalf("expecting 1 running service container, got %v", n)
}
if n := util.HowManyContainersExisting(servName, def.TypeData); n != 1 {
t.Fatalf("expecting 1 data container, got %v", n)
}
kill(t, servName, true)
if n := util.HowManyContainersRunning(servName, def.TypeService); n != 0 {
t.Fatalf("expecting 0 running service container, got %v", n)
}
if n := util.HowManyContainersExisting(servName, def.TypeData); n != 0 {
t.Fatalf("expecting 0 data container, got %v", n)
}
}
示例12: 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()
}
示例13: 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)
}
}
示例14: TestStartKillServiceWithDependencies
func TestStartKillServiceWithDependencies(t *testing.T) {
defer tests.RemoveAllContainers()
do := def.NowDo()
do.Operations.Args = []string{"do_not_use"}
if err := StartService(do); err != nil {
t.Fatalf("expected service to start, got %v", err)
}
if n := util.HowManyContainersRunning(servName, def.TypeService); n != 1 {
t.Fatalf("expecting 1 running service container, got %v", n)
}
if n := util.HowManyContainersExisting(servName, def.TypeData); n != 1 {
t.Fatalf("expecting 1 data container, got %v", n)
}
if n := util.HowManyContainersRunning("keys", def.TypeService); n != 1 {
t.Fatalf("expecting 1 running dependent service container, got %v", n)
}
if n := util.HowManyContainersExisting("keys", def.TypeData); n != 1 {
t.Fatalf("expecting 1 dependent data container, got %v", n)
}
kill(t, "do_not_use", true)
if n := util.HowManyContainersRunning(servName, def.TypeService); n != 0 {
t.Fatalf("expecting 0 running service container, got %v", n)
}
if n := util.HowManyContainersExisting(servName, def.TypeData); n != 0 {
t.Fatalf("expecting 0 data container, got %v", n)
}
if n := util.HowManyContainersRunning("keys", def.TypeService); n != 0 {
t.Fatalf("expecting 0 running dependent service container, got %v", n)
}
if n := util.HowManyContainersExisting("keys", def.TypeData); n != 0 {
t.Fatalf("expecting 0 dependent data container, got %v", n)
}
}
示例15: TestUpdateChain
func TestUpdateChain(t *testing.T) {
defer tests.RemoveAllContainers()
start(t, chainName)
do := def.NowDo()
do.Name = chainName
do.Pull = false
do.Operations.PublishAllPorts = true
if err := UpdateChain(do); err != nil {
t.Fatalf("expected chain to update, got %v", err)
}
if n := util.HowManyContainersRunning(chainName, def.TypeChain); n != 1 {
t.Fatalf("expecting 1 chain container running, got %v", n)
}
}