• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang utils.ConfigCleanupCommon函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/contiv/netplugin/systemtests/utils.ConfigCleanupCommon函数的典型用法代码示例。如果您正苦于以下问题:Golang ConfigCleanupCommon函数的具体用法?Golang ConfigCleanupCommon怎么用?Golang ConfigCleanupCommon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ConfigCleanupCommon函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestOneHostVlan_regress

func TestOneHostVlan_regress(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	cfgFile := utils.GetCfgFile("one_host_vlan")
	jsonCfg, err := ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}
	utils.ConfigSetupCommon(t, string(jsonCfg), testbed.GetNodes())

	node1 := testbed.GetNodes()[0]

	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange-myContainer1", u.EtcdNameStr)
	utils.StartClient(t, node1, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer2")
	}()
}
开发者ID:shwethab,项目名称:netplugin,代码行数:26,代码来源:regression_test.go


示例2: TestTwoHostsMultiVlanPingFailure_sanity

func TestTwoHostsMultiVlanPingFailure_sanity(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	jsonCfg :=
		`{
        "Hosts" : [{
            "Name"                      : "host1",
            "Intf"                      : "eth2"
        },
        {
            "Name"                      : "host2",
            "Intf"                      : "eth2"
        }],
        "Tenants" : [ {
            "Name"                      : "tenant-one",
            "DefaultNetType"            : "vlan",
            "SubnetPool"                : "11.1.0.0/16",
            "AllocSubnetLen"            : 24,
            "Vlans"                     : "11-48",
            "Networks"  : [ {
                "Name"                  : "orange",
                "Endpoints" : [
                {
                    "Container"         : "myContainer1",
                    "Host"              : "host1"
                } ]
            },
            {
                "Name"                  : "purple",
                "Endpoints" : [
                {
                    "Container"         : "myContainer2",
                    "Host"              : "host2"
                } ]
            } ]
        } ]
        }`

	utils.ConfigSetupCommon(t, jsonCfg, testbed.GetNodes())

	node1 := testbed.GetNodes()[0]
	node2 := testbed.GetNodes()[1]

	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange.tenant-one-myContainer1", u.EtcdNameStr)
	utils.StartClientFailure(t, node2, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer2")
	}()
}
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:57,代码来源:sanity_test.go


示例3: TestTwoHostsMultipleVxlansNetsInfraContainerBindings_regress

func TestTwoHostsMultipleVxlansNetsInfraContainerBindings_regress(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
	}()

	cfgFile := utils.GetCfgFile("container_bindings/multiple_vxlan_nets")
	jsonCfg, err := ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}
	utils.ConfigSetupCommon(t, string(jsonCfg), testbed.GetNodes())
	node1 := testbed.GetNodes()[0]
	node2 := testbed.GetNodes()[1]

	// Start server containers: Container1 and Container2
	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()
	// Container2 and Container4 are on purple network
	utils.StartServer(t, node1, "myContainer2")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer2")
	}()

	// read host bindings and infra container mappings
	cfgFile = utils.GetCfgFile("container_bindings/multiple_vxlan_nets_host_bindings")
	jsonCfg, err = ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}

	cfgFile = utils.GetCfgFile("container_bindings/multiple_vxlan_nets_infra_container_bindings")
	infraContMappings, err := ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}

	jsonCfgStr, _ := utils.FixUpInfraContainerUUIDs(t, testbed.GetNodes(), string(jsonCfg), string(infraContMappings))
	utils.ApplyHostBindingsConfig(t, jsonCfgStr, node1)

	// start client containers and test ping: myContainer1 and myContainer4
	ipAddress := utils.GetIPAddress(t, node1, "orange-myPod1", u.EtcdNameStr)
	utils.StartClient(t, node2, "myContainer3", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer3")
	}()
	ipAddress = utils.GetIPAddress(t, node1, "purple-myPod2", u.EtcdNameStr)
	utils.StartClient(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()
}
开发者ID:shwethab,项目名称:netplugin,代码行数:53,代码来源:regression_test.go


