Esempio n. 1
0
func TestOneHostMultipleNets_regress(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	cfgFile := utils.GetCfgFile("one_host_multiple_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]

	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")
	}()

	utils.StartServer(t, node1, "myContainer4")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer4")
	}()
	ipAddress = utils.GetIPAddress(t, node1, "purple-myContainer4", u.EtcdNameStr)
	utils.StartClient(t, node1, "myContainer3", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer3")
	}()
}
Esempio n. 2
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")
	}()
}
Esempio n. 3
0
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")
	}()
}
Esempio n. 4
0
func TestTwoHostVlan_regress(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	cfgFile := utils.GetCfgFile("two_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]
	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")
	}()

}
Esempio n. 5
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")
	}()
}
Esempio n. 6
0
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-myContainer1", u.EtcdNameStr)
	utils.StartClientFailure(t, node2, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer2")
	}()
}
Esempio n. 7
0
// 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")
	}()
}
Esempio n. 8
0
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-myContainer1", u.EtcdNameStr)
	utils.StartClient(t, node2, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer2")
	}()

	ipAddress = utils.GetIPAddress(t, node1, "purple-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")
	}()

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

	utils.DelConfig(t, jsonCfg, testbed.GetNodes()[0])

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

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

	utils.AddConfig(t, jsonCfg, testbed.GetNodes()[0])
	ipAddress = utils.GetIPAddress(t, node1, "purple-myContainer5", u.EtcdNameStr)
	utils.DockerCleanup(t, node2, "myContainer4")
	utils.StartClient(t, node2, "myContainer4", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer4")
	}()
}
Esempio n. 9
0
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-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-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")
	}()
}
Esempio n. 10
0
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-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")
	}()

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

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

	ipAddress = utils.GetIPAddress(t, node1, "green-myContainer5", u.ConsulNameStr)
	utils.StartClient(t, node2, "myContainer6", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node2, "myContainer6")
	}()

	utils.DelConfigConsul(t, jsonCfg, testbed.GetNodes()[0])

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

	jsonCfg = `
	{
	"Tenants" : [ {
		"Name"                      : "tenant-one",
		"Networks"  : [
		{
			"Name"                  : "green"
		}
		]
	} ]
	}`

	utils.DelConfigConsul(t, jsonCfg, testbed.GetNodes()[0])
	time.Sleep(1 * time.Second)
	if utils.NetworkStateExists(node2, "green", u.ConsulNameStr) == nil {
		t.Fatalf("Error - network %s doesn't seem to be deleted \n", "green")
	}
}