diff options
Diffstat (limited to 'src/spdk/test/iscsi_tgt/calsoft')
-rw-r--r-- | src/spdk/test/iscsi_tgt/calsoft/auth.conf | 3 | ||||
-rwxr-xr-x | src/spdk/test/iscsi_tgt/calsoft/calsoft.py | 115 | ||||
-rwxr-xr-x | src/spdk/test/iscsi_tgt/calsoft/calsoft.sh | 71 | ||||
-rw-r--r-- | src/spdk/test/iscsi_tgt/calsoft/iscsi.json | 17 | ||||
-rw-r--r-- | src/spdk/test/iscsi_tgt/calsoft/its.conf | 7 |
5 files changed, 213 insertions, 0 deletions
diff --git a/src/spdk/test/iscsi_tgt/calsoft/auth.conf b/src/spdk/test/iscsi_tgt/calsoft/auth.conf new file mode 100644 index 00000000..303bac31 --- /dev/null +++ b/src/spdk/test/iscsi_tgt/calsoft/auth.conf @@ -0,0 +1,3 @@ +[AuthGroup1] + Comment "Auth Group1" + Auth "root" "tester" diff --git a/src/spdk/test/iscsi_tgt/calsoft/calsoft.py b/src/spdk/test/iscsi_tgt/calsoft/calsoft.py new file mode 100755 index 00000000..2970328e --- /dev/null +++ b/src/spdk/test/iscsi_tgt/calsoft/calsoft.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 + +import os +import time +import sys +import subprocess +import threading +import json + +CALSOFT_BIN_PATH = "/usr/local/calsoft/iscsi-pcts-v1.5/bin" + +''' +11/26/2015 disable tc_login_11_2 and tc_login_11_4 +RFC 7143 6.3 +Neither the initiator nor the target should attempt to declare or +negotiate a parameter more than once during login, except for +responses to specific keys that explicitly allow repeated key +declarations (e.g., TargetAddress) + +The spec didn't make it clear what other keys could be re-declare +Disscussed this with UNH and get the conclusion that TargetName/ +TargetAddress/MaxRecvDataSegmentLength could be re-declare. +''' +''' +12/1/2015 add tc_login_2_2 to known_failed_cases +RFC 7143 6.1 +A standard-label MUST begin with a capital letter and must not exceed +63 characters. +key name: A standard-label +''' +known_failed_cases = ['tc_ffp_15_2', 'tc_ffp_29_2', 'tc_ffp_29_3', 'tc_ffp_29_4', + 'tc_err_1_1', 'tc_err_1_2', 'tc_err_2_8', + 'tc_err_3_1', 'tc_err_3_2', 'tc_err_3_3', + 'tc_err_3_4', 'tc_err_5_1', 'tc_login_3_1', + 'tc_login_11_2', 'tc_login_11_4', 'tc_login_2_2'] + + +def run_case(case, result_list, log_dir_path): + try: + case_log = subprocess.check_output("{}/{}".format(CALSOFT_BIN_PATH, case), stderr=subprocess.STDOUT, shell=True) + except subprocess.CalledProcessError as e: + result_list.append({"Name": case, "Result": "FAIL"}) + case_log = e.output + else: + result_list.append({"Name": case, "Result": "PASS"}) + with open(log_dir_path + case + '.txt', 'w') as f: + f.write(case_log) + + +def main(): + if not os.path.exists(CALSOFT_BIN_PATH): + print("The Calsoft test suite is not available on this machine.") + sys.exit(1) + + output_dir = sys.argv[1] + if len(sys.argv) > 2: + output_file = sys.argv[2] + else: + output_file = "%s/calsoft.json" % (output_dir) + + log_dir = "%s/calsoft/" % output_dir + + all_cases = [x for x in os.listdir(CALSOFT_BIN_PATH) if x.startswith('tc')] + all_cases.sort() + + case_result_list = [] + + result = {"Calsoft iSCSI tests": case_result_list} + + if not os.path.exists(log_dir): + os.mkdir(log_dir) + for case in known_failed_cases: + print("Skipping %s. It is known to fail." % (case)) + case_result_list.append({"Name": case, "Result": "SKIP"}) + + thread_objs = [] + left_cases = list(set(all_cases) - set(known_failed_cases)) + index = 0 + max_thread_count = 32 + + while index < len(left_cases): + cur_thread_count = 0 + for thread_obj in thread_objs: + if thread_obj.is_alive(): + cur_thread_count += 1 + while cur_thread_count < max_thread_count and index < len(left_cases): + thread_obj = threading.Thread(target=run_case, args=(left_cases[index], case_result_list, log_dir, )) + thread_obj.start() + time.sleep(0.02) + thread_objs.append(thread_obj) + index += 1 + cur_thread_count += 1 + end_time = time.time() + 30 + while time.time() < end_time: + for thread_obj in thread_objs: + if thread_obj.is_alive(): + break + else: + break + else: + print("Thread timeout") + exit(1) + with open(output_file, 'w') as f: + json.dump(obj=result, fp=f, indent=2) + + failed = 0 + for x in case_result_list: + if x["Result"] == "FAIL": + print("Test case %s failed." % (x["Name"])) + failed = 1 + exit(failed) + + +if __name__ == '__main__': + main() diff --git a/src/spdk/test/iscsi_tgt/calsoft/calsoft.sh b/src/spdk/test/iscsi_tgt/calsoft/calsoft.sh new file mode 100755 index 00000000..1a5c3932 --- /dev/null +++ b/src/spdk/test/iscsi_tgt/calsoft/calsoft.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../../..) +source $rootdir/test/common/autotest_common.sh +source $rootdir/test/iscsi_tgt/common.sh + +delete_tmp_conf_files() { + rm -f /usr/local/etc/its.conf + rm -f /usr/local/etc/auth.conf +} + +if [ ! -d /usr/local/calsoft ]; then + echo "skipping calsoft tests" + exit 0 +fi + +timing_enter calsoft + +MALLOC_BDEV_SIZE=64 +MALLOC_BLOCK_SIZE=512 + +rpc_py="$rootdir/scripts/rpc.py" +calsoft_py="$testdir/calsoft.py" + +# Copy the calsoft config file to /usr/local/etc +mkdir -p /usr/local/etc +cp $testdir/its.conf /usr/local/etc/ +cp $testdir/auth.conf /usr/local/etc/ + +# Append target ip to calsoft config +echo "IP=$TARGET_IP" >> /usr/local/etc/its.conf + +timing_enter start_iscsi_tgt + +$ISCSI_APP -m 0x1 --wait-for-rpc & +pid=$! +echo "Process pid: $pid" + +trap "killprocess $pid; delete_tmp_conf_files; exit 1 " SIGINT SIGTERM EXIT + +waitforlisten $pid +$rpc_py load_subsystem_config < $testdir/iscsi.json +$rpc_py start_subsystem_init +echo "iscsi_tgt is listening. Running tests..." + +timing_exit start_iscsi_tgt + +$rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT +$rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK +$rpc_py construct_malloc_bdev -b MyBdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE +# "MyBdev:0" ==> use MyBdev blockdev for LUN0 +# "1:2" ==> map PortalGroup1 to InitiatorGroup2 +# "64" ==> iSCSI queue depth 64 +# "0 0 0 1" ==> enable CHAP authentication using auth group 1 +$rpc_py construct_target_node Target3 Target3_alias 'MyBdev:0' $PORTAL_TAG:$INITIATOR_TAG 64 -g 1 +sleep 1 + +if [ "$1" ]; then + $calsoft_py "$output_dir" "$1" + failed=$? +else + $calsoft_py "$output_dir" + failed=$? +fi + +trap - SIGINT SIGTERM EXIT + +killprocess $pid +delete_tmp_conf_files +timing_exit calsoft +exit $failed diff --git a/src/spdk/test/iscsi_tgt/calsoft/iscsi.json b/src/spdk/test/iscsi_tgt/calsoft/iscsi.json new file mode 100644 index 00000000..34e44ca0 --- /dev/null +++ b/src/spdk/test/iscsi_tgt/calsoft/iscsi.json @@ -0,0 +1,17 @@ +{ + "subsystem": "iscsi", + "config": [ + { + "params": { + "allow_duplicated_isid": true, + "nop_timeout": 30, + "nop_in_interval": 10, + "discovery_auth_group": 1, + "max_sessions": 256, + "error_recovery_level": 2, + "auth_file": "/usr/local/etc/auth.conf" + }, + "method": "set_iscsi_options" + } + ] +} diff --git a/src/spdk/test/iscsi_tgt/calsoft/its.conf b/src/spdk/test/iscsi_tgt/calsoft/its.conf new file mode 100644 index 00000000..6469dab6 --- /dev/null +++ b/src/spdk/test/iscsi_tgt/calsoft/its.conf @@ -0,0 +1,7 @@ +InitiatorName=iqn.1994-05.com.redhat:b3283535dc3b +TargetName=iqn.2016-06.io.spdk:Target3 +DefaultTime2Retain=20 +DefaultTime2Wait=2 +AuthMethod=CHAP,None +UserName=root +PassWord=tester |