示例4: TestMultipleEpsInContainer_regress

func TestMultipleEpsInContainer_regress(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	cfgFile := utils.GetCfgFile("multiple_eps_in_container")
	jsonCfg, err := ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}
	utils.ConfigSetupCommon(t, string(jsonCfg), testbed.GetNodes())

	node1 := testbed.GetNodes()[0]
	node2 := testbed.GetNodes()[1]

	// Container2 is reachable on both orange and purple networks
	utils.StartServer(t, node1, "myContainer2")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer2")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange-myContainer2", u.EtcdNameStr)
	utils.StartClient(t, node1, "myContainer3", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer3")
	}()

	ipAddress = utils.GetIPAddress(t, node1, "purple-myContainer2", u.EtcdNameStr)
	utils.StartClient(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()

	// Container1 is reachable on only on orange network
	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	ipAddress = utils.GetIPAddress(t, node1, "orange-myContainer1", u.EtcdNameStr)
	utils.StartClient(t, node2, "myContainer3", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer3")
	}()
	utils.DockerCleanup(t, node2, "myContainer4")
	utils.StartClientFailure(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()
}
开发者ID:shwethab,项目名称:netplugin,代码行数:51,代码来源:regression_test.go


示例5: TestTwoHostVxlan_regress

func TestTwoHostVxlan_regress(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	cfgFile := utils.GetCfgFile("two_host_vxlan")
	jsonCfg, err := ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}
	utils.ConfigSetupCommon(t, string(jsonCfg), testbed.GetNodes())

	node1 := testbed.GetNodes()[0]
	node2 := testbed.GetNodes()[1]

	// all four containers can talk to each other
	utils.StartServer(t, node1, "myContainer2")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer2")
	}()
	utils.StartServer(t, node2, "myContainer4")
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange-myContainer2", u.EtcdNameStr)
	utils.StartClient(t, node2, "myContainer3", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer3")
	}()
	utils.StartClient(t, node1, "myContainer1", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	ipAddress = utils.GetIPAddress(t, node1, "orange-myContainer4", u.EtcdNameStr)
	utils.DockerCleanup(t, node2, "myContainer3")
	utils.StartClient(t, node2, "myContainer3", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer3")
	}()
	utils.DockerCleanup(t, node1, "myContainer1")
	utils.StartClient(t, node1, "myContainer1", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

}
开发者ID:shwethab,项目名称:netplugin,代码行数:49,代码来源:regression_test.go


示例6: TestTwoHostsMultipleVxlansNetsLateHostBindings_regress

func TestTwoHostsMultipleVxlansNetsLateHostBindings_regress(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	cfgFile := utils.GetCfgFile("late_bindings/multiple_vxlan_nets")
	jsonCfg, err := ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}
	utils.ConfigSetupCommon(t, string(jsonCfg), testbed.GetNodes())
	node1 := testbed.GetNodes()[0]
	node2 := testbed.GetNodes()[1]

	cfgFile = utils.GetCfgFile("late_bindings/multiple_vxlan_nets_host_bindings")
	jsonCfg, err = ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}
	utils.ApplyHostBindingsConfig(t, string(jsonCfg), node1)

	// Container1 and Container3 are on orange network
	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange-myContainer1", u.EtcdNameStr)
	utils.StartClient(t, node2, "myContainer3", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer3")
	}()

	// Container2 and Container4 are on purple network
	utils.StartServer(t, node1, "myContainer2")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer2")
	}()

	ipAddress = utils.GetIPAddress(t, node1, "purple-myContainer2", u.EtcdNameStr)
	utils.StartClient(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()
}
开发者ID:shwethab,项目名称:netplugin,代码行数:46,代码来源:regression_test.go


示例7: TestSingleHostSingleVlanPingSuccess_sanity

