本文整理匯總了Golang中github.com/eris-ltd/eris-cli/definitions.NowDo函數的典型用法代碼示例。如果您正苦於以下問題:Golang NowDo函數的具體用法?Golang NowDo怎麽用?Golang NowDo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NowDo函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: StartServicesAndChains
func StartServicesAndChains(do *definitions.Do) error {
// start the services and chains
doSrvs := definitions.NowDo()
if do.Action.Dependencies == nil || len(do.Action.Dependencies.Services) == 0 {
log.Debug("No services to start")
} else {
doSrvs.Operations.Args = do.Action.Dependencies.Services
log.WithField("args", doSrvs.Operations.Args).Debug("Starting services")
if err := services.StartService(doSrvs); err != nil {
return err
}
}
doChns := definitions.NowDo()
doChns.Name = do.Action.Chain
if doChns.Name == "" {
log.Debug("No chain to start")
} else {
log.WithField("=>", doChns.Name).Debug("Starting chain")
if err := chains.StartChain(do); err != nil {
return err
}
}
return nil
}
示例2: 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)
}
}
示例3: TestInspectService
func TestInspectService(t *testing.T) {
testStartService(t, servName, false)
defer testKillService(t, servName, true)
do := def.NowDo()
do.Name = servName
do.Operations.Args = []string{"name"}
do.Operations.ContainerNumber = 1
log.WithFields(log.Fields{
"=>": fmt.Sprintf("%s:%d", servName, do.Operations.ContainerNumber),
"args": do.Operations.Args,
}).Debug("Inspect service (from tests)")
e := InspectService(do)
if e != nil {
log.Infof("Error inspecting service: %v", e)
tests.IfExit(e)
}
do = def.NowDo()
do.Name = servName
do.Operations.Args = []string{"config.user"}
do.Operations.ContainerNumber = 1
log.WithFields(log.Fields{
"=>": servName,
"args": do.Operations.Args,
}).Debug("Inspect service (from tests)")
e = InspectService(do)
if e != nil {
log.Infof("Error inspecting service: %v", e)
tests.IfExit(e)
}
}
示例4: TestKillRmService
func TestKillRmService(t *testing.T) {
testStartService(t, servName, false)
do := def.NowDo()
do.Name = servName
do.Rm = false
do.RmD = false
do.Operations.Args = []string{servName}
log.WithField("=>", servName).Debug("Stopping service (from tests)")
if e := KillService(do); e != nil {
log.Error(e)
tests.IfExit(e)
}
testExistAndRun(t, servName, 1, true, false)
testNumbersExistAndRun(t, servName, 1, 0)
if os.Getenv("TEST_IN_CIRCLE") == "true" {
log.Warn("Testing in Circle where we don't have rm privileges. Skipping test")
return
}
do = def.NowDo()
do.Name = servName
do.Operations.Args = []string{servName}
do.File = false
do.RmD = true
log.WithField("=>", servName).Debug("Removing service (from tests)")
if e := RmService(do); e != nil {
log.Error(e)
tests.IfExit(e)
}
testExistAndRun(t, servName, 1, false, false)
testNumbersExistAndRun(t, servName, 0, 0)
}
示例5: StartServicesAndChains
func StartServicesAndChains(do *definitions.Do) error {
// start the services and chains
doSrvs := definitions.NowDo()
doSrvs.Args = do.Action.ServiceDeps
if len(doSrvs.Args) == 0 {
logger.Debugf("No services to start.\n")
} else {
logger.Debugf("Starting Services. Args =>\t%v\n", doSrvs.Args)
if err := services.StartService(doSrvs); err != nil {
return err
}
}
doChns := definitions.NowDo()
doChns.Name = do.Action.Chain
if doChns.Name == "" {
logger.Debugf("No chain to start.\n")
} else {
logger.Debugf("Starting Chain. Name =>\t\t%v\n", doChns.Name)
if err := chains.StartChain(do); err != nil {
return err
}
}
return nil
}
示例6: 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)
}
}
示例7: TestRenameChain
func TestRenameChain(t *testing.T) {
aChain := "hichain"
rename1 := "niahctset"
rename2 := chainName
testNewChain(aChain)
defer testKillChain(t, rename2)
do := def.NowDo()
do.Name = aChain
do.NewName = rename1
log.WithFields(log.Fields{
"from": do.Name,
"to": do.NewName,
}).Info("Renaming chain (from tests)")
if e := RenameChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, rename1, true, true)
do = def.NowDo()
do.Name = rename1
do.NewName = rename2
log.WithFields(log.Fields{
"from": do.Name,
"to": do.NewName,
}).Info("Renaming chain (from tests)")
if e := RenameChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, chainName, true, true)
}
示例8: TestGetPubKey
func TestGetPubKey(t *testing.T) {
testStartKeys(t)
defer testKillService(t, "keys", true)
doPub := def.NowDo()
doPub.Address = testsGenAKey()
pub := new(bytes.Buffer)
config.GlobalConfig.Writer = pub
if err := GetPubKey(doPub); err != nil {
fatal(t, err)
}
pubBytes := pub.Bytes()
pubkey := trimString(string(pubBytes))
key := new(bytes.Buffer)
config.GlobalConfig.Writer = key
doKey := def.NowDo()
doKey.Address = doPub.Address
if err := ConvertKey(doKey); err != nil {
fatal(t, err)
}
converted := regexp.MustCompile(`"pub_key":\[1,"([^"]+)"\]`).FindStringSubmatch(key.String())[1]
if converted != pubkey {
fatal(t, fmt.Errorf("Expected (%s), got (%s)\n", pubkey, converted))
}
}
示例9: TestRenameChain
func TestRenameChain(t *testing.T) {
aChain := "hichain"
rename1 := "niahctset"
rename2 := chainName
testNewChain(aChain)
defer testKillChain(t, rename2)
do := def.NowDo()
do.Name = aChain
do.NewName = rename1
logger.Infof("Renaming chain (from tests) =>\t%s:%s\n", do.Name, do.NewName)
if e := RenameChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, rename1, true, true)
do = def.NowDo()
do.Name = rename1
do.NewName = rename2
logger.Infof("Renaming chain (from tests) =>\t%s:%s\n", do.Name, do.NewName)
if e := RenameChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, chainName, true, true)
}
示例10: TestInspectData
func TestInspectData(t *testing.T) {
testCreateDataByImport(t, dataName)
defer testKillDataCont(t, dataName)
do := definitions.NowDo()
do.Name = dataName
do.Operations.Args = []string{"name"}
do.Operations.ContainerNumber = 1
log.WithFields(log.Fields{
"data container": do.Name,
"args": do.Operations.Args,
}).Info("Inspecting data (from tests)")
if err := InspectData(do); err != nil {
log.Error(err)
t.FailNow()
}
do = definitions.NowDo()
do.Name = dataName
do.Operations.Args = []string{"config.network_disabled"}
do.Operations.ContainerNumber = 1
log.WithFields(log.Fields{
"data container": do.Name,
"args": do.Operations.Args,
}).Info("Inspecting data (from tests)")
if err := InspectData(do); err != nil {
log.Error(err)
t.Fail()
}
}
示例11: checkIPFSnotRunning
//------- helpers --------
func checkIPFSnotRunning() {
//os.Setenv("ERIS_IPFS_HOST", "http://0.0.0.0") //conflicts with docker-machine
do := def.NowDo()
do.Known = false
do.Existing = false
do.Running = true
do.Quiet = true
log.Debug("Finding the running services")
if err := list.ListAll(do, "services"); err != nil {
IfExit(err)
}
res := strings.Split(do.Result, "\n")
for _, r := range res {
if r == "ipfs" {
IfExit(fmt.Errorf("IPFS service is running.\nPlease stop it with.\neris services stop -rx ipfs\n"))
}
}
// make sure ipfs container does not exist
do = def.NowDo()
do.Known = false
do.Existing = true
do.Running = false
do.Quiet = true
log.Debug("Finding the existing services")
if err := list.ListAll(do, "services"); err != nil {
IfExit(err)
}
res = strings.Split(do.Result, "\n")
for _, r := range res {
if r == "ipfs" {
IfExit(fmt.Errorf("IPFS service exists.\nPlease remove it with\neris services rm ipfs\n"))
}
}
}
示例12: TestRenameChain
func TestRenameChain(t *testing.T) {
do := def.NowDo()
do.Name = chainName
do.NewName = "niahctset"
logger.Infof("Renaming chain (from tests) =>\t%s:%s\n", do.Name, do.NewName)
e := RenameChain(do)
if e != nil {
logger.Errorln(e)
t.Fail()
}
testExistAndRun(t, "niahctset", true, true)
do = def.NowDo()
do.Name = "niahctset"
do.NewName = chainName
logger.Infof("Renaming chain (from tests) =>\t%s:%s\n", do.Name, do.NewName)
e = RenameChain(do)
if e != nil {
logger.Errorln(e)
t.Fail()
}
testExistAndRun(t, chainName, true, true)
}
示例13: TestRmChain
func TestRmChain(t *testing.T) {
start(t, chainName)
do := def.NowDo()
do.Operations.Args, do.Rm, do.RmD = []string{"keys"}, true, true
if err := services.KillService(do); err != nil {
t.Fatalf("expected service to be stopped, got %v", err)
}
do = def.NowDo()
do.Name, do.Rm, do.RmD = chainName, false, false
log.WithField("=>", do.Name).Info("Stopping chain (from tests)")
if err := KillChain(do); err != nil {
t.Fatalf("expected chain to be stopped, got %v", err)
}
if n := util.HowManyContainersExisting(chainName, def.TypeChain); n != 1 {
t.Fatalf("expecting 1 chain containers, got %v", n)
}
do = def.NowDo()
do.Name = chainName
do.RmD = true
log.WithField("=>", do.Name).Info("Removing chain (from tests)")
if err := RmChain(do); err != nil {
t.Fatalf("expected chain to be removed, got %v", err)
}
if n := util.HowManyContainersExisting(chainName, def.TypeChain); n != 0 {
t.Fatalf("expecting 0 chain containers, got %v", n)
}
}
示例14: TestChainsNewConfigOpts
func TestChainsNewConfigOpts(t *testing.T) {
defer tests.RemoveAllContainers()
const (
chain = "test-config-opts"
)
do := def.NowDo()
do.Name = chain
do.ConfigOpts = []string{"moniker=satoshi", "p2p=1.1.1.1:42", "fast-sync=true"}
do.Operations.ContainerNumber = 1
do.Operations.PublishAllPorts = true
if err := NewChain(do); err != nil {
t.Fatalf("expected to create a new chain, got %v", err)
}
do = def.NowDo()
do.Name = chain
do.Operations.Args = []string{"cat", fmt.Sprintf("/home/eris/.eris/chains/%s/config.toml", chain)}
if err := ExecChain(do); err != nil {
t.Fatalf("expected chain to execute, got %v", err)
}
args := []string{"cat", fmt.Sprintf("/home/eris/.eris/chains/%s/config.toml", chain)}
if out := exec(t, chain, args); !strings.Contains(out, "satoshi") || !strings.Contains(out, "1.1.1.1:42") {
t.Fatalf("expected to find set options in config file, got %v", out)
}
}
示例15: TestRmChain
func TestRmChain(t *testing.T) {
testStartChain(t, chainName)
do := def.NowDo()
do.Operations.Args, do.Rm, do.RmD = []string{"keys"}, true, true
log.WithField("=>", do.Name).Info("Removing keys (from tests)")
if e := services.KillService(do); e != nil {
tests.IfExit(e)
}
do = def.NowDo()
do.Name, do.Rm, do.RmD = chainName, false, false
log.WithField("=>", do.Name).Info("Stopping chain (from tests)")
if e := KillChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, chainName, true, false)
do = def.NowDo()
do.Name = chainName
do.RmD = true
log.WithField("=>", do.Name).Info("Removing chain (from tests)")
if e := RmChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, chainName, false, false)
}