本文整理汇总了Golang中github.com/contiv/systemtests-utils.TestbedNode类的典型用法代码示例。如果您正苦于以下问题:Golang TestbedNode类的具体用法?Golang TestbedNode怎么用?Golang TestbedNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestbedNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: StartClientWithEnvAndArgs
// StartClientWithEnvAndArgs starts a client container with specified env-variables.
// It expects ping to server container to succeed
func StartClientWithEnvAndArgs(t *testing.T, node stu.TestbedNode, contName, ipAddress string,
env, dockerArgs []string) {
cmdStr := "sudo %s docker run %s --name=" + contName +
" ubuntu /bin/bash -c \"ping -c5 " + ipAddress + "\""
cmdStr = fmt.Sprintf(cmdStr, strings.Join(env, " "),
strings.Join(dockerArgs, " "))
output, err := node.RunCommandWithOutput(cmdStr)
if err != nil {
OvsDumpInfo(node)
t.Fatalf("Error '%s' launching container '%s', Output: \n%s\n",
err, contName, output)
}
cmdStr = fmt.Sprintf("sudo docker logs %s", contName)
output, err = node.RunCommandWithOutput(cmdStr)
if err != nil {
t.Fatalf("Error '%s' fetching container '%s' logs, Output: \n%s\n",
err, contName, output)
}
//verify that the output indicates <100% loss (some loss is expected due to
// timing of interface creation and starting ping)
if strings.Contains(string(output), ", 100% packet loss,") {
OvsDumpInfo(node)
t.Fatalf("Ping test failed for container '%s', Output: \n%s\n",
contName, output)
}
}
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:30,代码来源:docker.go
示例2: GetIPAddress
// GetIPAddress returns IP-address information for specified endpoint
func GetIPAddress(t *testing.T, node stu.TestbedNode, ep, stateStore string) string {
cmdStr := "netdcli -oper get -construct endpoint " + ep + " 2>&1"
if stateStore != "" {
cmdStr = "netdcli -oper get -state-store " + stateStore + " -construct endpoint " + ep + " 2>&1"
}
output, err := node.RunCommandWithOutput(cmdStr)
if err != nil || string(output) == "" {
time.Sleep(2 * time.Second)
output, err = node.RunCommandWithOutput(cmdStr)
if err != nil || output == "" {
t.Fatalf("Error getting ip for ep %s. Error: %s, Cmdstr: %s, Output: \n%s\n",
err, ep, cmdStr, output)
}
}
output = strings.Trim(string(output), "[]")
epStruct := drivers.OvsOperEndpointState{}
if err := json.Unmarshal([]byte(output), &epStruct); err != nil {
t.Fatalf("Error getting ip for ep %s. Error: %s, Cmdstr: %s, Output: \n%s\n",
err, ep, cmdStr, output)
}
return epStruct.IPAddress
}
开发者ID:syeduguri,项目名称:netplugin,代码行数:28,代码来源:utils.go
示例3: startVolmaster
func startVolmaster(node utils.TestbedNode) error {
log.Infof("Starting the volmaster on %s", node.GetName())
_, err := node.RunCommandBackground("sudo -E nohup `which volmaster` --debug </dev/null &>/tmp/volmaster.log &")
log.Infof("Waiting for volmaster startup")
time.Sleep(10 * time.Millisecond)
return err
}
开发者ID:hankerepo,项目名称:volplugin,代码行数:7,代码来源:util_test.go
示例4: StartNetmasterWithFlags
// StartNetmasterWithFlags starts netplugin on specified testbed nodes with specified flags
func StartNetmasterWithFlags(t *testing.T, node stu.TestbedNode, flags map[string]string) {
time.Sleep(5 * time.Second)
var (
cmdStr string
flagsStr string
)
for k, v := range flags {
flagsStr += fmt.Sprintf("%s=%s", k, v)
}
if os.Getenv("CONTIV_TESTBED") == "DIND" {
cmdStr = fmt.Sprintf("netmaster %s 1>/tmp/netmaster.log 2>&1", flagsStr)
} else {
cmdStr = fmt.Sprintf("nohup netmaster %s 0<&- &>/tmp/netmaster.log", flagsStr)
}
output, err := node.RunCommandBackground(cmdStr)
if err != nil {
t.Fatalf("Failed to launch netplugin. Error: %s\nCmd:%q\n Output : %s\n",
err, cmdStr, output)
}
time.Sleep(5 * time.Second)
}
开发者ID:syeduguri,项目名称:netplugin,代码行数:26,代码来源:utils.go
示例5: DumpNetpluginLogs
// DumpNetpluginLogs prints netplugin logs from the specified testbed node
func DumpNetpluginLogs(node stu.TestbedNode) {
cmdStr := fmt.Sprintf("sudo cat /tmp/netplugin.log")
output, err := node.RunCommandWithOutput(cmdStr)
if err == nil {
log.Debugf("logs on node %s: \n%s\n", node.GetName(), output)
}
}
开发者ID:syeduguri,项目名称:netplugin,代码行数:8,代码来源:utils.go
示例6: restartDockerHost
func restartDockerHost(node utils.TestbedNode) error {
log.Infof("Restarting docker on %q", node.GetName())
// note that for all these restart tasks we error out quietly to avoid other
// hosts being cleaned up
node.RunCommand("sudo service docker restart")
return nil
}
开发者ID:hankerepo,项目名称:volplugin,代码行数:7,代码来源:util_test.go
示例7: getContainerUUID
func getContainerUUID(node stu.TestbedNode, contName string) (string, error) {
cmdStr := "sudo docker inspect --format='{{.Id}}' " + contName
output, err := node.RunCommandWithOutput(cmdStr)
if err != nil {
output = ""
}
return strings.TrimSpace(output), err
}
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:8,代码来源:docker.go
示例8: DockerCleanupWithEnv
// DockerCleanupWithEnv kills and removes a container on a specified testbed node
// and with specified env-variables
func DockerCleanupWithEnv(t *testing.T, node stu.TestbedNode, contName string, env []string) {
if !OkToCleanup(t.Failed()) {
return
}
cmdStr := fmt.Sprintf("sudo %s docker kill %s", strings.Join(env, " "), contName)
node.RunCommand(cmdStr)
cmdStr = fmt.Sprintf("sudo %s docker rm %s", strings.Join(env, " "), contName)
node.RunCommand(cmdStr)
}
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:11,代码来源:docker.go
示例9: startVolplugin
func startVolplugin(node utils.TestbedNode) error {
log.Infof("Starting the volplugin on %q", node.GetName())
defer time.Sleep(10 * time.Millisecond)
// FIXME this is hardcoded because it's simpler. If we move to
// multimaster or change the monitor subnet, we will have issues.
_, err := node.RunCommandBackground("sudo -E `which volplugin` --debug &>/tmp/volplugin.log &")
return err
}
开发者ID:hankerepo,项目名称:volplugin,代码行数:9,代码来源:util_test.go
示例10: StartServerWithEnvAndArgs
// StartServerWithEnvAndArgs starts a server container with specified env-variables
func StartServerWithEnvAndArgs(t *testing.T, node stu.TestbedNode, contName string,
env, dockerArgs []string) {
cmdStr := "sudo %s docker run -d %s --name=" + contName +
" ubuntu /bin/bash -c \"mkfifo foo && < foo\""
cmdStr = fmt.Sprintf(cmdStr, strings.Join(env, " "),
strings.Join(dockerArgs, " "))
output, err := node.RunCommandWithOutput(cmdStr)
if err != nil {
OvsDumpInfo(node)
t.Fatalf("Error '%s' launching container '%s', Output: \n%s\n",
err, contName, output)
}
}
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:14,代码来源:docker.go
示例11: NetworkStateExists
// NetworkStateExists tests if state for specified network exists
func NetworkStateExists(node stu.TestbedNode, network, stateStore string) error {
cmdStr := "netdcli -oper get -construct network " + network + " 2>&1"
if stateStore != "" {
cmdStr = "netdcli -state-store " + stateStore + "-oper get -construct network " + network + " 2>&1"
}
output, err := node.RunCommandWithOutput(cmdStr)
if err != nil {
return err
}
if string(output) == "" {
return core.Errorf("got null output")
}
return nil
}
开发者ID:syeduguri,项目名称:netplugin,代码行数:16,代码来源:utils.go
示例12: StartClientFailureWithEnvAndArgs
// StartClientFailureWithEnvAndArgs starts a client container with specified env-variables.
// It expects ping to server container to failure
func StartClientFailureWithEnvAndArgs(t *testing.T, node stu.TestbedNode, contName, ipAddress string,
env, dockerArgs []string) {
cmdStr := "sudo %s docker run %s --name=" + contName +
" ubuntu /bin/bash -c \"ping -c5 " + ipAddress + "\""
cmdStr = fmt.Sprintf(cmdStr, strings.Join(env, " "),
strings.Join(dockerArgs, " "))
output, err := node.RunCommandWithOutput(cmdStr)
if err == nil {
t.Fatalf("Ping did not fail as expected, err '%s' container '%s', "+
"Output: \n%s\n", err, contName, output)
}
cmdStr = fmt.Sprintf("sudo docker logs %s", contName)
output, err = node.RunCommandWithOutput(cmdStr)
if err != nil || !strings.Contains(string(output), ", 100% packet loss,") {
t.Fatalf("Ping did not fail as expected, err '%s' container '%s', "+
"Output: \n%s\n", err, contName, output)
}
}
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:21,代码来源:docker.go
示例13: applyConfig
func applyConfig(t *testing.T, cfgType, jsonCfg string, node stu.TestbedNode, stateStore string) {
// replace newlines with space and "(quote) with \"(escaped quote) for
// echo to consume and produce desired json config
jsonCfg = getEchoCompatibleStr(jsonCfg)
cmdStr := fmt.Sprintf("echo \"%s\" > /tmp/netdcli.cfg", jsonCfg)
output, err := node.RunCommandWithOutput(cmdStr)
if err != nil {
t.Fatalf("Error '%s' creating config file\nCmd: %q\n Output : %s \n",
err, cmdStr, output)
}
cmdStr = "netdcli -" + cfgType + " /tmp/netdcli.cfg 2>&1"
if stateStore != "" {
cmdStr = "netdcli -state-store " + stateStore + " -" + cfgType + " /tmp/netdcli.cfg 2>&1"
}
output, err = node.RunCommandWithOutput(cmdStr)
if err != nil {
t.Fatalf("Failed to apply config. Error: %s\nCmd: %q\n Output : %s\n",
err, cmdStr, output)
}
}
开发者ID:syeduguri,项目名称:netplugin,代码行数:20,代码来源:utils.go
示例14: stopVolplugin
func stopVolplugin(node utils.TestbedNode) error {
log.Infof("Stopping the volplugin on %q", node.GetName())
return node.RunCommand("sudo pkill volplugin")
}
开发者ID:hankerepo,项目名称:volplugin,代码行数:4,代码来源:util_test.go
示例15: stopVolmaster
func stopVolmaster(node utils.TestbedNode) error {
log.Infof("Stopping the volmaster on %s", node.GetName())
return node.RunCommand("sudo pkill volmaster")
}
开发者ID:hankerepo,项目名称:volplugin,代码行数:4,代码来源:util_test.go
示例16: startVolsupervisor
func startVolsupervisor(node utils.TestbedNode) error {
log.Infof("Starting the volsupervisor on %s", node.GetName())
_, err := node.RunCommandBackground("sudo -E nohup `which volsupervisor` --debug </dev/null &>/tmp/volsupervisor.log &")
return err
}
开发者ID:hankerepo,项目名称:volplugin,代码行数:5,代码来源:util_test.go
示例17: volpluginStop
func (s *systemtestSuite) volpluginStop(node utils.TestbedNode) error {
log.Infof("Stopping the volplugin on %q", node.GetName())
return node.RunCommand("sudo pkill volplugin")
}
开发者ID:leochencipher,项目名称:volplugin,代码行数:4,代码来源:util_test.go
示例18: volpluginStop
func volpluginStop(node utils.TestbedNode) error {
return node.RunCommand("sudo pkill volplugin")
}
开发者ID:cloudstrack,项目名称:volplugin,代码行数:3,代码来源:init_test.go
示例19: clearContainerHost
func (s *systemtestSuite) clearContainerHost(node utils.TestbedNode) error {
log.Infof("Clearing containers on %q", node.GetName())
node.RunCommand("docker ps -aq | xargs docker rm -f")
return nil
}
开发者ID:hankerepo,项目名称:volplugin,代码行数:5,代码来源:util_test.go
示例20: OvsDumpInfo
// OvsDumpInfo dumps the ovs state on the specified testbed node
func OvsDumpInfo(node stu.TestbedNode) {
cmdStr := "sudo ovs-vsctl show"
output, _ := node.RunCommandWithOutput(cmdStr)
log.Debugf("ovs-vsctl on node %s: \n%s\n", node.GetName(), output)
}
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:6,代码来源:ovs.go
注:本文中的github.com/contiv/systemtests-utils.TestbedNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论