本文整理汇总了Golang中github.com/contiv/netplugin/netmaster/mastercfg.CfgEndpointState.Write方法的典型用法代码示例。如果您正苦于以下问题:Golang CfgEndpointState.Write方法的具体用法?Golang CfgEndpointState.Write怎么用?Golang CfgEndpointState.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/contiv/netplugin/netmaster/mastercfg.CfgEndpointState
的用法示例。
在下文中一共展示了CfgEndpointState.Write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestOvsDriverCreateEndpointStatefulStateMismatch
func TestOvsDriverCreateEndpointStatefulStateMismatch(t *testing.T) {
driver := initOvsDriver(t)
defer func() { driver.Deinit() }()
id := createEpIDStatefulMismatch
// create network
err := driver.CreateNetwork(testOvsNwID)
if err != nil {
t.Fatalf("network creation failed. Error: %s", err)
}
defer func() { driver.DeleteNetwork(testOvsNwID, "", "", testPktTag, testExtPktTag, testGateway, testTenant) }()
// create second network
err = driver.CreateNetwork(testOvsNwIDStateful)
if err != nil {
t.Fatalf("network creation failed. Error: %s", err)
}
defer func() {
driver.DeleteNetwork(testOvsNwIDStateful, "", "", testPktTagStateful, testExtPktTag, testGateway, testTenant)
}()
// create endpoint
err = driver.CreateEndpoint(id)
if err != nil {
t.Fatalf("endpoint creation failed. Error: %s", err)
}
cfgEp := mastercfg.CfgEndpointState{}
cfgEp.StateDriver = driver.oper.StateDriver
err = cfgEp.Read(id)
if err != nil {
t.Fatalf("failed to read ep config. Error: %s", err)
}
cfgEp.NetID = testOvsNwIDStateful
err = cfgEp.Write()
if err != nil {
t.Fatalf("failed to write ep config. Error: %s", err)
}
err = driver.CreateEndpoint(id)
if err != nil {
t.Fatalf("stateful endpoint creation failed. Error: %s", err)
}
defer func() { driver.DeleteEndpoint(id) }()
output, err := exec.Command("ovs-vsctl", "list", "Port").CombinedOutput()
expectedPortName := fmt.Sprintf("port%d", driver.oper.CurrPortNum)
if err != nil || !strings.Contains(string(output), expectedPortName) {
t.Fatalf("port lookup failed. Error: %s expected port: %s Output: %s",
err, expectedPortName, output)
}
output, err = exec.Command("ovs-vsctl", "list", "Interface").CombinedOutput()
if err != nil || !strings.Contains(string(output), expectedPortName) {
t.Fatalf("interface lookup failed. Error: %s expected port: %s Output: %s",
err, expectedPortName, output)
}
}