tests: Add createVHBAByStoragePool-by-parent to fchosttest

Add a new test to fchosttest in order to test creation of our vHBA
via the Storage Pool logic.  Unlike the real code, we cannot yet use
the virVHBA* API's because they (currently) traverse the file system
in order to get the parent vport capable scsi_host. Besides there's
no "real" NPIV device here - so we have to take some liberties, at
least for now.

Instead, we'll follow the node device tests partially in order to
create and destroy the vHBA with the test node devices.

Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
John Ferlan
2017-03-10 14:57:38 -05:00
parent e915942b05
commit 0623945c40
2 changed files with 156 additions and 1 deletions
+64
View File
@@ -75,6 +75,19 @@ static const char test10_xml[] =
" </capability>"
"</device>";
/* virStoragePoolCreateXML using parent='%s' to find the vport capable HBA */
static const char test11_xml[] =
"<pool type='scsi'>"
" <name>vhba_pool</name>"
" <source>"
" <adapter type='fc_host' parent='scsi_host1' wwnn='20000000c9831b4b' wwpn='10000000c9831b4b'/>"
" </source>"
" <target>"
" <path>/dev/disk/by-path</path>"
" </target>"
"</pool>";
/* Test virIsVHBACapable */
static int
test1(const void *data ATTRIBUTE_UNUSED)
@@ -275,6 +288,54 @@ manageVHBAByNodeDevice(const void *data)
}
/* Test manageVHBAByStoragePool
* - Test both virStoragePoolCreateXML and virStoragePoolDestroy
* - Create a storage pool vHBA allowing usage of various different
* methods based on the input data/xml argument.
* - Be sure that it's possible to destroy the storage pool as well.
*/
static int
manageVHBAByStoragePool(const void *data)
{
const char *expect_hostname = "scsi_host12";
virConnectPtr conn = NULL;
virStoragePoolPtr pool = NULL;
virNodeDevicePtr dev = NULL;
int ret = -1;
const char *vhba = data;
if (!(conn = virConnectOpen("test:///default")))
return -1;
if (!(pool = virStoragePoolCreateXML(conn, vhba, 0)))
goto cleanup;
if (!(dev = virNodeDeviceLookupByName(conn, expect_hostname))) {
VIR_DEBUG("Failed to find expected_hostname '%s'", expect_hostname);
ignore_value(virStoragePoolDestroy(pool));
goto cleanup;
}
if (virStoragePoolDestroy(pool) < 0)
goto cleanup;
if ((dev = virNodeDeviceLookupByName(conn, expect_hostname))) {
VIR_DEBUG("Found expected_hostname '%s' after destroy",
expect_hostname);
goto cleanup;
}
ret = 0;
cleanup:
if (pool)
virStoragePoolFree(pool);
if (conn)
virConnectClose(conn);
return ret;
}
static int
mymain(void)
{
@@ -310,6 +371,9 @@ mymain(void)
if (virTestRun("manageVHBAByNodeDevice-parent-fabric-wwn",
manageVHBAByNodeDevice, test10_xml) < 0)
ret = -1;
if (virTestRun("manageVHBAByStoragePool-by-parent", manageVHBAByStoragePool,
test11_xml) < 0)
ret = -1;
cleanup:
VIR_FREE(fchost_prefix);