// Testcase:
// - Create a single vlan network with two endpoints
// - Verify that the endpoints are able to ping
func TestSingleHostSingleVlanPingSuccess_sanity(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	//create a single vlan network, with two endpoints
	jsonCfg :=
		`{
        "Tenants" : [ {
            "Name"                      : "tenant-one",
            "DefaultNetType"            : "vlan",
            "SubnetPool"                : "11.1.0.0/16",
            "AllocSubnetLen"            : 24,
            "Vlans"                     : "11-48",
            "Networks"  : [ {
                "Name"                  : "orange",
                "Endpoints" : [
                {
                    "Container"         : "myContainer1",
                    "Host"              : "host1"
                },
                {
                    "Container"         : "myContainer2",
                    "Host"              : "host1"
                } ]
            } ]
        } ]
        }`

	utils.ConfigSetupCommon(t, jsonCfg, testbed.GetNodes())

	node := testbed.GetNodes()[0]

	utils.StartServer(t, node, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node, "myContainer1")
	}()

	ipAddress := utils.GetIPAddress(t, node, "orange-myContainer1", u.EtcdNameStr)
	utils.StartClient(t, node, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node, "myContainer2")
	}()
}
开发者ID:shwethab,项目名称:netplugin,代码行数:48,代码来源:sanity_test.go


示例8: TestTwoHostVlanPowerstripDocker

// XXX: don't run this until we upgrade docker to a recent version that supports
// labels and build-time env
func TestTwoHostVlanPowerstripDocker(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	cfgFile := utils.GetCfgFile("late_bindings/powerstrip_demo_vlan_nets")
	jsonCfg, err := ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}

	node1 := testbed.GetNodes()[0]
	node2 := testbed.GetNodes()[1]

	utils.StartNetPlugin(t, testbed.GetNodes(), true)

	utils.StartPowerStripAdapter(t, testbed.GetNodes())

	utils.ApplyDesiredConfig(t, string(jsonCfg), node1)

	env := []string{"DOCKER_HOST=localhost:2375"}
	utils.StartServerWithEnvAndArgs(t, node1, "server1", env,
		[]string{"--label", "netid=orange", "--label", "tenantid=tenant-one"})
	defer func() {
		utils.DockerCleanupWithEnv(t, node1, "server1", env)
	}()
	ipAddress := utils.GetIPAddressFromNetworkAndContainerName(t, node1,
		"orange", "server1")

	// test ping success between containers in same network
	utils.StartClientWithEnvAndArgs(t, node2, "client1", ipAddress, env,
		[]string{"--label", "netid=orange", "--label", "tenantid=tenant-one"})
	defer func() {
		utils.DockerCleanupWithEnv(t, node2, "client1", env)
	}()

	// test ping failure between containers in different networks
	utils.StartClientFailureWithEnvAndArgs(t, node2, "client2", ipAddress, env,
		[]string{"--label", "netid=purple", "--label", "tenantid=tenant-one"})
	defer func() {
		utils.DockerCleanupWithEnv(t, node2, "client2", env)
	}()
}
开发者ID:shwethab,项目名称:netplugin,代码行数:46,代码来源:regression_test.go


示例9: TestTwoHostsVxlanAddDelEp_sanity

