test/prout: use multipath session if available

These 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:47:21 +02:00
parent 89c1749ae7
commit 638d58dd57
2 changed files with 74 additions and 134 deletions

View File

@@ -22,7 +22,7 @@
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-test-cu.h"
#include "iscsi-multipath.h"
static void
verify_persistent_reserve_access(struct scsi_device *sd1, struct scsi_device *sd2,
@@ -122,7 +122,8 @@ verify_persistent_reserve_access(struct scsi_device *sd1, struct scsi_device *sd
void
test_prout_reserve_access_ea(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -132,24 +133,19 @@ test_prout_reserve_access_ea(void)
return;
}
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;
}
verify_persistent_reserve_access(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_access(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS,
0, 0, 0, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}
void
test_prout_reserve_access_we(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -159,24 +155,19 @@ test_prout_reserve_access_we(void)
return;
}
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;
}
verify_persistent_reserve_access(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_access(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE,
1, 0, 1, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}
void
test_prout_reserve_access_earo(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -186,24 +177,19 @@ test_prout_reserve_access_earo(void)
return;
}
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;
}
verify_persistent_reserve_access(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_access(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY,
1, 1, 0, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}
void
test_prout_reserve_access_wero(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -213,24 +199,19 @@ test_prout_reserve_access_wero(void)
return;
}
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;
}
verify_persistent_reserve_access(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_access(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY,
1, 1, 1, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}
void
test_prout_reserve_access_eaar(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -240,24 +221,19 @@ test_prout_reserve_access_eaar(void)
return;
}
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;
}
verify_persistent_reserve_access(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_access(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS,
1, 1, 0, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}
void
test_prout_reserve_access_wear(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -267,16 +243,10 @@ test_prout_reserve_access_wear(void)
return;
}
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;
}
verify_persistent_reserve_access(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_access(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS,
1, 1, 1, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}

View File

@@ -22,7 +22,7 @@
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-test-cu.h"
#include "iscsi-multipath.h"
static void
verify_persistent_reserve_ownership(struct scsi_device *sd1, struct scsi_device *sd2,
@@ -96,7 +96,8 @@ verify_persistent_reserve_ownership(struct scsi_device *sd1, struct scsi_device
void
test_prout_reserve_ownership_ea(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -106,23 +107,18 @@ test_prout_reserve_ownership_ea(void)
return;
}
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;
}
verify_persistent_reserve_ownership(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_ownership(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}
void
test_prout_reserve_ownership_we(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -132,23 +128,18 @@ test_prout_reserve_ownership_we(void)
return;
}
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;
}
verify_persistent_reserve_ownership(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_ownership(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}
void
test_prout_reserve_ownership_earo(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -158,23 +149,18 @@ test_prout_reserve_ownership_earo(void)
return;
}
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;
}
verify_persistent_reserve_ownership(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_ownership(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}
void
test_prout_reserve_ownership_wero(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -184,23 +170,18 @@ test_prout_reserve_ownership_wero(void)
return;
}
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;
}
verify_persistent_reserve_ownership(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_ownership(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}
void
test_prout_reserve_ownership_eaar(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -210,23 +191,18 @@ test_prout_reserve_ownership_eaar(void)
return;
}
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;
}
verify_persistent_reserve_ownership(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_ownership(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS, 1);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}
void
test_prout_reserve_ownership_wear(void)
{
struct scsi_device sd2;
struct scsi_device *sd2;
int ret;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
@@ -236,15 +212,9 @@ test_prout_reserve_ownership_wear(void)
return;
}
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;
}
verify_persistent_reserve_ownership(sd, &sd2,
ret = mpath_sd2_get_or_clone(sd, &sd2);
CU_ASSERT_EQUAL(ret, 0);
verify_persistent_reserve_ownership(sd, sd2,
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS, 1);
iscsi_destroy_context(sd2.iscsi_ctx);
mpath_sd2_put(sd2);
}