diff options
Diffstat (limited to '')
23 files changed, 925 insertions, 0 deletions
diff --git a/src/spdk/test/spdkcli/common.sh b/src/spdk/test/spdkcli/common.sh new file mode 100644 index 000000000..fec6d0497 --- /dev/null +++ b/src/spdk/test/spdkcli/common.sh @@ -0,0 +1,45 @@ +spdkcli_job="$rootdir/test/spdkcli/spdkcli_job.py" +spdk_clear_config_py="$rootdir/test/json_config/clear_config.py" + +function on_error_exit() { + set +e + if [ -n "$spdk_tgt_pid" ]; then + killprocess $spdk_tgt_pid + fi + if [ -n "$nvmf_tgt_pid" ]; then + killprocess $nvmf_tgt_pid + fi + if [ -n "$iscsi_tgt_pid" ]; then + killprocess $iscsi_tgt_pid + fi + if [ -n "$vhost_tgt_pid" ]; then + killprocess $vhost_tgt_pid + fi + rm -f $testdir/${MATCH_FILE} $testdir/match_files/spdkcli_details_vhost.test /tmp/sample_aio /tmp/sample_pmem + print_backtrace + exit 1 +} + +function run_spdk_tgt() { + $SPDK_BIN_DIR/spdk_tgt -m 0x3 -p 0 -s 4096 & + spdk_tgt_pid=$! + waitforlisten $spdk_tgt_pid +} + +function run_nvmf_tgt() { + $SPDK_BIN_DIR/nvmf_tgt -m 0x3 -p 0 -s 4096 & + nvmf_tgt_pid=$! + waitforlisten $nvmf_tgt_pid +} + +function run_vhost_tgt() { + $SPDK_BIN_DIR/vhost -m 0x3 -p 0 -s 4096 & + vhost_tgt_pid=$! + waitforlisten $vhost_tgt_pid +} + +function check_match() { + $rootdir/scripts/spdkcli.py ll $SPDKCLI_BRANCH > $testdir/match_files/${MATCH_FILE} + $rootdir/test/app/match/match $testdir/match_files/${MATCH_FILE}.match + rm -f $testdir/match_files/${MATCH_FILE} +} diff --git a/src/spdk/test/spdkcli/iscsi.sh b/src/spdk/test/spdkcli/iscsi.sh new file mode 100755 index 000000000..ff892ab36 --- /dev/null +++ b/src/spdk/test/spdkcli/iscsi.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../..) +source $rootdir/test/common/autotest_common.sh +source $rootdir/test/spdkcli/common.sh +source $rootdir/test/iscsi_tgt/common.sh + +MATCH_FILE="spdkcli_iscsi.test" +SPDKCLI_BRANCH="/iscsi" + +trap 'on_error_exit;' ERR + +timing_enter run_iscsi_tgt + +# Running iscsi target with --wait-for-rpc. Implies framework_start_init later +$SPDK_BIN_DIR/iscsi_tgt -m 0x3 -p 0 -s 4096 --wait-for-rpc & +iscsi_tgt_pid=$! +waitforlisten $iscsi_tgt_pid +$rootdir/scripts/rpc.py framework_start_init + +timing_exit run_iscsi_tgt + +timing_enter spdkcli_create_iscsi_config +$spdkcli_job "'/bdevs/malloc create 32 512 Malloc0' 'Malloc0' True +'/bdevs/malloc create 32 512 Malloc1' 'Malloc1' True +'/bdevs/malloc create 32 512 Malloc2' 'Malloc2' True +'/bdevs/malloc create 32 512 Malloc3' 'Malloc3' True +'/iscsi/portal_groups create 1 \"127.0.0.1:3261 127.0.0.1:3263@0x1\"' 'host=127.0.0.1, port=3261' True +'/iscsi/portal_groups create 2 127.0.0.1:3262' 'host=127.0.0.1, port=3262' True +'/iscsi/initiator_groups create 2 ANY 10.0.2.15/32' 'hostname=ANY, netmask=10.0.2.15/32' True +'/iscsi/initiator_groups create 3 ANZ 10.0.2.15/32' 'hostname=ANZ, netmask=10.0.2.15/32' True +'/iscsi/initiator_groups add_initiator 2 ANW 10.0.2.16/32' 'hostname=ANW, netmask=10.0.2.16' True +'/iscsi/target_nodes create Target0 Target0_alias \"Malloc0:0 Malloc1:1\" 1:2 64 g=1' 'Target0' True +'/iscsi/target_nodes create Target1 Target1_alias Malloc2:0 1:2 64 g=1' 'Target1' True +'/iscsi/target_nodes/iqn.2016-06.io.spdk:Target0 iscsi_target_node_add_pg_ig_maps \"1:3 2:2\"' 'portal_group1 - initiator_group3' True +'/iscsi/target_nodes add_lun iqn.2016-06.io.spdk:Target1 Malloc3 2' 'Malloc3' True +'/iscsi/auth_groups create 1 \"user:test1 secret:test1 muser:mutual_test1 msecret:mutual_test1,\ +user:test3 secret:test3 muser:mutual_test3 msecret:mutual_test3\"' 'user=test3' True +'/iscsi/auth_groups add_secret 1 user=test2 secret=test2 muser=mutual_test2 msecret=mutual_test2' 'user=test2' True +'/iscsi/auth_groups create 2 \"user:test4 secret:test4 muser:mutual_test4 msecret:mutual_test4\"' 'user=test4' True +'/iscsi/target_nodes/iqn.2016-06.io.spdk:Target0 set_auth g=1 d=true' 'disable_chap: True' True +'/iscsi/global_params set_auth g=1 d=true r=false' 'disable_chap: True' True +'/iscsi ls' 'Malloc' True +" +timing_exit spdkcli_create_iscsi_config + +timing_enter spdkcli_check_match +check_match +timing_exit spdkcli_check_match + +timing_enter spdkcli_clear_iscsi_config +$spdkcli_job "'/iscsi/auth_groups delete_secret 1 test2' 'user=test2' +'/iscsi/auth_groups delete_secret_all 1' 'user=test1' +'/iscsi/auth_groups delete 1' 'user=test1' +'/iscsi/auth_groups delete_all' 'user=test4' +'/iscsi/target_nodes/iqn.2016-06.io.spdk:Target0 iscsi_target_node_remove_pg_ig_maps \"1:3 2:2\"' 'portal_group1 - initiator_group3' +'/iscsi/target_nodes delete iqn.2016-06.io.spdk:Target1' 'Target1' +'/iscsi/target_nodes delete_all' 'Target0' +'/iscsi/initiator_groups delete_initiator 2 ANW 10.0.2.16/32' 'ANW' +'/iscsi/initiator_groups delete 3' 'ANZ' +'/iscsi/initiator_groups delete_all' 'ANY' +'/iscsi/portal_groups delete 1' '127.0.0.1:3261' +'/iscsi/portal_groups delete_all' '127.0.0.1:3262' +'/bdevs/malloc delete Malloc3' 'Malloc3' +'/bdevs/malloc delete Malloc2' 'Malloc2' +'/bdevs/malloc delete Malloc1' 'Malloc1' +'/bdevs/malloc delete Malloc0' 'Malloc0' +" +timing_exit spdkcli_clear_iscsi_config + +killprocess $iscsi_tgt_pid diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_details_lvs.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_details_lvs.test.match new file mode 100644 index 000000000..efb34b9e7 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_details_lvs.test.match @@ -0,0 +1,9 @@ +{ + "base_bdev": "Malloc0", + "block_size": 512, + "cluster_size": 4194304, + "free_clusters": 1, + "name": "lvs0", + "total_data_clusters": 9, + "uuid": "$(S)" +} diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_details_vhost.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_details_vhost.test.match new file mode 100644 index 000000000..afab7ba56 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_details_vhost.test.match @@ -0,0 +1,32 @@ +{ + "aliases": [], + "assigned_rate_limits": { + "r_mbytes_per_sec": $(N), + "rw_ios_per_sec": $(N), + "rw_mbytes_per_sec": $(N), + "w_mbytes_per_sec": $(N) + }, + "block_size": $(N), + "claimed": false, + "driver_specific": { + "split": { + "base_bdev": "Nvme0n1", + "offset_blocks": $(N) + } + }, + "name": "Nvme0n1p0", + "num_blocks": $(N), + "product_name": "Split Disk", + "supported_io_types": { + "flush": $(S), + "nvme_admin": $(S), + "nvme_io": $(S), + "read": $(S), + "reset": $(S), + "unmap": $(S), + "write": $(S), + "write_zeroes": $(S) + }, + "uuid": "$(S)", + "zoned": false +} diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_details_vhost_ctrl.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_details_vhost_ctrl.test.match new file mode 100644 index 000000000..7e045fb7d --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_details_vhost_ctrl.test.match @@ -0,0 +1,22 @@ +{ + "backend_specific": { + "scsi": [ + { + "id": 0, + "luns": [ + { + "bdev_name": "Malloc2", + "id": 0 + } + ], + "scsi_dev_num": 0, + "target_name": "Target 0" + } + ] + }, + "cpumask": "0x3", + "ctrlr": "vhost_scsi1", + "delay_base_us": 20, + "iops_threshold": 1000000, + "socket": "$(S)/vhost_scsi1" +} diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_details_vhost_target.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_details_vhost_target.test.match new file mode 100644 index 000000000..8a31e49f0 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_details_vhost_target.test.match @@ -0,0 +1,11 @@ +{ + "id": 0, + "luns": [ + { + "bdev_name": "Malloc2", + "id": 0 + } + ], + "scsi_dev_num": 0, + "target_name": "Target 0" +} diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_iscsi.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_iscsi.test.match new file mode 100644 index 000000000..ffb314921 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_iscsi.test.match @@ -0,0 +1,55 @@ +o- iscsi ..................................................................................................................... [...] + o- auth_groups ....................................................................................................... [Groups: 2] + | o- group1 ......................................................................................................... [Secrets: 3] + | | o- user=test1, secret=test1, muser=mutual_test1, msecret=mutual_test1 .................................................. [...] + | | o- user=test2, secret=test2, muser=mutual_test2, msecret=mutual_test2 .................................................. [...] + | | o- user=test3, secret=test3, muser=mutual_test3, msecret=mutual_test3 .................................................. [...] + | o- group2 ......................................................................................................... [Secrets: 1] + | o- user=test4, secret=test4, muser=mutual_test4, msecret=mutual_test4 .................................................. [...] + o- global_params ........................................................................................................... [...] + | o- allow_duplicated_isid: False .......................................................................................... [...] + | o- chap_group: 1 ......................................................................................................... [...] + | o- default_time2retain: 20 ............................................................................................... [...] + | o- default_time2wait: 2 .................................................................................................. [...] + | o- disable_chap: True .................................................................................................... [...] + | o- error_recovery_level: 0 ............................................................................................... [...] + | o- first_burst_length: 8192 .............................................................................................. [...] + | o- immediate_data: True .................................................................................................. [...] + | o- max_connections_per_session: 2 ........................................................................................ [...] + | o- max_queue_depth: 64 ................................................................................................... [...] + | o- max_sessions: 128 ..................................................................................................... [...] + | o- mutual_chap: False .................................................................................................... [...] + | o- node_base: iqn.2016-06.io.spdk ........................................................................................ [...] + | o- nop_in_interval: 30 ................................................................................................... [...] + | o- nop_timeout: 60 ....................................................................................................... [...] + | o- require_chap: False ................................................................................................... [...] + o- initiator_groups ........................................................................................ [Initiator groups: 2] + | o- initiator_group2 ............................................................................................ [Initiators: 2] + | | o- hostname=ANW, netmask=$(N).$(N).$(N).$(N)/32 $(S) [...] + | | o- hostname=ANY, netmask=$(N).$(N).$(N).$(N)/32 $(S) [...] + | o- initiator_group3 ............................................................................................ [Initiators: 1] + | o- hostname=ANZ, netmask=$(N).$(N).$(N).$(N)/32 $(S) [...] + o- iscsi_connections ............................................................................................ [Connections: 0] + o- portal_groups .............................................................................................. [Portal groups: 2] + | o- portal_group1 .................................................................................................. [Portals: 2] + | | o- host=127.0.0.1, port=3261 ........................................................................................... [...] + | | o- host=127.0.0.1, port=3263 ........................................................................................... [...] + | o- portal_group2 .................................................................................................. [Portals: 1] + | o- host=127.0.0.1, port=3262 ........................................................................................... [...] + o- target_nodes ................................................................................................ [Target nodes: 2] + o- iqn.2016-06.io.spdk:Target0 ......................................................................... [Id: 0, QueueDepth: 64] + | o- auths ........................................ [disable_chap: True, require_chap: False, mutual_chap: False, chap_group: 1] + | o- luns ............................................................................................................ [Luns: 2] + | | o- lun 0 ......................................................................................................... [Malloc0] + | | o- lun 1 ......................................................................................................... [Malloc1] + | o- pg_ig_maps ................................................................................................ [Pg_ig_maps: 3] + | o- portal_group1 - initiator_group2 .................................................................................. [...] + | o- portal_group1 - initiator_group3 .................................................................................. [...] + | o- portal_group2 - initiator_group2 .................................................................................. [...] + o- iqn.2016-06.io.spdk:Target1 ......................................................................... [Id: 1, QueueDepth: 64] + o- auths ....................................... [disable_chap: False, require_chap: False, mutual_chap: False, chap_group: 1] + o- luns ............................................................................................................ [Luns: 2] + | o- lun 0 ......................................................................................................... [Malloc2] + | o- lun 2 ......................................................................................................... [Malloc3] + o- pg_ig_maps ................................................................................................ [Pg_ig_maps: 1] + o- portal_group1 - initiator_group2 .................................................................................. [...] diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_nvmf.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_nvmf.test.match new file mode 100644 index 000000000..736c53090 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_nvmf.test.match @@ -0,0 +1,34 @@ +o- nvmf ...................................................................................................................... [...] + o- subsystem ..................................................................................................... [Subsystems: 4] + | o- nqn.2014-08.org.nvmexpress.discovery ......................................................... [st=Discovery, Allow any host] + | | o- hosts .......................................................................................................... [Hosts: 0] + | | o- listen_addresses ........................................................................................... [Addresses: 0] + | o- nqn.2014-08.org.spdk:cnode1 ...................................................... [sn=$(S), st=NVMe, Allow any host] + | | o- hosts .......................................................................................................... [Hosts: 1] + | | | o- nqn.2014-08.org.spdk:cnode2 ....................................................................................... [...] + | | o- listen_addresses ........................................................................................... [Addresses: 3] + | | | o- $(N).$(N).$(N).$(N):4260 $(S) [RDMA] + | | | o- $(N).$(N).$(N).$(N):4261 $(S) [RDMA] + | | | o- $(N).$(N).$(N).$(N):4262 $(S) [RDMA] + | | o- namespaces ................................................................................................ [Namespaces: 4] + | | o- Malloc3 .................................................................................................... [Malloc3, 1] + | | o- Malloc4 .................................................................................................... [Malloc4, 2] + | | o- Malloc5 .................................................................................................... [Malloc5, 3] + | | o- Malloc6 .................................................................................................... [Malloc6, 4] + | o- nqn.2014-08.org.spdk:cnode2 ...................................................... [sn=$(S), st=NVMe, Allow any host] + | | o- hosts .......................................................................................................... [Hosts: 0] + | | o- listen_addresses ........................................................................................... [Addresses: 1] + | | | o- $(N).$(N).$(N).$(N):4260 $(S) [RDMA] + | | o- namespaces ................................................................................................ [Namespaces: 1] + | | o- Malloc2 .................................................................................................... [Malloc2, 1] + | o- nqn.2014-08.org.spdk:cnode3 ...................................................... [sn=$(S), st=NVMe, Allow any host] + | o- hosts .......................................................................................................... [Hosts: 2] + | | o- nqn.2014-08.org.spdk:cnode1 ....................................................................................... [...] + | | o- nqn.2014-08.org.spdk:cnode2 ....................................................................................... [...] + | o- listen_addresses ........................................................................................... [Addresses: 2] + | | o- $(N).$(N).$(N).$(N):4260 $(S) [RDMA] + | | o- $(N).$(N).$(N).$(N):4261 $(S) [RDMA] + | o- namespaces ................................................................................................ [Namespaces: 1] + | o- Malloc1 .................................................................................................... [Malloc1, 1] + o- transport ..................................................................................................... [Transports: 1] + o- RDMA .................................................................................................................. [...] diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_pmem.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_pmem.test.match new file mode 100644 index 000000000..3948afd26 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_pmem.test.match @@ -0,0 +1,3 @@ +o- pmemblk .............................................................................................................. [Bdevs: 2] + o- pmem_bdev0 .......................................................................................... [Size=31.6M, Not claimed] + o- pmem_bdev1 .......................................................................................... [Size=31.6M, Not claimed] diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_pmem_info.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_pmem_info.test.match new file mode 100644 index 000000000..cdebc2ba1 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_pmem_info.test.match @@ -0,0 +1,12 @@ +[ + { + "num_blocks": 64700, + "block_size": 512 + } +] +[ + { + "num_blocks": 64700, + "block_size": 512 + } +] diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_raid.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_raid.test.match new file mode 100644 index 000000000..906c1717f --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_raid.test.match @@ -0,0 +1,17 @@ +o- bdevs ..................................................................................................................... [...] + o- aio ................................................................................................................ [Bdevs: 0] + o- error .............................................................................................................. [Bdevs: 0] + o- iscsi .............................................................................................................. [Bdevs: 0] + o- logical_volume ..................................................................................................... [Bdevs: 0] + o- malloc ............................................................................................................. [Bdevs: 2] + | o- Malloc1 ................................................................................................ [Size=8.0M, Claimed] + | o- Malloc2 ................................................................................................ [Size=8.0M, Claimed] + o- null ............................................................................................................... [Bdevs: 0] + o- nvme ............................................................................................................... [Bdevs: 0] + o- pmemblk ............................................................................................................ [Bdevs: 0] + o- raid_volume ........................................................................................................ [Bdevs: 1] + | o- testraid .......................................................................................... [Size=16.0M, Not claimed] + o- rbd ................................................................................................................ [Bdevs: 0] + o- split_disk ......................................................................................................... [Bdevs: 0] + o- virtioblk_disk ..................................................................................................... [Bdevs: 0] + o- virtioscsi_disk .................................................................................................... [Bdevs: 0] diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_rbd.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_rbd.test.match new file mode 100644 index 000000000..7d1257493 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_rbd.test.match @@ -0,0 +1,3 @@ +o- rbd .................................................................................................................. [Bdevs: 2] + o- Ceph0 ............................................................................................. [Size=1000.0M, Not claimed] + o- Ceph1 ............................................................................................. [Size=1000.0M, Not claimed] diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_vhost.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_vhost.test.match new file mode 100644 index 000000000..2a8c3c738 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_vhost.test.match @@ -0,0 +1,54 @@ +o- / ......................................................................................................................... [...] + o- bdevs ................................................................................................................... [...] + | o- aio .............................................................................................................. [Bdevs: 2] + | | o- sample0 .......................................................................................... [Size=$(FP)M, Not claimed] + | | o- sample1 .......................................................................................... [Size=$(FP)M, Not claimed] + | o- error ............................................................................................................ [Bdevs: 2] + | | o- EE_Malloc1 ...................................................................................... [Size=$(FP)M, Not claimed] + | | o- EE_Malloc4 ...................................................................................... [Size=$(FP)M, Not claimed] + | o- iscsi ............................................................................................................ [Bdevs: 0] + | o- logical_volume ................................................................................................... [Bdevs: 2] + | | o- $(X)-$(X)-$(X)-$(X)-$(X) ................................................ [lvs0/lvol$(FP), Size=$(FP)M, Not claimed] + | | o- $(X)-$(X)-$(X)-$(X)-$(X) ................................................ [lvs0/lvol$(FP), Size=$(FP)M, Not claimed] + | o- malloc ........................................................................................................... [Bdevs: 6] + | | o- Malloc0 ............................................................................................. [Size=$(FP)M, Claimed] + | | o- Malloc1 ............................................................................................. [Size=$(FP)M, Claimed] + | | o- Malloc2 ......................................................................................... [Size=$(FP)M, Not claimed] + | | o- Malloc3 ......................................................................................... [Size=$(FP)M, Not claimed] + | | o- Malloc4 ............................................................................................. [Size=$(FP)M, Claimed] + | | o- Malloc5 ............................................................................................. [Size=$(FP)M, Claimed] + | o- null ............................................................................................................. [Bdevs: 2] + | | o- null_bdev0 ...................................................................................... [Size=$(FP)M, Not claimed] + | | o- null_bdev1 ...................................................................................... [Size=$(FP)M, Not claimed] + | o- nvme ............................................................................................................. [Bdevs: 1] + | | o- Nvme0n1 $(S) [Size=$(S), Claimed] + | o- pmemblk .......................................................................................................... [Bdevs: 0] + | o- raid_volume ...................................................................................................... [Bdevs: 0] + | o- rbd .............................................................................................................. [Bdevs: 0] + | o- split_disk ....................................................................................................... [Bdevs: 4] + | | o- Nvme0n1p0 $(S) [Size=$(FP)G, Not claimed] + | | o- Nvme0n1p1 $(S) [Size=$(FP)G, Not claimed] + | | o- Nvme0n1p2 $(S) [Size=$(FP)G, Not claimed] + | | o- Nvme0n1p3 $(S) [Size=$(FP)G, Not claimed] + | o- virtioblk_disk ................................................................................................... [Bdevs: 0] + | o- virtioscsi_disk .................................................................................................. [Bdevs: 0] + o- lvol_stores .................................................................................................. [Lvol stores: 2] + | o- lvs0 $(S) [Size=$(FP)M, Free=$(FP)M] + | o- lvs1 $(S) [Size=$(FP)M, Free=$(FP)M] + o- vhost ................................................................................................................... [...] + o- block ................................................................................................................. [...] + | o- vhost_blk1 $(S) [$(S)] + | | o- Nvme0n1p0 ......................................................................................................... [...] + | o- vhost_blk2 $(S) [$(S), Readonly] + | o- Nvme0n1p1 ......................................................................................................... [...] + o- scsi .................................................................................................................. [...] + o- vhost_scsi1 $(S) [$(S)] + | o- Target_0 .......................................................................................... [LUNs: 1,TargetID: 0] + | o- Malloc2 ......................................................................................................... [...] + o- vhost_scsi2 $(S) [$(S)] + o- Target_0 .......................................................................................... [LUNs: 1,TargetID: 0] + | o- Malloc3 ......................................................................................................... [...] + o- Target_1 .......................................................................................... [LUNs: 1,TargetID: 1] + | o- Nvme0n1p2 ....................................................................................................... [...] + o- Target_2 .......................................................................................... [LUNs: 1,TargetID: 2] + o- Nvme0n1p3 ....................................................................................................... [...] diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_virtio_pci.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_virtio_pci.test.match new file mode 100644 index 000000000..5caf84e56 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_virtio_pci.test.match @@ -0,0 +1,19 @@ +o- bdevs ..................................................................................................................... [...] + o- aio ................................................................................................................ [Bdevs: 0] + o- error .............................................................................................................. [Bdevs: 0] + o- iscsi .............................................................................................................. [Bdevs: 0] + o- logical_volume ..................................................................................................... [Bdevs: 0] + o- malloc ............................................................................................................. [Bdevs: 2] + | o- Malloc0 ........................................................................................... [Size=32.0M, Not claimed] + | o- Malloc1 ........................................................................................... [Size=32.0M, Not claimed] + o- null ............................................................................................................... [Bdevs: 0] + o- nvme ............................................................................................................... [Bdevs: 0] + o- pmemblk ............................................................................................................ [Bdevs: 0] + o- raid_volume ........................................................................................................ [Bdevs: 0] + o- rbd ................................................................................................................ [Bdevs: 0] + o- split_disk ......................................................................................................... [Bdevs: 0] + o- virtioblk_disk ..................................................................................................... [Bdevs: 1] + | o- virtioblk_pci $(S) [Size=$(FP)M, Not claimed] + o- virtioscsi_disk .................................................................................................... [Bdevs: 1] + o- virtioscsi_pci ............................................................................................... [$(S)] + o- virtioscsi_pcit0 $(S) [Size=$(FP)M, Not claimed] diff --git a/src/spdk/test/spdkcli/match_files/spdkcli_virtio_user.test.match b/src/spdk/test/spdkcli/match_files/spdkcli_virtio_user.test.match new file mode 100644 index 000000000..157938e74 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_virtio_user.test.match @@ -0,0 +1,8 @@ +o- vhost ..................................................................................................................... [...] + o- block ................................................................................................................... [...] + | o- sample_block $(S) [$(S)] + | o- Malloc1 ............................................................................................................. [...] + o- scsi .................................................................................................................... [...] + o- sample_scsi $(S) [$(S)] + o- Target_0 ............................................................................................ [LUNs: 1,TargetID: 0] + o- Malloc0 ........................................................................................................... [...] diff --git a/src/spdk/test/spdkcli/nvmf.sh b/src/spdk/test/spdkcli/nvmf.sh new file mode 100755 index 000000000..1c2499d11 --- /dev/null +++ b/src/spdk/test/spdkcli/nvmf.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../..) +source $rootdir/test/common/autotest_common.sh +source $rootdir/test/spdkcli/common.sh +source $rootdir/test/nvmf/common.sh + +MATCH_FILE="spdkcli_nvmf.test" +SPDKCLI_BRANCH="/nvmf" + +trap 'on_error_exit; revert_soft_roce' ERR +rdma_device_init + +timing_enter run_nvmf_tgt +run_nvmf_tgt +timing_exit run_nvmf_tgt + +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) + +timing_enter spdkcli_create_nvmf_config +$spdkcli_job "'/bdevs/malloc create 32 512 Malloc1' 'Malloc1' True +'/bdevs/malloc create 32 512 Malloc2' 'Malloc2' True +'/bdevs/malloc create 32 512 Malloc3' 'Malloc3' True +'/bdevs/malloc create 32 512 Malloc4' 'Malloc4' True +'/bdevs/malloc create 32 512 Malloc5' 'Malloc5' True +'/bdevs/malloc create 32 512 Malloc6' 'Malloc6' True +'nvmf/transport create RDMA max_io_qpairs_per_ctrlr=4 io_unit_size=8192' '' True +'/nvmf/subsystem create nqn.2014-08.org.spdk:cnode1 N37SXV509SRW\ + max_namespaces=4 allow_any_host=True' 'nqn.2014-08.org.spdk:cnode1' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces create Malloc3 1' 'Malloc3' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces create Malloc4 2' 'Malloc4' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses create \ + RDMA $NVMF_TARGET_IP 4260 IPv4' '$NVMF_TARGET_IP:4260' True +'/nvmf/subsystem create nqn.2014-08.org.spdk:cnode2 N37SXV509SRD\ + max_namespaces=2 allow_any_host=True' 'nqn.2014-08.org.spdk:cnode2' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode2/namespaces create Malloc2' 'Malloc2' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode2/listen_addresses create \ + RDMA $NVMF_TARGET_IP 4260 IPv4' '$NVMF_TARGET_IP:4260' True +'/nvmf/subsystem create nqn.2014-08.org.spdk:cnode3 N37SXV509SRR\ + max_namespaces=2 allow_any_host=True' 'nqn.2014-08.org.spdk:cnode2' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/namespaces create Malloc1' 'Malloc1' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/listen_addresses create \ + RDMA $NVMF_TARGET_IP 4260 IPv4' '$NVMF_TARGET_IP:4260' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/listen_addresses create \ + RDMA $NVMF_TARGET_IP 4261 IPv4' '$NVMF_TARGET_IP:4261' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/hosts create \ + nqn.2014-08.org.spdk:cnode1' 'nqn.2014-08.org.spdk:cnode1' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/hosts create \ + nqn.2014-08.org.spdk:cnode2' 'nqn.2014-08.org.spdk:cnode2' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1 allow_any_host True' 'Allow any host' +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1 allow_any_host False' 'Allow any host' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses create RDMA $NVMF_TARGET_IP 4261 IPv4' '$NVMF_TARGET_IP:4261' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses create RDMA $NVMF_TARGET_IP 4262 IPv4' '$NVMF_TARGET_IP:4262' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/hosts create nqn.2014-08.org.spdk:cnode2' 'nqn.2014-08.org.spdk:cnode2' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces create Malloc5' 'Malloc5' True +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces create Malloc6' 'Malloc6' True +" +timing_exit spdkcli_create_nvmf_config + +timing_enter spdkcli_check_match +check_match +timing_exit spdkcli_check_match + +timing_enter spdkcli_clear_nvmf_config +$spdkcli_job "'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces delete nsid=1' 'Malloc3' +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces delete_all' 'Malloc4' +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/hosts delete nqn.2014-08.org.spdk:cnode2' 'nqn.2014-08.org.spdk:cnode2' +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/hosts delete_all' 'nqn.2014-08.org.spdk:cnode1' +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses delete RDMA $NVMF_TARGET_IP 4262' '$NVMF_TARGET_IP:4262' +'/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses delete_all' '$NVMF_TARGET_IP:4261' +'/nvmf/subsystem delete nqn.2014-08.org.spdk:cnode3' 'nqn.2014-08.org.spdk:cnode3' +'/nvmf/subsystem delete_all' 'nqn.2014-08.org.spdk:cnode2' +'/bdevs/malloc delete Malloc6' 'Malloc6' +'/bdevs/malloc delete Malloc5' 'Malloc5' +'/bdevs/malloc delete Malloc4' 'Malloc4' +'/bdevs/malloc delete Malloc3' 'Malloc3' +'/bdevs/malloc delete Malloc2' 'Malloc2' +'/bdevs/malloc delete Malloc1' 'Malloc1' +" +timing_exit spdkcli_clear_nvmf_config + +killprocess $nvmf_tgt_pid +#revert_soft_roce diff --git a/src/spdk/test/spdkcli/pmem.sh b/src/spdk/test/spdkcli/pmem.sh new file mode 100755 index 000000000..abecd73ca --- /dev/null +++ b/src/spdk/test/spdkcli/pmem.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../..) +source $rootdir/test/common/autotest_common.sh +source $rootdir/test/spdkcli/common.sh + +MATCH_FILE="spdkcli_pmem.test" +SPDKCLI_BRANCH="/bdevs/pmemblk" + +trap 'rm -f $testdir/match_files/spdkcli_pmem_info.test; on_error_exit;' ERR + +timing_enter run_spdk_tgt +run_spdk_tgt +timing_exit run_spdk_tgt + +timing_enter spdkcli_create_pmem_config +$spdkcli_job "'/bdevs/pmemblk bdev_pmem_create_pool /tmp/sample_pmem0 32 512' '' True +'/bdevs/pmemblk bdev_pmem_create_pool /tmp/sample_pmem1 32 512' '' True +" + +# Saving pmem pool info before they get claimed by /bdevs/pmemblk create +$rootdir/scripts/spdkcli.py /bdevs/pmemblk bdev_pmem_get_pool_info /tmp/sample_pmem0 >> $testdir/match_files/spdkcli_pmem_info.test +$rootdir/scripts/spdkcli.py /bdevs/pmemblk bdev_pmem_get_pool_info /tmp/sample_pmem1 >> $testdir/match_files/spdkcli_pmem_info.test + +$spdkcli_job "'/bdevs/pmemblk create /tmp/sample_pmem0 pmem_bdev0' 'pmem_bdev0' True +'/bdevs/pmemblk create /tmp/sample_pmem1 pmem_bdev1' 'pmem_bdev1' True +" + +timing_exit spdkcli_create_pmem_config + +timing_enter spdkcli_check_match +check_match +$rootdir/test/app/match/match -v $testdir/match_files/spdkcli_pmem_info.test.match +timing_exit spdkcli_check_match + +timing_enter spdkcli_clear_pmem_config +$spdkcli_job "'/bdevs/pmemblk delete pmem_bdev0' 'pmem_bdev0' +'/bdevs/pmemblk bdev_pmem_delete_pool /tmp/sample_pmem0' '' +'/bdevs/pmemblk delete_all' 'pmem_bdev1' +'/bdevs/pmemblk bdev_pmem_delete_pool /tmp/sample_pmem1' '' +" +rm -f /tmp/sample_pmem +rm -f $testdir/match_files/spdkcli_pmem_info.test +timing_exit spdkcli_clear_pmem_config + +killprocess $spdk_tgt_pid diff --git a/src/spdk/test/spdkcli/raid.sh b/src/spdk/test/spdkcli/raid.sh new file mode 100755 index 000000000..9bbde4719 --- /dev/null +++ b/src/spdk/test/spdkcli/raid.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../..) +source $rootdir/test/common/autotest_common.sh +source $rootdir/test/spdkcli/common.sh +source $rootdir/test/iscsi_tgt/common.sh + +MATCH_FILE="spdkcli_raid.test" +SPDKCLI_BRANCH="/bdevs" +testdir=$(readlink -f $(dirname $0)) +. $testdir/common.sh + +trap 'on_error_exit;' ERR + +timing_enter run_spdk_tgt +run_spdk_tgt +timing_exit run_spdk_tgt + +timing_enter spdkcli_create_malloc +$spdkcli_job "'/bdevs/malloc create 8 512 Malloc1' 'Malloc1' True +'/bdevs/malloc create 8 512 Malloc2' 'Malloc2' True +" +timing_exit spdkcli_create_malloc + +timing_enter spdkcli_create_raid +$spdkcli_job "'/bdevs/raid_volume create testraid 0 \"Malloc1 Malloc2\" 4' 'testraid' True +" +timing_exit spdkcli_create_raid + +timing_enter spdkcli_check_match +check_match +timing_exit spdkcli_check_match + +timing_enter spdkcli_delete_raid +$spdkcli_job "'/bdevs/raid_volume delete testraid' '' True +" +timing_exit spdkcli_delete_raid + +timing_enter spdkcli_delete_malloc +$spdkcli_job "'/bdevs/malloc delete Malloc1' '' True +'/bdevs/malloc delete Malloc2' '' True +" +timing_exit spdkcli_delete_malloc + +killprocess $spdk_tgt_pid diff --git a/src/spdk/test/spdkcli/rbd.sh b/src/spdk/test/spdkcli/rbd.sh new file mode 100755 index 000000000..bc6c798f6 --- /dev/null +++ b/src/spdk/test/spdkcli/rbd.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../..) +source $rootdir/test/common/autotest_common.sh +source $rootdir/test/spdkcli/common.sh + +MATCH_FILE="spdkcli_rbd.test" +SPDKCLI_BRANCH="/bdevs/rbd" + +trap 'on_error_exit' ERR +timing_enter run_spdk_tgt +run_spdk_tgt +timing_exit run_spdk_tgt + +timing_enter spdkcli_create_rbd_config +trap 'rbd_cleanup; on_error_exit' ERR +rbd_cleanup +rbd_setup 127.0.0.1 +$spdkcli_job "\"/bdevs/rbd create rbd foo 512' 'Ceph0' True "\"/bdevs/rbd create rbd foo 512 'Ceph1' True" +timing_exit spdkcli_create_rbd_config + +timing_enter spdkcli_check_match +check_match +timing_exit spdkcli_check_match + +timing_enter spdkcli_clear_rbd_config +$spdkcli_job "\"/bdevs/rbd delete Ceph0 'Ceph0' "\"/bdevs/rbd delete_all' 'Ceph1' " +rbd_cleanup +timing_exit spdkcli_clear_rbd_config + +killprocess $spdk_tgt_pid diff --git a/src/spdk/test/spdkcli/spdkcli_job.py b/src/spdk/test/spdkcli/spdkcli_job.py new file mode 100755 index 000000000..ce6530a90 --- /dev/null +++ b/src/spdk/test/spdkcli/spdkcli_job.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +import pexpect +import os +import sys +import re + + +def execute_command(cmd, element=None, element_exists=False): + child.sendline(cmd) + child.expect("/>") + if "error response" in child.before.decode(): + print("Error in cmd: %s" % cmd) + exit(1) + ls_tree = cmd.split(" ")[0] + if ls_tree and element: + child.sendline("ls %s" % ls_tree) + child.expect("/>") + if element_exists: + if element not in child.before.decode(): + print("Element %s not in list:\n%s" % (element, child.before.decode())) + exit(1) + else: + if element in child.before.decode(): + print("Element %s is in list:\n%s" % (element, child.before.decode())) + exit(1) + + +if __name__ == "__main__": + socket = "/var/tmp/spdk.sock" + port = None + if len(sys.argv) == 3: + socket = sys.argv[2] + elif len(sys.argv) == 4: + port = sys.argv[3] + testdir = os.path.dirname(os.path.realpath(sys.argv[0])) + + if port is None: + child = pexpect.spawn(os.path.join(testdir, "../../scripts/spdkcli.py") + " -s %s" % socket) + else: + child = pexpect.spawn(os.path.join(testdir, "../../scripts/spdkcli.py") + " -s %s -p %s" % (socket, port)) + child.expect(">") + child.sendline("cd /") + child.expect("/>") + + cmd_lines = sys.argv[1].strip().split("\n") + for line in cmd_lines: + data = line.strip() + p = re.compile('\'(.*?)\'') + cmd = p.findall(data) + if data[-1] != "\'": + cmd.append(data.rsplit(" ", 1)[1].strip()) + if cmd[-1] == "False": + cmd[-1] = False + else: + cmd[-1] = True + else: + cmd.append(False) + print("Executing command: %s" % cmd) + execute_command(*cmd[0:3]) diff --git a/src/spdk/test/spdkcli/tcp.sh b/src/spdk/test/spdkcli/tcp.sh new file mode 100755 index 000000000..d0d4dafba --- /dev/null +++ b/src/spdk/test/spdkcli/tcp.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../..) +source $rootdir/test/common/autotest_common.sh +source $rootdir/test/spdkcli/common.sh + +function err_cleanup() { + if [ -n "$socat_pid" ]; then + killprocess $socat_pid || true + fi + killprocess $spdk_tgt_pid +} + +IP_ADDRESS="127.0.0.1" +PORT="9998" + +trap 'err_cleanup; exit 1' SIGINT SIGTERM EXIT + +timing_enter run_spdk_tgt_tcp +$SPDK_BIN_DIR/spdk_tgt -m 0x3 -p 0 -s 2048 & +spdk_tgt_pid=$! + +waitforlisten $spdk_tgt_pid + +# socat will terminate automatically after the connection is closed +socat TCP-LISTEN:$PORT UNIX-CONNECT:$DEFAULT_RPC_ADDR & +socat_pid=$! + +$rootdir/scripts/rpc.py -r 100 -t 2 -s $IP_ADDRESS -p $PORT rpc_get_methods + +timing_exit run_spdk_tgt_tcp + +trap - SIGINT SIGTERM EXIT +killprocess $spdk_tgt_pid diff --git a/src/spdk/test/spdkcli/vhost.sh b/src/spdk/test/spdkcli/vhost.sh new file mode 100755 index 000000000..809a322f8 --- /dev/null +++ b/src/spdk/test/spdkcli/vhost.sh @@ -0,0 +1,147 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../..) +source $rootdir/test/common/autotest_common.sh +source $rootdir/test/spdkcli/common.sh + +MATCH_FILE="spdkcli_vhost.test" +SPDKCLI_BRANCH="/" + +sample_aio=$SPDK_TEST_STORAGE/sample_aio +sample_aio2=$SPDK_TEST_STORAGE/sample_aio2 + +trap 'on_error_exit' ERR +timing_enter run_vhost_tgt +run_vhost_tgt +timing_exit run_vhost_tgt + +timing_enter spdkcli_create_bdevs_config +$spdkcli_job "'/bdevs/malloc create 40 512 Malloc0' 'Malloc0' True +'/bdevs/malloc create 32 512 Malloc1' 'Malloc1' True +'/bdevs/malloc create 32 512 Malloc2' 'Malloc2' True +'/bdevs/malloc create 32 4096 Malloc3' 'Malloc3' True +'/bdevs/malloc create 32 4096 Malloc4' 'Malloc4' True +'/bdevs/malloc create 32 4096 Malloc5' 'Malloc5' True +'/bdevs/error create Malloc1' 'EE_Malloc1' True +'/bdevs/error create Malloc4' 'EE_Malloc4' True +'/bdevs/null create null_bdev0 32 512' 'null_bdev0' True +'/bdevs/null create null_bdev1 32 512' 'null_bdev1' True +" +dd if=/dev/zero of="$sample_aio" bs=2048 count=5000 +dd if=/dev/zero of="$sample_aio2" bs=2048 count=5000 +$spdkcli_job "'/bdevs/aio create sample0 $sample_aio 512' 'sample0' True +'/bdevs/aio create sample1 $sample_aio2 512' 'sample1' True +" +trtype=$($rootdir/scripts/gen_nvme.sh --json | jq -r '.config[].params | select(.name=="Nvme0").trtype') +traddr=$($rootdir/scripts/gen_nvme.sh --json | jq -r '.config[].params | select(.name=="Nvme0").traddr') +$spdkcli_job "'/bdevs/nvme create Nvme0 $trtype $traddr' 'Nvme0' True +'/bdevs/split_disk bdev_split_create Nvme0n1 4' 'Nvme0n1p0' True +" +timing_exit spdkcli_create_bdevs_config + +timing_enter spdkcli_create_lvols_config +$spdkcli_job "'/lvol_stores create lvs0 Malloc0' 'lvs0' True +'/lvol_stores create lvs1 Malloc5' 'lvs1' True +'/bdevs/logical_volume create lvol0 16 lvs0' 'lvs0/lvol0' True +'/bdevs/logical_volume create lvol1 16 lvs0' 'lvs0/lvol1' True +" +timing_exit spdkcli_create_lvols_config + +timing_enter spdkcli_check_match_details +$rootdir/scripts/spdkcli.py /lvol_stores/lvs0 show_details | jq -r -S '.' > $testdir/match_files/spdkcli_details_lvs.test +$rootdir/test/app/match/match $testdir/match_files/spdkcli_details_lvs.test.match +rm -f $testdir/match_files/spdkcli_details_lvs.test +timing_exit spdkcli_check_match_details + +timing_enter spdkcli_create_vhosts_config +$spdkcli_job "'vhost/block create vhost_blk1 Nvme0n1p0' 'Nvme0n1p0' True +'vhost/block create vhost_blk2 Nvme0n1p1 0x1 readonly' 'Nvme0n1p1' True +'vhost/scsi create vhost_scsi1' 'vhost_scsi1' True +'vhost/scsi create vhost_scsi2' 'vhost_scsi2' True +'vhost/scsi/vhost_scsi1 add_lun 0 Malloc2' 'Malloc2' True +'vhost/scsi/vhost_scsi2 add_lun 0 Malloc3' 'Malloc3' True +'vhost/scsi/vhost_scsi2 add_lun 1 Nvme0n1p2' 'Nvme0n1p2' True +'vhost/scsi/vhost_scsi2 add_lun 2 Nvme0n1p3' 'Nvme0n1p3' True +'vhost/scsi/vhost_scsi1 set_coalescing 20 1000000' '' True +" +timing_exit spdkcli_create_vhosts_config + +timing_enter spdkcli_check_match +check_match +timing_exit spdkcli_check_match + +timing_enter spdkcli_save_config +$spdkcli_job "'save_config $testdir/config.json' +'save_subsystem_config $testdir/config_bdev.json bdev' +'save_subsystem_config $testdir/config_vhost.json vhost' +" +timing_exit spdkcli_save_config + +timing_enter spdkcli_check_match_details +$rootdir/scripts/spdkcli.py vhost/scsi/vhost_scsi1/Target_0 show_details | jq -r -S '.' > $testdir/match_files/spdkcli_details_vhost_target.test +$rootdir/test/app/match/match $testdir/match_files/spdkcli_details_vhost_target.test.match +rm -f $testdir/match_files/spdkcli_details_vhost_target.test + +$rootdir/scripts/spdkcli.py bdevs/split_disk/Nvme0n1p0 show_details | jq -r -S '.' > $testdir/match_files/spdkcli_details_vhost.test +$rootdir/test/app/match/match $testdir/match_files/spdkcli_details_vhost.test.match +rm -f $testdir/match_files/spdkcli_details_vhost.test + +$rootdir/scripts/spdkcli.py vhost/scsi/vhost_scsi1 show_details | jq -r -S '.' > $testdir/match_files/spdkcli_details_vhost_ctrl.test +$rootdir/test/app/match/match $testdir/match_files/spdkcli_details_vhost_ctrl.test.match +rm -f $testdir/match_files/spdkcli_details_vhost_ctrl.test +timing_exit spdkcli_check_match_details + +timing_enter spdkcli_clear_config +$spdkcli_job "'vhost/scsi/vhost_scsi2 remove_target 2' 'Nvme0n1p3' +'vhost/scsi/vhost_scsi2 remove_target 1' 'Nvme0n1p2' +'vhost/scsi/vhost_scsi2 remove_target 0' 'Malloc3' +'vhost/scsi/vhost_scsi1 remove_target 0' 'Malloc2' +'vhost/scsi delete vhost_scsi2' 'vhost_scsi2' +'vhost/scsi delete vhost_scsi1' 'vhost_scsi1' +'vhost/block delete vhost_blk2' 'vhost_blk2' +'vhost/block delete vhost_blk1' 'vhost_blk1' +'/bdevs/split_disk bdev_split_delete Nvme0n1' 'Nvme0n1p0' +'/bdevs/aio delete sample0' 'sample0' +'/bdevs/aio delete_all' 'sample1' +'/bdevs/nvme delete Nvme0' 'Nvme0' +'/bdevs/null delete null_bdev0' 'null_bdev0' +'/bdevs/null delete_all' 'null_bdev1' +'/bdevs/logical_volume delete lvs0/lvol0' 'lvs0/lvol0' +'/bdevs/logical_volume delete_all' 'lvs0/lvol1' +'/lvol_stores delete lvs0' 'lvs0' +'/lvol_stores delete_all' 'lvs1' +'/bdevs/error delete EE_Malloc1' 'EE_Malloc1' +'/bdevs/error delete_all' 'EE_Malloc4' +'/bdevs/malloc delete Malloc0' 'Malloc0' +'/bdevs/malloc delete_all' 'Malloc1' +" +timing_exit spdkcli_clear_config + +timing_enter spdkcli_load_config +$spdkcli_job "'load_config $testdir/config.json' +'/lvol_stores create lvs0 Malloc0' 'lvs0' True +'/lvol_stores create lvs1 Malloc5' 'lvs1' True +'/bdevs/logical_volume create lvol0 16 lvs0' 'lvs0/lvol0' True +'/bdevs/logical_volume create lvol1 16 lvs0' 'lvs0/lvol1' True +" +check_match +$spdk_clear_config_py clear_config +# FIXME: remove this sleep when NVMe driver will be fixed to wait for reset to complete +sleep 2 +$spdkcli_job "'load_subsystem_config $testdir/config_bdev.json' +'load_subsystem_config $testdir/config_vhost.json' +'/lvol_stores create lvs0 Malloc0' 'lvs0' True +'/lvol_stores create lvs1 Malloc5' 'lvs1' True +'/bdevs/logical_volume create lvol0 16 lvs0' 'lvs0/lvol0' True +'/bdevs/logical_volume create lvol1 16 lvs0' 'lvs0/lvol1' True +" +check_match +$spdk_clear_config_py clear_config +rm -f $testdir/config.json +rm -f $testdir/config_bdev.json +rm -f $testdir/config_vhost.json +rm -f "$sample_aio" "$sample_aio2" +timing_exit spdkcli_load_config + +killprocess $vhost_tgt_pid diff --git a/src/spdk/test/spdkcli/virtio.sh b/src/spdk/test/spdkcli/virtio.sh new file mode 100755 index 000000000..b483e0562 --- /dev/null +++ b/src/spdk/test/spdkcli/virtio.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../..) +source $rootdir/test/common/autotest_common.sh +source $rootdir/test/spdkcli/common.sh + +trap 'killprocess $virtio_pid; on_error_exit' ERR + +timing_enter run_spdk_tgt +run_spdk_tgt +timing_exit run_spdk_tgt + +timing_enter run_spdk_virtio +$SPDK_BIN_DIR/spdk_tgt -m 0x4 -p 0 -g -u -s 1024 -r /var/tmp/virtio.sock & +virtio_pid=$! +waitforlisten $virtio_pid /var/tmp/virtio.sock +timing_exit run_spdk_virtio + +timing_enter spdkcli_create_virtio_pci_config +$spdkcli_job "'/bdevs/malloc create 32 512 Malloc0' 'Malloc0' True +'/bdevs/malloc create 32 512 Malloc1' 'Malloc1' True +" +pci_blk=$(lspci -nn -D | grep '1af4:1001' | head -1 | awk '{print $1;}') +if [ -n "$pci_blk" ] && grep -Eq "DRIVER=(uio|vfio)" "/sys/bus/pci/devices/$pci_blk/uevent"; then + $spdkcli_job "'/bdevs/virtioblk_disk create virtioblk_pci pci $pci_blk' 'virtioblk_pci' True" +fi +pci_scsi=$(lspci -nn -D | grep '1af4:1004' | head -1 | awk '{print $1;}') +if [ -n "$pci_scsi" ] && grep -Eq "DRIVER=(uio|vfio)" "/sys/bus/pci/devices/$pci_scsi/uevent"; then + $spdkcli_job "'/bdevs/virtioscsi_disk create virtioscsi_pci pci $pci_scsi' 'virtioscsi_pci' True" +fi +$spdkcli_job "'/vhost/scsi create sample_scsi' 'sample_scsi' True +'/vhost/scsi/sample_scsi add_lun 0 Malloc0' 'Malloc0' True +'/vhost/block create sample_block Malloc1' 'Malloc1' True +" +timing_exit spdkcli_create_virtio_pci_config + +timing_enter spdkcli_check_match +if [ -n "$pci_blk" ] && [ -n "$pci_scsi" ]; then + MATCH_FILE="spdkcli_virtio_pci.test" + SPDKCLI_BRANCH="/bdevs" + check_match +fi +timing_exit spdkcli_check_match + +timing_enter spdkcli_create_virtio_user_config +$spdkcli_job "'/bdevs/virtioblk_disk create virtioblk_user user $testdir/../../sample_block' 'virtioblk_user' True +'/bdevs/virtioscsi_disk create virtioscsi_user user $testdir/../../sample_scsi' 'virtioscsi_user' True +" /var/tmp/virtio.sock +timing_exit spdkcli_create_virtio_user_config + +timing_enter spdkcli_check_match_user_config +MATCH_FILE="spdkcli_virtio_user.test" +SPDKCLI_BRANCH="/vhost" +check_match +timing_exit spdkcli_check_match_user_config + +timing_enter spdkcli_clear_virtio_config +$spdkcli_job "'/bdevs/virtioscsi_disk delete virtioscsi_user' '' False +'/bdevs/virtioblk_disk delete virtioblk_user' '' False +" /var/tmp/virtio.sock +$spdkcli_job "'/vhost/block delete sample_block' 'sample_block' +'/vhost/scsi/sample_scsi remove_target 0' 'Malloc0' +'/vhost/scsi delete sample_scsi' 'sample_scsi' +" +if [ -n "$pci_blk" ] && grep -Eq "DRIVER=(uio|vfio)" "/sys/bus/pci/devices/$pci_blk/uevent"; then + $spdkcli_job "'/bdevs/virtioblk_disk delete virtioblk_pci' 'virtioblk_pci'" +fi +if [ -n "$pci_scsi" ] && grep -Eq "DRIVER=(uio|vfio)" "/sys/bus/pci/devices/$pci_scsi/uevent"; then + $spdkcli_job "'/bdevs/virtioscsi_disk delete virtioscsi_pci' 'virtioscsi_pci'" +fi +$spdkcli_job "'/bdevs/malloc delete Malloc0' 'Malloc0' +'/bdevs/malloc delete Malloc1' 'Malloc1' +" +timing_exit spdkcli_clear_virtio_config + +killprocess $virtio_pid +killprocess $spdk_tgt_pid |