diff options
Diffstat (limited to 'src/spdk/test/spdkcli')
-rw-r--r-- | src/spdk/test/spdkcli/common.sh | 26 | ||||
-rwxr-xr-x | src/spdk/test/spdkcli/iscsi.sh | 60 | ||||
-rw-r--r-- | src/spdk/test/spdkcli/match_files/spdkcli_details_vhost.test.match | 28 | ||||
-rw-r--r-- | src/spdk/test/spdkcli/match_files/spdkcli_iscsi.test.match | 53 | ||||
-rw-r--r-- | src/spdk/test/spdkcli/match_files/spdkcli_nvmf.test.match | 32 | ||||
-rw-r--r-- | src/spdk/test/spdkcli/match_files/spdkcli_pmem.test.match | 2 | ||||
-rw-r--r-- | src/spdk/test/spdkcli/match_files/spdkcli_rbd.test.match | 2 | ||||
-rw-r--r-- | src/spdk/test/spdkcli/match_files/spdkcli_vhost.test.match | 75 | ||||
-rw-r--r-- | src/spdk/test/spdkcli/match_files/spdkcli_virtio_pci.test.match | 18 | ||||
-rw-r--r-- | src/spdk/test/spdkcli/match_files/spdkcli_virtio_user.test.match | 8 | ||||
-rwxr-xr-x | src/spdk/test/spdkcli/nvmf.sh | 83 | ||||
-rwxr-xr-x | src/spdk/test/spdkcli/pmem.sh | 33 | ||||
-rwxr-xr-x | src/spdk/test/spdkcli/rbd.sh | 34 | ||||
-rwxr-xr-x | src/spdk/test/spdkcli/spdkcli_job.py | 38 | ||||
-rwxr-xr-x | src/spdk/test/spdkcli/vhost.sh | 106 | ||||
-rwxr-xr-x | src/spdk/test/spdkcli/virtio.sh | 74 |
16 files changed, 672 insertions, 0 deletions
diff --git a/src/spdk/test/spdkcli/common.sh b/src/spdk/test/spdkcli/common.sh new file mode 100644 index 00000000..80ea6ab1 --- /dev/null +++ b/src/spdk/test/spdkcli/common.sh @@ -0,0 +1,26 @@ +set -xe + +testdir=$(readlink -f $(dirname $0)) +SPDKCLI_BUILD_DIR=$(readlink -f $testdir/../..) +spdkcli_job="$SPDKCLI_BUILD_DIR/test/spdkcli/spdkcli_job.py" +. $SPDKCLI_BUILD_DIR/test/common/autotest_common.sh + +function on_error_exit() { + set +e + killprocess $spdk_tgt_pid + 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() { + $SPDKCLI_BUILD_DIR/app/spdk_tgt/spdk_tgt -m 0x3 -p 0 -s 4096 & + spdk_tgt_pid=$! + waitforlisten $spdk_tgt_pid +} + +function check_match() { + $SPDKCLI_BUILD_DIR/scripts/spdkcli.py ll $SPDKCLI_BRANCH > $testdir/match_files/${MATCH_FILE} + $SPDKCLI_BUILD_DIR/test/app/match/match -v $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 00000000..e33aba85 --- /dev/null +++ b/src/spdk/test/spdkcli/iscsi.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +set -xe + +MATCH_FILE="spdkcli_iscsi.test" +SPDKCLI_BRANCH="/iscsi" +testdir=$(readlink -f $(dirname $0)) +. $testdir/common.sh +. $testdir/../iscsi_tgt/common.sh + +timing_enter spdkcli_iscsi +trap 'on_error_exit;' ERR + +timing_enter run_spdk_tgt +run_spdk_tgt +timing_exit run_spdk_tgt + +timing_enter spdkcli_create_iscsi_config +$spdkcli_job "/bdevs/malloc create 32 512 Malloc0" "Malloc0" True +$spdkcli_job "/bdevs/malloc create 32 512 Malloc1" "Malloc1" True +$spdkcli_job "/bdevs/malloc create 32 512 Malloc2" "Malloc2" True +$spdkcli_job "/bdevs/malloc create 32 512 Malloc3" "Malloc3" True +$spdkcli_job "/iscsi/portal_groups create 1 \"127.0.0.1:3261 127.0.0.1:3263@0x1\"" "host=127.0.0.1, port=3261" True +$spdkcli_job "/iscsi/portal_groups create 2 127.0.0.1:3262" "host=127.0.0.1, port=3262" True +$spdkcli_job "/iscsi/initiator_groups create 2 ANY 10.0.2.15/32" "hostname=ANY, netmask=10.0.2.15/32" True +$spdkcli_job "/iscsi/initiator_groups create 3 ANZ 10.0.2.15/32" "hostname=ANZ, netmask=10.0.2.15/32" True +$spdkcli_job "/iscsi/initiator_groups add_initiator 2 ANW 10.0.2.16/32" "hostname=ANW, netmask=10.0.2.16" True +$spdkcli_job "/iscsi/target_nodes create Target0 Target0_alias \"Malloc0:0 Malloc1:1\" 1:2 64 g=1" "Target0" True +$spdkcli_job "/iscsi/target_nodes create Target1 Target1_alias Malloc2:0 1:2 64 g=1" "Target1" True +$spdkcli_job "/iscsi/target_nodes/iqn.2016-06.io.spdk:Target0 add_pg_ig_maps \"1:3 2:2\"" "portal_group1 - initiator_group3" True +$spdkcli_job "/iscsi/target_nodes add_lun iqn.2016-06.io.spdk:Target1 Malloc3 2" "Malloc3" True +$spdkcli_job "/iscsi/auth_groups create 1 \"user:test secret:test muser:mutual_test msecret:mutual_test \ +user:test3 secret:test3 muser:mutual_test3 msecret:mutual_test3\"" "user=test3" True +$spdkcli_job "/iscsi/auth_groups add_secret 1 user=test2 secret=test2 muser=mutual_test2 msecret=mutual_test2" "user=test2" True +$spdkcli_job "/iscsi/target_nodes/iqn.2016-06.io.spdk:Target0 set_auth g=1 d=true" "disable_chap: True" True +$spdkcli_job "/iscsi/global_params set_auth g=1 d=true r=false" "disable_chap: True" True +$spdkcli_job "/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" +$spdkcli_job "/iscsi/auth_groups delete 1" "user=test" +$spdkcli_job "/iscsi/target_nodes/iqn.2016-06.io.spdk:Target0 delete_pg_ig_maps \"1:3 2:2\"" "portal_group1 - initiator_group3" +$spdkcli_job "/iscsi/target_nodes delete iqn.2016-06.io.spdk:Target1" "Target1" +$spdkcli_job "/iscsi/target_nodes delete iqn.2016-06.io.spdk:Target0" "Target0" +$spdkcli_job "/iscsi/initiator_groups delete_initiator 2 ANW 10.0.2.16/32" "ANW" +$spdkcli_job "/iscsi/initiator_groups delete 3" "ANYZ" +$spdkcli_job "/iscsi/portal_groups delete 1" "127.0.0.1:3261" +$spdkcli_job "/bdevs/malloc delete Malloc3" "Malloc3" +$spdkcli_job "/bdevs/malloc delete Malloc2" "Malloc2" +$spdkcli_job "/bdevs/malloc delete Malloc1" "Malloc1" +$spdkcli_job "/bdevs/malloc delete Malloc0" "Malloc0" +timing_exit spdkcli_clear_iscsi_config + +killprocess $spdk_tgt_pid +timing_exit spdkcli_iscsi +report_test_completion spdk_cli 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 00000000..8cbd9e80 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_details_vhost.test.match @@ -0,0 +1,28 @@ +{ + "aliases": [], + "assigned_rate_limits": { + "rw_ios_per_sec": $(N), + "rw_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) + } +} 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 00000000..e48d8d98 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_iscsi.test.match @@ -0,0 +1,53 @@ +o- iscsi ..................................................................................................................... [...] + o- auth_groups ....................................................................................................... [Groups: 1] + | o- group1 ......................................................................................................... [Secrets: 2] + | o- user=test2, secret=test2, muser=mutual_test2, msecret=mutual_test2 .................................................. [...] + | o- user=test3, secret=test3, muser=mutual_test3, msecret=mutual_test3 .................................................. [...] + 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- min_connections_per_core: 4 ........................................................................................... [...] + | 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, cpumask=0x3 .............................................................................. [...] + | | o- host=127.0.0.1, port=3263, cpumask=0x1 .............................................................................. [...] + | o- portal_group2 .................................................................................................. [Portals: 1] + | o- host=127.0.0.1, port=3262, cpumask=0x3 .............................................................................. [...] + 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 00000000..95b36f64 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_nvmf.test.match @@ -0,0 +1,32 @@ +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 .............................................................. [$(X)-$(X)-$(X)-$(X)-$(X), Malloc3, 1] + | o- Malloc4 .............................................................. [$(X)-$(X)-$(X)-$(X)-$(X), Malloc4, 2] + | o- Malloc5 .............................................................. [$(X)-$(X)-$(X)-$(X)-$(X), Malloc5, 3] + | o- Malloc6 .............................................................. [$(X)-$(X)-$(X)-$(X)-$(X), 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 .............................................................. [$(X)-$(X)-$(X)-$(X)-$(X), 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 .............................................................. [$(X)-$(X)-$(X)-$(X)-$(X), Malloc1, 1] 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 00000000..0ee659b5 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_pmem.test.match @@ -0,0 +1,2 @@ +o- pmemblk .............................................................................................................. [Bdevs: 1] + o- pmem_bdev ........................................................................................... [Size=31.6M, Not claimed] 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 00000000..ea748e90 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_rbd.test.match @@ -0,0 +1,2 @@ +o- rbd .................................................................................................................. [Bdevs: 1] + o- Ceph0 ............................................................................................. [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 00000000..a1ed8dc7 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_vhost.test.match @@ -0,0 +1,75 @@ +o- / ......................................................................................................................... [...] + o- bdevs ................................................................................................................... [...] + | o- aio .............................................................................................................. [Bdevs: 1] + | | o- sample ........................................................................................... [Size=$(FP)M, Not claimed] + | o- error ............................................................................................................ [Bdevs: 1] + | | o- EE_Malloc1 ...................................................................................... [Size=$(FP)M, Not claimed] + | o- iscsi ............................................................................................................ [Bdevs: 0] + | o- logical_volume ................................................................................................... [Bdevs: 1] + | | o- $(X)-$(X)-$(X)-$(X)-$(X) .................................................. [lvs/lvol, Size=$(FP)M, Not claimed] + | o- malloc ........................................................................................................... [Bdevs: 4] + | | 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- null ............................................................................................................. [Bdevs: 1] + | | o- null_bdev ....................................................................................... [Size=$(FP)M, Not claimed] + | o- nvme ............................................................................................................. [Bdevs: 1] + | | o- Nvme0n1 $(S) [Size=$(FP)G, Claimed] + | o- pmemblk .......................................................................................................... [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- iscsi ................................................................................................................... [...] + | o- auth_groups ..................................................................................................... [Groups: 0] + | o- global_params ......................................................................................................... [...] + | | o- allow_duplicated_isid: False ........................................................................................ [...] + | | o- chap_group: 0 ....................................................................................................... [...] + | | o- default_time2retain: 20 ............................................................................................. [...] + | | o- default_time2wait: 2 ................................................................................................ [...] + | | o- disable_chap: False ................................................................................................. [...] + | | 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- min_connections_per_core: 4 ......................................................................................... [...] + | | 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: 0] + | o- iscsi_connections .......................................................................................... [Connections: 0] + | o- portal_groups ............................................................................................ [Portal groups: 0] + | o- target_nodes .............................................................................................. [Target nodes: 0] + o- lvol_stores .................................................................................................. [Lvol stores: 1] + | o- lvs ................................................................................................ [Size=$(FP)M, Free=$(FP)M] + o- nvmf .................................................................................................................... [...] + | o- subsystem ................................................................................................... [Subsystems: 1] + | o- nqn.2014-08.org.nvmexpress.discovery ....................................................... [st=Discovery, Allow any host] + | o- hosts ........................................................................................................ [Hosts: 0] + | o- listen_addresses ......................................................................................... [Addresses: 0] + 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 00000000..0eca06e1 --- /dev/null +++ b/src/spdk/test/spdkcli/match_files/spdkcli_virtio_pci.test.match @@ -0,0 +1,18 @@ +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- 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 00000000..157938e7 --- /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 00000000..cf592a4e --- /dev/null +++ b/src/spdk/test/spdkcli/nvmf.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +set -xe + +MATCH_FILE="spdkcli_nvmf.test" +SPDKCLI_BRANCH="/nvmf" +testdir=$(readlink -f $(dirname $0)) +. $testdir/common.sh +. $testdir/../nvmf/common.sh + +timing_enter spdkcli_nvmf +trap 'on_error_exit; revert_soft_roce' ERR +rdma_device_init + +timing_enter run_spdk_tgt +run_spdk_tgt +timing_exit run_spdk_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 +$spdkcli_job "/bdevs/malloc create 32 512 Malloc2" "Malloc2" True +$spdkcli_job "/bdevs/malloc create 32 512 Malloc3" "Malloc3" True +$spdkcli_job "/bdevs/malloc create 32 512 Malloc4" "Malloc4" True +$spdkcli_job "/bdevs/malloc create 32 512 Malloc5" "Malloc5" True +$spdkcli_job "/bdevs/malloc create 32 512 Malloc6" "Malloc6" True +$spdkcli_job "/nvmf/subsystem create nqn.2014-08.org.spdk:cnode1 N37SXV509SRW\ + max_namespaces=4 allow_any_host=True" "nqn.2014-08.org.spdk:cnode1" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces create Malloc3 1" "Malloc3" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces create Malloc4 2" "Malloc4" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses create \ + RDMA $NVMF_TARGET_IP 4260 IPv4" "$NVMF_TARGET_IP:4260" True +$spdkcli_job "/nvmf/subsystem create nqn.2014-08.org.spdk:cnode2 N37SXV509SRD\ + max_namespaces=2 allow_any_host=True" "nqn.2014-08.org.spdk:cnode2" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode2/namespaces create Malloc2" "Malloc2" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode2/listen_addresses create \ + RDMA $NVMF_TARGET_IP 4260 IPv4" "$NVMF_TARGET_IP:4260" True +$spdkcli_job "/nvmf/subsystem create nqn.2014-08.org.spdk:cnode3 N37SXV509SRR\ + max_namespaces=2 allow_any_host=True" "nqn.2014-08.org.spdk:cnode2" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/namespaces create Malloc1" "Malloc1" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/listen_addresses create \ + RDMA $NVMF_TARGET_IP 4260 IPv4" "$NVMF_TARGET_IP:4260" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/listen_addresses create \ + RDMA $NVMF_TARGET_IP 4261 IPv4" "$NVMF_TARGET_IP:4261" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/hosts create \ + nqn.2014-08.org.spdk:cnode1" "nqn.2014-08.org.spdk:cnode1" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/hosts create \ + nqn.2014-08.org.spdk:cnode2" "nqn.2014-08.org.spdk:cnode2" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1 allow_any_host True" "Allow any host" +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1 allow_any_host False" "Allow any host" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses create RDMA $NVMF_TARGET_IP 4261 IPv4" "$NVMF_TARGET_IP:4261" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses create RDMA $NVMF_TARGET_IP 4262 IPv4" "$NVMF_TARGET_IP:4262" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/hosts create nqn.2014-08.org.spdk:cnode2" "nqn.2014-08.org.spdk:cnode2" True +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces create Malloc5" "Malloc5" True +$spdkcli_job "/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" +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces delete nsid=2" "Malloc4" +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/hosts delete nqn.2014-08.org.spdk:cnode2" "nqn.2014-08.org.spdk:cnode2" +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses delete RDMA $NVMF_TARGET_IP 4262" "$NVMF_TARGET_IP:4262" +$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses delete RDMA $NVMF_TARGET_IP 4261" "$NVMF_TARGET_IP:4261" +$spdkcli_job "/nvmf/subsystem delete nqn.2014-08.org.spdk:cnode3" "nqn.2014-08.org.spdk:cnode3" +$spdkcli_job "/nvmf/subsystem delete nqn.2014-08.org.spdk:cnode2" "nqn.2014-08.org.spdk:cnode2" +$spdkcli_job "/nvmf/subsystem delete nqn.2014-08.org.spdk:cnode1" "nqn.2014-08.org.spdk:cnode1" +$spdkcli_job "/bdevs/malloc delete Malloc6" "Malloc6" +$spdkcli_job "/bdevs/malloc delete Malloc5" "Malloc5" +$spdkcli_job "/bdevs/malloc delete Malloc4" "Malloc4" +$spdkcli_job "/bdevs/malloc delete Malloc3" "Malloc3" +$spdkcli_job "/bdevs/malloc delete Malloc2" "Malloc2" +$spdkcli_job "/bdevs/malloc delete Malloc1" "Malloc1" +timing_exit spdkcli_clear_nvmf_config + +killprocess $spdk_tgt_pid +#revert_soft_roce +timing_exit spdkcli_nvmf +report_test_completion spdk_cli_nvmf diff --git a/src/spdk/test/spdkcli/pmem.sh b/src/spdk/test/spdkcli/pmem.sh new file mode 100755 index 00000000..bdac1873 --- /dev/null +++ b/src/spdk/test/spdkcli/pmem.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -xe + +MATCH_FILE="spdkcli_pmem.test" +SPDKCLI_BRANCH="/bdevs/pmemblk" +testdir=$(readlink -f $(dirname $0)) +. $testdir/common.sh + +timing_enter spdkcli_pmem +trap '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 create_pmem_pool /tmp/sample_pmem 32 512" "" True +$spdkcli_job "/bdevs/pmemblk create /tmp/sample_pmem pmem_bdev" "pmem_bdev" True +timing_exit spdkcli_create_pmem_config + +timing_enter spdkcli_check_match +check_match +timing_exit spdkcli_check_match + +timing_enter spdkcli_clear_pmem_config +$spdkcli_job "/bdevs/pmemblk delete pmem_bdev" "pmem_bdev" +$spdkcli_job "/bdevs/pmemblk delete_pmem_pool /tmp/sample_pmem" "" +rm -f /tmp/sample_pmem +timing_exit spdkcli_clear_pmem_config + +killprocess $spdk_tgt_pid +timing_exit spdkcli_pmem +report_test_completion spdk_cli diff --git a/src/spdk/test/spdkcli/rbd.sh b/src/spdk/test/spdkcli/rbd.sh new file mode 100755 index 00000000..352d0645 --- /dev/null +++ b/src/spdk/test/spdkcli/rbd.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set -xe + +MATCH_FILE="spdkcli_rbd.test" +SPDKCLI_BRANCH="/bdevs/rbd" +testdir=$(readlink -f $(dirname $0)) +. $testdir/common.sh + +timing_enter spdk_cli_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 +rootdir=$(readlink -f $SPDKCLI_BUILD_DIR) +rbd_setup 127.0.0.1 +$spdkcli_job "/bdevs/rbd create rbd foo 512" "Ceph0" 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" +rbd_cleanup +timing_exit spdkcli_clear_rbd_config + +killprocess $spdk_tgt_pid + +timing_exit spdk_cli_rbd +report_test_completion spdk_cli_rbd diff --git a/src/spdk/test/spdkcli/spdkcli_job.py b/src/spdk/test/spdkcli/spdkcli_job.py new file mode 100755 index 00000000..a2677f6a --- /dev/null +++ b/src/spdk/test/spdkcli/spdkcli_job.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +import pexpect +import os +import sys + + +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("/>") + print("child: %s" % child.before.decode()) + if element_exists: + if element not in child.before.decode(): + print("Element %s not in list" % element) + exit(1) + else: + if element in child.before.decode(): + print("Element %s is in list" % element) + exit(1) + + +if __name__ == "__main__": + socket = "/var/tmp/spdk.sock" + if len(sys.argv) == 5: + socket = sys.argv[4] + testdir = os.path.dirname(os.path.realpath(sys.argv[0])) + child = pexpect.spawn(os.path.join(testdir, "../../scripts/spdkcli.py") + " -s %s" % socket) + child.expect(">") + child.sendline("cd /") + child.expect("/>") + + execute_command(*sys.argv[1:4]) diff --git a/src/spdk/test/spdkcli/vhost.sh b/src/spdk/test/spdkcli/vhost.sh new file mode 100755 index 00000000..c479857e --- /dev/null +++ b/src/spdk/test/spdkcli/vhost.sh @@ -0,0 +1,106 @@ +#!/usr/bin/env bash +set -xe + +MATCH_FILE="spdkcli_vhost.test" +SPDKCLI_BRANCH="/" +testdir=$(readlink -f $(dirname $0)) +. $testdir/../json_config/common.sh +. $testdir/common.sh + +timing_enter spdk_cli_vhost +trap 'on_error_exit' ERR +timing_enter run_spdk_tgt +run_spdk_tgt +timing_exit run_spdk_tgt + +timing_enter spdkcli_create_bdevs_config +$spdkcli_job "/bdevs/malloc create 32 512 Malloc0" "Malloc0" True +$spdkcli_job "/bdevs/malloc create 32 512 Malloc1" "Malloc1" True +$spdkcli_job "/bdevs/malloc create 32 512 Malloc2" "Malloc2" True +$spdkcli_job "/bdevs/malloc create 32 4096 Malloc3" "Malloc3" True +$spdkcli_job "/bdevs/error create Malloc1" "EE_Malloc1" True +$spdkcli_job "/bdevs/null create null_bdev 32 512" "null_bdev" True +dd if=/dev/zero of=/tmp/sample_aio bs=2048 count=5000 +$spdkcli_job "/bdevs/aio create sample /tmp/sample_aio 512" "sample" True +trtype=$($SPDKCLI_BUILD_DIR/scripts/gen_nvme.sh --json | jq -r '.config[].params | select(.name=="Nvme0").trtype') +traddr=$($SPDKCLI_BUILD_DIR/scripts/gen_nvme.sh --json | jq -r '.config[].params | select(.name=="Nvme0").traddr') +$spdkcli_job "/bdevs/nvme create Nvme0 $trtype $traddr" "Nvme0" True +$spdkcli_job "/bdevs/split_disk split_bdev Nvme0n1 4" "Nvme0n1p0" True +timing_exit spdkcli_create_bdevs_config + +timing_enter spdkcli_create_lvols_config +$spdkcli_job "/lvol_stores create lvs Malloc0" "lvs" True +$spdkcli_job "/bdevs/logical_volume create lvol 16 lvs" "lvs/lvol" True +timing_exit spdkcli_create_lvols_config + +timing_enter spdkcli_create_vhosts_config +$spdkcli_job "vhost/block create vhost_blk1 Nvme0n1p0" "Nvme0n1p0" True +$spdkcli_job "vhost/block create vhost_blk2 Nvme0n1p1 0x2 readonly" "Nvme0n1p1" True +$spdkcli_job "vhost/scsi create vhost_scsi1" "vhost_scsi1" True +$spdkcli_job "vhost/scsi create vhost_scsi2" "vhost_scsi2" True +$spdkcli_job "vhost/scsi/vhost_scsi1 add_lun 0 Malloc2" "Malloc2" True +$spdkcli_job "vhost/scsi/vhost_scsi2 add_lun 0 Malloc3" "Malloc3" True +$spdkcli_job "vhost/scsi/vhost_scsi2 add_lun 1 Nvme0n1p2" "Nvme0n1p2" True +$spdkcli_job "vhost/scsi/vhost_scsi2 add_lun 2 Nvme0n1p3" "Nvme0n1p3" 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" +$spdkcli_job "save_subsystem_config $testdir/config_bdev.json bdev" +$spdkcli_job "save_subsystem_config $testdir/config_vhost.json vhost" +timing_exit spdkcli_save_config + +timing_enter spdkcli_check_match_details +$SPDKCLI_BUILD_DIR/scripts/spdkcli.py bdevs/split_disk/Nvme0n1p0 show_details | jq -r -S '.' > $testdir/match_files/spdkcli_details_vhost.test +$SPDKCLI_BUILD_DIR/test/app/match/match -v $testdir/match_files/spdkcli_details_vhost.test.match +rm -f $testdir/match_files/spdkcli_details_vhost.test +timing_exit spdkcli_check_match_details + +timing_enter spdkcli_clear_config +$spdkcli_job "vhost/scsi/vhost_scsi2 remove_target 2" "Nvme0n1p3" +$spdkcli_job "vhost/scsi/vhost_scsi2 remove_target 1" "Nvme0n1p2" +$spdkcli_job "vhost/scsi/vhost_scsi2 remove_target 0" "Malloc3" +$spdkcli_job "vhost/scsi/vhost_scsi1 remove_target 0" "Malloc2" +$spdkcli_job "vhost/scsi delete vhost_scsi2" "vhost_scsi2" +$spdkcli_job "vhost/scsi delete vhost_scsi1" "vhost_scsi1" +$spdkcli_job "vhost/block delete vhost_blk2" "vhost_blk2" +$spdkcli_job "vhost/block delete vhost_blk1" "vhost_blk1" +$spdkcli_job "/bdevs/split_disk destruct_split_bdev Nvme0n1" "Nvme0n1p0" +$spdkcli_job "/bdevs/aio delete sample" "sample" +$spdkcli_job "/bdevs/nvme delete Nvme0" "Nvme0" +$spdkcli_job "/bdevs/null delete null_bdev" "null_bdev" +$spdkcli_job "/bdevs/logical_volume delete lvs/lvol" "lvs/lvol" +$spdkcli_job "/lvol_stores delete lvs" "lvs" +$spdkcli_job "/bdevs/malloc delete Malloc0" "Malloc0" +$spdkcli_job "/bdevs/malloc delete Malloc1" "Malloc1" +$spdkcli_job "/bdevs/malloc delete Malloc2" "Malloc2" +$spdkcli_job "/bdevs/malloc delete Malloc3" "Malloc3" +timing_exit spdkcli_clear_config + +timing_enter spdkcli_load_config +$spdkcli_job "load_config $testdir/config.json" +$spdkcli_job "/lvol_stores create lvs Malloc0" "lvs" True +$spdkcli_job "/bdevs/logical_volume create lvol 16 lvs" "lvs/lvol" 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" +$spdkcli_job "load_subsystem_config $testdir/config_vhost.json" +$spdkcli_job "/lvol_stores create lvs Malloc0" "lvs" True +$spdkcli_job "/bdevs/logical_volume create lvol 16 lvs" "lvs/lvol" True +check_match +rm -f $testdir/config.json +rm -f $testdir/config_bdev.json +rm -f $testdir/config_vhost.json +rm -f /tmp/sample_aio +timing_exit spdkcli_load_config + +killprocess $spdk_tgt_pid + +timing_exit spdk_cli_vhost +report_test_completion spdk_cli_vhost diff --git a/src/spdk/test/spdkcli/virtio.sh b/src/spdk/test/spdkcli/virtio.sh new file mode 100755 index 00000000..fd8260be --- /dev/null +++ b/src/spdk/test/spdkcli/virtio.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +set -xe + +testdir=$(readlink -f $(dirname $0)) +. $testdir/common.sh + +trap 'killprocess $virtio_pid; on_error_exit' ERR +timing_enter spdk_cli_vhost + +timing_enter run_spdk_tgt +run_spdk_tgt +timing_exit run_spdk_tgt + +timing_enter run_spdk_virtio +$SPDKCLI_BUILD_DIR/app/spdk_tgt/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 +$spdkcli_job "/bdevs/malloc create 32 512 Malloc1" "Malloc1" True +pci_blk=$(lspci -nn -D | grep '1af4:1001' | head -1 | awk '{print $1;}') +if [ ! -z $pci_blk ]; 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 [ ! -z $pci_scsi ]; 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 +$spdkcli_job "/vhost/scsi/sample_scsi add_lun 0 Malloc0" "Malloc0" True +$spdkcli_job "/vhost/block create sample_block Malloc1" "Malloc1" True +timing_exit spdkcli_create_virtio_pci_config + +timing_enter spdkcli_check_match +if [ ! -z $pci_blk ] && [ ! -z $pci_scsi ]; then + MATCH_FILE="spdkcli_virtio_pci.test" + SPDKCLI_BRANCH="/bdevs" + check_match +fi +timing_exit spdkcli_check_match + +timing_exit spdkcli_create_virtio_user_config +$spdkcli_job "/bdevs/virtioblk_disk create virtioblk_user user $testdir/../../sample_block" "virtioblk_user" True "/var/tmp/virtio.sock" +$spdkcli_job "/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 +MATCH_FILE="spdkcli_virtio_user.test" +SPDKCLI_BRANCH="/vhost" +check_match +timing_exit spdkcli_check_match + +timing_enter spdkcli_clear_virtio_config +$spdkcli_job "/bdevs/virtioscsi_disk delete virtioscsi_user" "" False "/var/tmp/virtio.sock" +$spdkcli_job "/bdevs/virtioblk_disk delete virtioblk_user" "" False "/var/tmp/virtio.sock" +$spdkcli_job "/vhost/block delete sample_block" "sample_block" +$spdkcli_job "/vhost/scsi/sample_scsi remove_target 0" "Malloc0" +$spdkcli_job "/vhost/scsi delete sample_scsi" " sample_scsi" +if [ ! -z $pci_blk ]; then + $spdkcli_job "/bdevs/virtioblk_disk delete virtioblk_pci" "virtioblk_pci" +fi +if [ ! -z $pci_scsi ]; then + $spdkcli_job "/bdevs/virtioscsi_disk delete virtioscsi_pci" "virtioscsi_pci" +fi +$spdkcli_job "/bdevs/malloc delete Malloc0" "Malloc0" +$spdkcli_job "/bdevs/malloc delete Malloc1" "Malloc1" +timing_exit spdkcli_clear_virtio_config + +killprocess $virtio_pid +killprocess $spdk_tgt_pid + +timing_exit spdk_cli_vhost |