コード例 #1
0
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")
	}()
}
コード例 #2
0
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")
	}()
}