func TestTwoHostsVxlanAddDelEp_sanity(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	jsonCfg :=
		`{
        "Hosts" : [{
            "Name"                      : "host1",
            "VtepIp"                    : "192.168.2.10"
        },
        {
            "Name"                      : "host2",
            "VtepIp"                    : "192.168.2.11"
        }],
        "Tenants" : [ {
            "Name"                      : "tenant-one",
            "DefaultNetType"            : "vxlan",
            "SubnetPool"                : "11.1.0.0/16",
            "AllocSubnetLen"            : 24,
            "VXlans"                    : "10001-11000",
            "Networks"  : [
            {
                "Name"                  : "orange",
                "Endpoints" : [
                {
                    "Container"         : "myContainer1",
                    "Host"              : "host1"
                },
                {
                    "Container"         : "myContainer2",
                    "Host"              : "host2"
                } ]
            },
            {
                "Name"                  : "purple",
                "Endpoints" : [
                {
                    "Container"         : "myContainer3",
                    "Host"              : "host1"
                },
                {
                    "Container"         : "myContainer4",
                    "Host"              : "host2"
                } ]
            } ]
        } ]
        }`

	utils.ConfigSetupCommon(t, jsonCfg, testbed.GetNodes())

	node1 := testbed.GetNodes()[0]
	node2 := testbed.GetNodes()[1]

	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	utils.StartServer(t, node1, "myContainer3")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer3")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange.tenant-one-myContainer1", u.EtcdNameStr)
	utils.StartClient(t, node2, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer2")
	}()

	ipAddress = utils.GetIPAddress(t, node1, "purple.tenant-one-myContainer3", u.EtcdNameStr)
	utils.StartClient(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()

	jsonCfg = `
	{
	"Tenants" : [ {
		"Name"                      : "tenant-one",
		"Networks"  : [
		{
			"Name"                  : "orange",
			"Endpoints" : [
			{
				"Container"         : "myContainer5",
				"Host"              : "host1"
			}
			]
		}
		]
	} ]
	}`
	utils.AddConfig(t, jsonCfg, testbed.GetNodes()[0])

	utils.StartServer(t, node1, "myContainer5")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer5")
	}()
//.........这里部分代码省略.........
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:101,代码来源:sanity_test.go


示例10: TestTwoHostsMultiVxlanPingFailureStatefulStart_sanity

