test/reserve6: use multipath session if available

Many tests currently reconnect to the base sd for multi-initiator
testing. Use the secondary multipath device instead, if available.

Signed-off-by: David Disseldorp <ddiss@suse.de>
This commit is contained in:
David Disseldorp
2015-09-21 15:40:18 +02:00
parent 0cfc593bbd
commit 89c1749ae7
5 changed files with 41 additions and 79 deletions

View File

@@ -23,13 +23,13 @@
#include "scsi-lowlevel.h"
#include "iscsi-support.h"
#include "iscsi-test-cu.h"
#include "iscsi-multipath.h"
void
test_reserve6_target_warm_reset(void)
{
int ret;
struct scsi_device sd2;
struct scsi_device *sd2;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that RESERVE6 is released on target warm reset");
@@ -64,24 +64,16 @@ test_reserve6_target_warm_reset(void)
logging(LOG_VERBOSE, "Create a second connection to the target");
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun);
if (sd2.iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target");
return;
}
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
ret = reserve6(&sd2);
ret = reserve6(sd2);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
ret = release6(&sd2);
ret = release6(sd2);
CU_ASSERT_EQUAL(ret, 0);
iscsi_logout_sync(sd2.iscsi_ctx);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}