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:
@@ -23,16 +23,13 @@
|
|||||||
#include "scsi-lowlevel.h"
|
#include "scsi-lowlevel.h"
|
||||||
#include "iscsi-support.h"
|
#include "iscsi-support.h"
|
||||||
#include "iscsi-test-cu.h"
|
#include "iscsi-test-cu.h"
|
||||||
|
#include "iscsi-multipath.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
test_reserve6_2initiators(void)
|
test_reserve6_2initiators(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct scsi_device sd2;
|
struct scsi_device *sd2;
|
||||||
memset(&sd2, 0, sizeof(sd2));
|
|
||||||
sd2.iscsi_url = sd->iscsi_url;
|
|
||||||
sd2.iscsi_lun = sd->iscsi_lun;
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test RESERVE6/RELEASE6 across two initiators");
|
logging(LOG_VERBOSE, "Test RESERVE6/RELEASE6 across two initiators");
|
||||||
@@ -59,21 +56,16 @@ test_reserve6_2initiators(void)
|
|||||||
ret = reserve6(sd);
|
ret = reserve6(sd);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
ret = mpath_sd2_get_or_clone(sd, &sd2);
|
||||||
logging(LOG_VERBOSE, "Create a second connection to the target");
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator");
|
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);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Try to RELEASE from the second initiator. Should be a nop");
|
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);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
|
||||||
@@ -83,12 +75,12 @@ test_reserve6_2initiators(void)
|
|||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_NORMAL, "MODE SENSE should fail from the second initiator");
|
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);
|
EXPECT_RESERVATION_CONFLICT);
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RESERVE6 from the second initiator should still fail");
|
logging(LOG_NORMAL, "RESERVE6 from the second initiator should still fail");
|
||||||
ret = reserve6_conflict(&sd2);
|
ret = reserve6_conflict(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RELEASE6 from the first initiator");
|
logging(LOG_NORMAL, "RELEASE6 from the first initiator");
|
||||||
@@ -96,13 +88,12 @@ test_reserve6_2initiators(void)
|
|||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
|
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(&sd2);
|
ret = reserve6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
||||||
ret = release6(&sd2);
|
ret = release6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
iscsi_logout_sync(sd2.iscsi_ctx);
|
mpath_sd2_put(sd2);
|
||||||
iscsi_destroy_context(sd2.iscsi_ctx);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,13 @@
|
|||||||
#include "scsi-lowlevel.h"
|
#include "scsi-lowlevel.h"
|
||||||
#include "iscsi-support.h"
|
#include "iscsi-support.h"
|
||||||
#include "iscsi-test-cu.h"
|
#include "iscsi-test-cu.h"
|
||||||
|
#include "iscsi-multipath.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
test_reserve6_itnexus_loss(void)
|
test_reserve6_itnexus_loss(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct scsi_device sd2;
|
struct scsi_device *sd2;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test that RESERVE6 is released on it-nexus loss");
|
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");
|
logging(LOG_VERBOSE, "Create a second connection to the target");
|
||||||
memset(&sd2, 0, sizeof(sd2));
|
ret = mpath_sd2_get_or_clone(sd, &sd2);
|
||||||
sd2.iscsi_url = sd->iscsi_url;
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator");
|
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);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Disconnect from the target.");
|
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");
|
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(&sd2);
|
ret = reserve6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
||||||
ret = release6(&sd2);
|
ret = release6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
finished:
|
finished:
|
||||||
iscsi_logout_sync(sd2.iscsi_ctx);
|
mpath_sd2_put(sd2);
|
||||||
iscsi_destroy_context(sd2.iscsi_ctx);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,13 @@
|
|||||||
#include "scsi-lowlevel.h"
|
#include "scsi-lowlevel.h"
|
||||||
#include "iscsi-support.h"
|
#include "iscsi-support.h"
|
||||||
#include "iscsi-test-cu.h"
|
#include "iscsi-test-cu.h"
|
||||||
|
#include "iscsi-multipath.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
test_reserve6_logout(void)
|
test_reserve6_logout(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct scsi_device sd2;
|
struct scsi_device *sd2;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test that RESERVE6 is released on logout");
|
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");
|
logging(LOG_VERBOSE, "Create a second connection to the target");
|
||||||
memset(&sd2, 0, sizeof(sd2));
|
ret = mpath_sd2_get_or_clone(sd, &sd2);
|
||||||
sd2.iscsi_url = sd->iscsi_url;
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator");
|
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);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Logout from target");
|
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");
|
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(&sd2);
|
ret = reserve6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
||||||
ret = release6(&sd2);
|
ret = release6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
iscsi_logout_sync(sd2.iscsi_ctx);
|
mpath_sd2_put(sd2);
|
||||||
iscsi_destroy_context(sd2.iscsi_ctx);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,13 @@
|
|||||||
#include "scsi-lowlevel.h"
|
#include "scsi-lowlevel.h"
|
||||||
#include "iscsi-support.h"
|
#include "iscsi-support.h"
|
||||||
#include "iscsi-test-cu.h"
|
#include "iscsi-test-cu.h"
|
||||||
|
#include "iscsi-multipath.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
test_reserve6_target_cold_reset(void)
|
test_reserve6_target_cold_reset(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct scsi_device sd2;
|
struct scsi_device *sd2;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test that RESERVE6 is released on target cold reset");
|
logging(LOG_VERBOSE, "Test that RESERVE6 is released on target cold reset");
|
||||||
@@ -63,23 +63,16 @@ test_reserve6_target_cold_reset(void)
|
|||||||
sleep(3);
|
sleep(3);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Create a second connection to the target");
|
logging(LOG_VERBOSE, "Create a second connection to the target");
|
||||||
memset(&sd2, 0, sizeof(sd2));
|
ret = mpath_sd2_get_or_clone(sd, &sd2);
|
||||||
sd2.iscsi_url = sd->iscsi_url;
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
|
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(&sd2);
|
ret = reserve6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
|
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
|
||||||
ret = release6(&sd2);
|
ret = release6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
iscsi_logout_sync(sd2.iscsi_ctx);
|
mpath_sd2_put(sd2);
|
||||||
iscsi_destroy_context(sd2.iscsi_ctx);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,13 @@
|
|||||||
#include "scsi-lowlevel.h"
|
#include "scsi-lowlevel.h"
|
||||||
#include "iscsi-support.h"
|
#include "iscsi-support.h"
|
||||||
#include "iscsi-test-cu.h"
|
#include "iscsi-test-cu.h"
|
||||||
|
#include "iscsi-multipath.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
test_reserve6_target_warm_reset(void)
|
test_reserve6_target_warm_reset(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct scsi_device sd2;
|
struct scsi_device *sd2;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test that RESERVE6 is released on target warm reset");
|
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");
|
logging(LOG_VERBOSE, "Create a second connection to the target");
|
||||||
memset(&sd2, 0, sizeof(sd2));
|
ret = mpath_sd2_get_or_clone(sd, &sd2);
|
||||||
sd2.iscsi_url = sd->iscsi_url;
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
|
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(&sd2);
|
ret = reserve6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
|
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
|
||||||
ret = release6(&sd2);
|
ret = release6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
iscsi_logout_sync(sd2.iscsi_ctx);
|
mpath_sd2_put(sd2);
|
||||||
iscsi_destroy_context(sd2.iscsi_ctx);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user