コード例 #1
0
func TestDeleteFCoENetwork(t *testing.T) {
	var (
		d           *OVTest
		c           *ov.OVClient
		testName    string
		testFcoeNet ov.FCoENetwork
	)
	if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_fcoe_network")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		err := c.DeleteFCoENetwork(testName)
		assert.NoError(t, err, "DeleteFCoENetwork err-> %s", err)

		testFcoeNet, err = c.GetFCoENetworkByName(testName)
		assert.NoError(t, err, "GetFCoENetworkByName with deleted fcoe network-> %+v", err)
		assert.Equal(t, "", testFcoeNet.Name, fmt.Sprintf("Problem getting fcoe net name, %+v", testFcoeNet))
	} else {
		_, c = getTestDriverU("test_fcoe_network")
		err := c.DeleteFCoENetwork("footest")
		assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, testFcoeNet))
	}

}
コード例 #2
0
func TestGetFCoENetworkByName(t *testing.T) {
	var (
		d        *OVTest
		c        *ov.OVClient
		testName string
	)
	if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_fcoe_network")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		testFcoeNet, err := c.GetFCoENetworkByName(testName)
		assert.NoError(t, err, "GetFCoENetworkByName threw an error --> %s", err)
		assert.Equal(t, testName, testFcoeNet.Name)

		testFcoeNet, err = c.GetFCoENetworkByName("bad")
		assert.NoError(t, err, "GetFCoENetworkByName with fake name --> %s", err)
		assert.Equal(t, "", testFcoeNet.Name)
	} else {

		d, c = getTestDriverU("test_fcoe_network")
		testName = d.Tc.GetTestData(d.Env, "Name").(string)
		data, err := c.GetFCoENetworkByName(testName)

		assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, data))
	}
}
コード例 #3
0
func TestCreateFCoENetwork(t *testing.T) {
	var (
		d        *OVTest
		c        *ov.OVClient
		testName string
	)
	if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_fcoe_network")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		//find out if the test fcoe network already exists
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		testFcoeNet, err := c.GetFCoENetworkByName(testName)
		assert.NoError(t, err, "CreateFCoENetwork get the FCoENetwork error --> %s", err)

		if testFcoeNet.URI.IsNil() {
			testFcoeNet = ov.FCoENetwork{
				Name:   testName,
				VlanId: 143,
				Type:   d.Tc.GetTestData(d.Env, "Type").(string),
			}
			err := c.CreateFCoENetwork(testFcoeNet)
			assert.NoError(t, err, "CreateFCoENetwork error --> %s", err)

			err = c.CreateFCoENetwork(testFcoeNet)
			assert.Error(t, err, "CreateFCoENetwork should error because FCoENetwork already exists, err --> %s ", err)

		} else {
			log.Warnf("The fcoeNetwork already exists, so skipping CreateFCoENetwork test for %s", testName)
		}
		//reload the profile we just created
		testFcoeNet, err = c.GetFCoENetworkByName(testName)
		assert.NoError(t, err, "GetFCoENetworks error --> %s", err)
	}
}