コード例 #1
0
ファイル: layer3_test.go プロジェクト: RomainVabre/origin
func TestAll(t *testing.T) {
	base.Setup(t)
	defer base.Teardown()

	testRouter(t)
	testFloatingIP(t)
}
コード例 #2
0
ファイル: rule_test.go プロジェクト: RomainVabre/origin
func TestFirewallRules(t *testing.T) {
	base.Setup(t)
	defer base.Teardown()

	ruleID := createRule(t, &rules.CreateOpts{
		Name:                 "gophercloud_test",
		Description:          "acceptance test",
		Protocol:             "tcp",
		Action:               "allow",
		DestinationIPAddress: "192.168.0.0/24",
		DestinationPort:      "22",
	})

	listRules(t)

	destinationIPAddress := "192.168.1.0/24"
	destinationPort := ""
	sourcePort := "1234"

	updateRule(t, ruleID, &rules.UpdateOpts{
		DestinationIPAddress: &destinationIPAddress,
		DestinationPort:      &destinationPort,
		SourcePort:           &sourcePort,
	})

	getRule(t, ruleID)

	deleteRule(t, ruleID)
}
コード例 #3
0
ファイル: pool_test.go プロジェクト: RomainVabre/origin
func TestPools(t *testing.T) {
	base.Setup(t)
	defer base.Teardown()

	// setup
	networkID, subnetID := SetupTopology(t)

	// create pool
	poolID := CreatePool(t, subnetID)

	// list pools
	listPools(t)

	// update pool
	updatePool(t, poolID)

	// get pool
	getPool(t, poolID)

	// create monitor
	monitorID := CreateMonitor(t)

	// associate health monitor
	associateMonitor(t, poolID, monitorID)

	// disassociate health monitor
	disassociateMonitor(t, poolID, monitorID)

	// delete pool
	DeletePool(t, poolID)

	// teardown
	DeleteTopology(t, networkID)
}
コード例 #4
0
ファイル: member_test.go プロジェクト: RomainVabre/origin
func TestMembers(t *testing.T) {
	base.Setup(t)
	defer base.Teardown()

	// setup
	networkID, subnetID := SetupTopology(t)
	poolID := CreatePool(t, subnetID)

	// create member
	memberID := createMember(t, poolID)

	// list members
	listMembers(t)

	// update member
	updateMember(t, memberID)

	// get member
	getMember(t, memberID)

	// delete member
	deleteMember(t, memberID)

	// teardown
	DeletePool(t, poolID)
	DeleteTopology(t, networkID)
}
コード例 #5
0
ファイル: provider_test.go プロジェクト: RomainVabre/origin
func TestNetworkCRUDOperations(t *testing.T) {
	base.Setup(t)
	defer base.Teardown()

	// Create a network
	n, err := networks.Create(base.Client, networks.CreateOpts{Name: "sample_network", AdminStateUp: networks.Up}).Extract()
	th.AssertNoErr(t, err)
	th.AssertEquals(t, n.Name, "sample_network")
	th.AssertEquals(t, n.AdminStateUp, true)
	networkID := n.ID

	// List networks
	pager := networks.List(base.Client, networks.ListOpts{Limit: 2})
	err = pager.EachPage(func(page pagination.Page) (bool, error) {
		t.Logf("--- Page ---")

		networkList, err := networks.ExtractNetworks(page)
		th.AssertNoErr(t, err)

		for _, n := range networkList {
			t.Logf("Network: ID [%s] Name [%s] Status [%s] Is shared? [%s]",
				n.ID, n.Name, n.Status, strconv.FormatBool(n.Shared))
		}

		return true, nil
	})
	th.CheckNoErr(t, err)

	// Get a network
	if networkID == "" {
		t.Fatalf("In order to retrieve a network, the NetworkID must be set")
	}
	n, err = networks.Get(base.Client, networkID).Extract()
	th.AssertNoErr(t, err)
	th.AssertEquals(t, n.Status, "ACTIVE")
	th.AssertDeepEquals(t, n.Subnets, []string{})
	th.AssertEquals(t, n.Name, "sample_network")
	th.AssertEquals(t, n.AdminStateUp, true)
	th.AssertEquals(t, n.Shared, false)
	th.AssertEquals(t, n.ID, networkID)

	// Update network
	n, err = networks.Update(base.Client, networkID, networks.UpdateOpts{Name: "new_network_name"}).Extract()
	th.AssertNoErr(t, err)
	th.AssertEquals(t, n.Name, "new_network_name")

	// Delete network
	res := networks.Delete(base.Client, networkID)
	th.AssertNoErr(t, res.Err)
}
コード例 #6
0
func TestPortBinding(t *testing.T) {
	base.Setup(t)
	defer base.Teardown()

	// Setup network
	t.Log("Setting up network")
	networkID, err := createNetwork()
	th.AssertNoErr(t, err)
	defer networks.Delete(base.Client, networkID)

	// Setup subnet
	t.Logf("Setting up subnet on network %s", networkID)
	subnetID, err := createSubnet(networkID)
	th.AssertNoErr(t, err)
	defer subnets.Delete(base.Client, subnetID)

	// Create port
	t.Logf("Create port based on subnet %s", subnetID)
	hostID := "localhost"
	portID := createPort(t, networkID, subnetID, hostID)

	// Get port
	if portID == "" {
		t.Fatalf("In order to retrieve a port, the portID must be set")
	}
	p, err := portsbinding.Get(base.Client, portID).Extract()
	th.AssertNoErr(t, err)
	th.AssertEquals(t, p.ID, portID)
	th.AssertEquals(t, p.HostID, hostID)

	// Update port
	newHostID := "openstack"
	updateOpts := portsbinding.UpdateOpts{
		HostID: newHostID,
	}
	p, err = portsbinding.Update(base.Client, portID, updateOpts).Extract()

	th.AssertNoErr(t, err)
	th.AssertEquals(t, p.HostID, newHostID)

	// List ports
	t.Logf("Listing all ports")
	listPorts(t)

	// Delete port
	res := ports.Delete(base.Client, portID)
	th.AssertNoErr(t, res.Err)
}
コード例 #7
0
ファイル: monitor_test.go プロジェクト: RomainVabre/origin
func TestMonitors(t *testing.T) {
	base.Setup(t)
	defer base.Teardown()

	// create monitor
	monitorID := CreateMonitor(t)

	// list monitors
	listMonitors(t)

	// update monitor
	updateMonitor(t, monitorID)

	// get monitor
	getMonitor(t, monitorID)

	// delete monitor
	deleteMonitor(t, monitorID)
}
コード例 #8
0
ファイル: firewall_test.go プロジェクト: RomainVabre/origin
func firewallTeardown(t *testing.T, policyID string) {
	defer base.Teardown()
	deletePolicy(t, policyID)
}
コード例 #9
0
func TestLoadbalancers(t *testing.T) {
	base.Setup(t)
	defer base.Teardown()

	// setup network topology
	networkID, subnetID := setupTopology(t)

	// create Loadbalancer
	loadbalancerID := createLoadbalancer(t, subnetID)

	// list Loadbalancers
	listLoadbalancers(t)

	// get Loadbalancer and wait until ACTIVE
	getLoadbalancerWaitActive(t, loadbalancerID)

	// update Loadbalancer
	updateLoadbalancer(t, loadbalancerID)

	// get Loadbalancer and wait until ACTIVE
	getLoadbalancerWaitActive(t, loadbalancerID)

	// create listener
	listenerID := createListener(t, listeners.ProtocolHTTP, 80, loadbalancerID)

	// list listeners
	listListeners(t)

	// get Loadbalancer and wait until ACTIVE
	getLoadbalancerWaitActive(t, loadbalancerID)

	// update listener
	updateListener(t, listenerID)

	// get listener
	getListener(t, listenerID)

	// get Loadbalancer and wait until ACTIVE
	getLoadbalancerWaitActive(t, loadbalancerID)

	// create pool
	poolID := createPool(t, pools.ProtocolHTTP, listenerID, pools.LBMethodRoundRobin)

	// list pools
	listPools(t)

	// get Loadbalancer and wait until ACTIVE
	getLoadbalancerWaitActive(t, loadbalancerID)

	// update pool
	updatePool(t, poolID)

	// get pool
	getPool(t, poolID)

	// get Loadbalancer and wait until ACTIVE
	getLoadbalancerWaitActive(t, loadbalancerID)

	// create member
	memberID := createMember(t, subnetID, poolID, "1.2.3.4", 80, 5)

	// list members
	listMembers(t, poolID)

	// get Loadbalancer and wait until ACTIVE
	getLoadbalancerWaitActive(t, loadbalancerID)

	// update member
	updateMember(t, poolID, memberID)

	// get member
	getMember(t, poolID, memberID)

	// get Loadbalancer and wait until ACTIVE
	getLoadbalancerWaitActive(t, loadbalancerID)

	// create monitor
	monitorID := createMonitor(t, poolID, monitors.TypePING, 10, 10, 3)

	// list monitors
	listMonitors(t)

	// get Loadbalancer and wait until ACTIVE
	getLoadbalancerWaitActive(t, loadbalancerID)

	// update monitor
	updateMonitor(t, monitorID)

	// get monitor
	getMonitor(t, monitorID)

	// get loadbalancer statuses tree
	rawStatusTree, err := loadbalancers.GetStatuses(base.Client, loadbalancerID).ExtractStatuses()
	if err == nil {
		// verify statuses tree ID's of relevant objects
		if rawStatusTree.Loadbalancer.ID != loadbalancerID {
			t.Errorf("Loadbalancer ID did not match")
		}
		if rawStatusTree.Loadbalancer.Listeners[0].ID != listenerID {
			t.Errorf("Listner ID did not match")
		}
		if rawStatusTree.Loadbalancer.Listeners[0].Pools[0].ID != poolID {
			t.Errorf("Pool ID did not match")
		}
		if rawStatusTree.Loadbalancer.Listeners[0].Pools[0].Members[0].ID != memberID {
			t.Errorf("Member ID did not match")
		}
		if rawStatusTree.Loadbalancer.Listeners[0].Pools[0].Monitor.ID != monitorID {
			t.Errorf("Monitor ID did not match")
		}
	} else {
		t.Errorf("Failed to extract Loadbalancer statuses tree: %v", err)
	}

	getLoadbalancerWaitActive(t, loadbalancerID)
	deleteMonitor(t, monitorID)
	getLoadbalancerWaitActive(t, loadbalancerID)
	deleteMember(t, poolID, memberID)
	getLoadbalancerWaitActive(t, loadbalancerID)
	deletePool(t, poolID)
	getLoadbalancerWaitActive(t, loadbalancerID)
	deleteListener(t, listenerID)
	getLoadbalancerWaitActive(t, loadbalancerID)
	deleteLoadbalancer(t, loadbalancerID)
	getLoadbalancerWaitDeleted(t, loadbalancerID)
	deleteTopology(t, networkID)
}
コード例 #10
0
ファイル: policy_test.go プロジェクト: RomainVabre/origin
func firewallPolicyTeardown(t *testing.T, ruleID string) {
	defer base.Teardown()
	deleteRule(t, ruleID)
}