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,16 +23,13 @@
#include "scsi-lowlevel.h"
#include "iscsi-support.h"
#include "iscsi-test-cu.h"
#include "iscsi-multipath.h"
void
test_reserve6_2initiators(void)
{
int ret;
struct scsi_device sd2;
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
struct scsi_device *sd2;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test RESERVE6/RELEASE6 across two initiators");
@@ -59,21 +56,16 @@ test_reserve6_2initiators(void)
ret = reserve6(sd);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Create a second connection to the target");
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_NORMAL, "Try to take out a RESERVE6 from the second initiator");
ret = reserve6_conflict(&sd2);
ret = reserve6_conflict(sd2);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "Try to RELEASE from the second initiator. Should be a nop");
ret = release6(&sd2);
ret = release6(sd2);
CU_ASSERT_EQUAL(ret, 0);
@@ -83,12 +75,12 @@ test_reserve6_2initiators(void)
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "MODE SENSE should fail from the second initiator");
ret = modesense6(&sd2, NULL, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
ret = modesense6(sd2, NULL, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_RESERVATION_CONFLICT);
logging(LOG_NORMAL, "RESERVE6 from the second initiator should still fail");
ret = reserve6_conflict(&sd2);
ret = reserve6_conflict(sd2);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "RELEASE6 from the first initiator");
@@ -96,13 +88,12 @@ test_reserve6_2initiators(void)
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
ret = reserve6(&sd2);
ret = reserve6(sd2);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "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);
}

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_itnexus_loss(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 it-nexus loss");
@@ -53,17 +53,11 @@ test_reserve6_itnexus_loss(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_NORMAL, "Try to take out a RESERVE6 from the second initiator");
ret = reserve6_conflict(&sd2);
ret = reserve6_conflict(sd2);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Disconnect from the target.");
@@ -80,14 +74,13 @@ test_reserve6_itnexus_loss(void)
}
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
ret = reserve6(&sd2);
ret = reserve6(sd2);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
ret = release6(&sd2);
ret = release6(sd2);
CU_ASSERT_EQUAL(ret, 0);
finished:
iscsi_logout_sync(sd2.iscsi_ctx);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}

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_logout(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 logout");
@@ -53,17 +53,11 @@ test_reserve6_logout(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_NORMAL, "Try to take out a RESERVE6 from the second initiator");
ret = reserve6_conflict(&sd2);
ret = reserve6_conflict(sd2);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Logout from target");
@@ -78,13 +72,12 @@ test_reserve6_logout(void)
}
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
ret = reserve6(&sd2);
ret = reserve6(sd2);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "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);
}

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_cold_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 cold reset");
@@ -63,23 +63,16 @@ test_reserve6_target_cold_reset(void)
sleep(3);
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);
}

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);
}