func TestTwoHostsMultiVxlanPingFailureStatefulStart_sanity(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	//create a single vlan network, with two endpoints
	jsonCfg :=
		`{
        "Hosts" : [{
            "Name"                      : "host1",
            "VtepIp"                    : "192.168.2.10"
        },
        {
            "Name"                      : "host2",
            "VtepIp"                    : "192.168.2.11"
        }],
        "Tenants" : [ {
            "Name"                      : "tenant-one",
            "DefaultNetType"            : "vxlan",
            "SubnetPool"                : "11.1.0.0/16",
            "AllocSubnetLen"            : 24,
            "VXlans"                    : "10001-11000",
            "Networks"  : [
            {
                "Name"                  : "orange",
                "Endpoints" : [
                {
                    "Container"         : "myContainer1",
                    "Host"              : "host1"
                },
                {
                    "Container"         : "myContainer2",
                    "Host"              : "host2"
                } ]
            },
            {
                "Name"                  : "purple",
                "Endpoints" : [
                {
                    "Container"         : "myContainer3",
                    "Host"              : "host1"
                },
                {
                    "Container"         : "myContainer4",
                    "Host"              : "host2"
                } ]
            } ]
        } ]
        }`

	utils.ConfigSetupCommon(t, jsonCfg, testbed.GetNodes())

	node1 := testbed.GetNodes()[0]
	node2 := testbed.GetNodes()[1]

	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange.tenant-one-myContainer1", u.EtcdNameStr)
	utils.StartClientFailure(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()

	utils.StartClientFailure(t, node2, "myContainer3", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer3")
	}()

	// Wait for Netplugin to cleanup
	time.Sleep(1 * time.Second)

	//restart the netplugin and retry the pings
	utils.StopNetPlugin(t, testbed.GetNodes())
	utils.StartNetPlugin(t, testbed.GetNodes(), false)
	utils.DockerCleanup(t, node2, "myContainer3")
	utils.DockerCleanup(t, node2, "myContainer4")

	ipAddress = utils.GetIPAddress(t, node1, "orange.tenant-one-myContainer1", u.EtcdNameStr)
	utils.StartClientFailure(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()

	utils.StartClientFailure(t, node2, "myContainer3", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer3")
	}()
}
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:92,代码来源:sanity_test.go


示例11: TestTwoHostsVxlanAddDelNetworkConsul_sanity

func TestTwoHostsVxlanAddDelNetworkConsul_sanity(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	jsonCfg :=
		`{
        "Hosts" : [{
            "Name"                      : "host1",
            "VtepIp"                    : "192.168.2.10"
        },
        {
            "Name"                      : "host2",
            "VtepIp"                    : "192.168.2.11"
        }],
        "Tenants" : [ {
            "Name"                      : "tenant-one",
            "DefaultNetType"            : "vxlan",
            "SubnetPool"                : "11.1.0.0/16",
            "AllocSubnetLen"            : 24,
            "VXlans"                    : "10001-11000",
            "Networks"  : [
            {
                "Name"                  : "orange",
                "Endpoints" : [
                {
                    "Container"         : "myContainer1",
                    "Host"              : "host1"
                },
                {
                    "Container"         : "myContainer2",
                    "Host"              : "host2"
                } ]
            },
            {
                "Name"                  : "purple",
                "Endpoints" : [
                {
                    "Container"         : "myContainer3",
                    "Host"              : "host1"
                },
                {
                    "Container"         : "myContainer4",
                    "Host"              : "host2"
                } ]
            } ]
        } ]
        }`

	utils.ConfigSetupCommonWithConsul(t, jsonCfg, testbed.GetNodes())

	node1 := testbed.GetNodes()[0]
	node2 := testbed.GetNodes()[1]

	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	utils.StartServer(t, node1, "myContainer3")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer3")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange.tenant-one-myContainer1", u.ConsulNameStr)
	utils.StartClient(t, node2, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer2")
	}()

	ipAddress = utils.GetIPAddress(t, node1, "purple.tenant-one-myContainer3", u.ConsulNameStr)
	utils.StartClient(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()

	jsonCfg = `
	{
	"Tenants" : [ {
		"Name"                      : "tenant-one",
		"Networks"  : [
		{
			"Name"                  : "green",
			"Endpoints" : [
			{
				"Container"         : "myContainer5",
				"Host"              : "host1"
			},
			{
				"Container"         : "myContainer6",
				"Host"              : "host2"
			}
			]
		}
		]
	} ]
	}`
	utils.AddConfigConsul(t, jsonCfg, testbed.GetNodes()[0])

//.........这里部分代码省略.........
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:101,代码来源:sanity_test.go


示例12: TestTwoHostsMultiVxlanPingSuccessStatefulStartConsul_sanity

func TestTwoHostsMultiVxlanPingSuccessStatefulStartConsul_sanity(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	jsonCfg :=
		`{
        "Hosts" : [{
            "Name"                      : "host1",
            "VtepIp"                    : "192.168.2.10"
        },
        {
            "Name"                      : "host2",
            "VtepIp"                    : "192.168.2.11"
        }],
        "Tenants" : [ {
            "Name"                      : "tenant-one",
            "DefaultNetType"            : "vxlan",
            "SubnetPool"                : "11.1.0.0/16",
            "AllocSubnetLen"            : 24,
            "VXlans"                    : "10001-14000",
            "Networks"  : [ 
            {
                "Name"                  : "orange",
                "Endpoints" : [
                {
                    "Container"         : "myContainer1",
                    "Host"              : "host1"
                },
                {
                    "Container"         : "myContainer2",
                    "Host"              : "host2"
                } ]
            },
            {
                "Name"                  : "purple",
                "Endpoints" : [
                {
                    "Container"         : "myContainer3",
                    "Host"              : "host1"
                },
                {
                    "Container"         : "myContainer4",
                    "Host"              : "host2"
                } ]
            } ]
        } ]
        }`

	utils.ConfigSetupCommonWithConsul(t, jsonCfg, testbed.GetNodes())

	node1 := testbed.GetNodes()[0]
	node2 := testbed.GetNodes()[1]

	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	utils.StartServer(t, node1, "myContainer3")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer3")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange-myContainer1", u.ConsulNameStr)
	utils.StartClient(t, node2, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer2")
	}()

	ipAddress = utils.GetIPAddress(t, node1, "purple-myContainer3", u.ConsulNameStr)
	utils.StartClient(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()

	//restart the netplugin and retry the pings
	utils.StopNetPlugin(t, testbed.GetNodes())
	utils.StartNetPluginWithConfig(t, testbed.GetNodes(), false, utils.GetNetpluginConfigWithConsul())
	utils.DockerCleanup(t, node2, "myContainer2")
	utils.DockerCleanup(t, node2, "myContainer4")

	ipAddress = utils.GetIPAddress(t, node1, "orange-myContainer1", u.ConsulNameStr)
	utils.StartClient(t, node2, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer2")
	}()

	ipAddress = utils.GetIPAddress(t, node1, "purple-myContainer3", u.ConsulNameStr)
	utils.StartClient(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()
}
开发者ID:shwethab,项目名称:netplugin,代码行数:95,代码来源:sanity_test.go


示例13: TestSingleHostDefaultNetwork_sanity

// Default Network Assignment and freeing
func TestSingleHostDefaultNetwork_sanity(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	//create a single vlan network, with two endpoints
	jsonCfg :=
		`{
        "Tenants" : [ {
            "Name"                      : "tenant-one",
            "DefaultNetType"            : "vlan",
            "DefaultNetwork"            : "orange",
            "SubnetPool"                : "100.1.0.0/16",
            "AllocSubnetLen"            : 24,
            "Vlans"                     : "11-48",
            "Networks"  : [ {
                "Name"                  : "orange",
                "Endpoints" : [
                {
                    "Container"         : "myContainer1",
                    "Host"              : "host1"
                } ]
            },
            {
                "Name"                  : "purple",
                "Endpoints" : [
                {
                    "Container"         : "myContainer2",
                    "Host"              : "host1"
                } ]
            } ]
        } ]
        }`

	utils.ConfigSetupCommon(t, jsonCfg, testbed.GetNodes())

	node := testbed.GetNodes()[0]

	utils.StartServer(t, node, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node, "myContainer1")
	}()

	ipAddress := utils.GetIPAddress(t, node, "orange.tenant-one-myContainer1", u.EtcdNameStr)
	utils.StartClientFailure(t, node, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node, "myContainer2")
	}()

	// confirm the default gateway in one of the containers
	output, err := node.RunCommandWithOutput("docker exec myContainer1 /sbin/ip route")
	if err != nil {
		t.Fatalf("Error - unable to get default ip route, output = '%s'", output)
	}
	if !strings.Contains(output, "default via 100.1.0.254") {
		t.Fatalf("Error - unable to confirm container's default ip route, output = '%s'", output)
	}

	jsonCfg = `
    {
      "Tenants" : [ {
        "Name"                      : "tenant-one",
        "Networks"  : [ {
          "Name"                    : "orange",
          "Endpoints" : [ {
            "Container"             : "myContainer1",
            "Host"                  : "host1"
          } ]
        } ]
      } ]
    }`

	// deletion would result into unassignment
	utils.DelConfig(t, jsonCfg, testbed.GetNodes()[0])
	time.Sleep(1 * time.Second)

	// confirm the default gateway in one of the containers
	output, err = node.RunCommandWithOutput("docker exec myContainer1 /sbin/ip route")
	if err != nil {
		t.Fatalf("Error - unable to get default ip route, output = '%s'", output)
	}
	if strings.Contains(output, "default via 100.1.0.254") {
		t.Fatalf("Error - able to still find the default rout after network is deleted output = '%s'", output)
	}

}
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:88,代码来源:sanity_test.go



注:本文中的github.com/contiv/netplugin/systemtests/utils.ConfigCleanupCommon函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang utils.ConfigSetupCommon函数代码示例发布时间:2022-05-23
下一篇:
Golang plugin.NetPlugin类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap