Add script files of test and spdk-ansible for SPDK 37/42737/8
authorheluwei <heluwei@huawei.com>
Fri, 22 Sep 2017 07:51:29 +0000 (15:51 +0800)
committerheluwei <heluwei@huawei.com>
Sat, 6 Jan 2018 12:48:16 +0000 (20:48 +0800)
The runtest.py file and the spdk-ansible are submitted. The runtest.py
file is used to execute the scripts of test to validate whether the
SPDK is available. The spdk-ansible is used to install SPDK by the
ansible tool.

Change-Id: I9eca7fb5cfcd2dcf718a0ef99d0ced5f962fd92a
Signed-off-by: heluwei <heluwei@huawei.com>
src/spdk/ansible/README.md [new file with mode: 0644]
src/spdk/ansible/group_vars/common.yml [new file with mode: 0644]
src/spdk/ansible/site.yml [new file with mode: 0644]
src/spdk/ansible/tasks/install.yml [new file with mode: 0644]
src/spdk/test/runtest.py [new file with mode: 0644]
src/spdk/test/unittest.sh [new file with mode: 0755]

diff --git a/src/spdk/ansible/README.md b/src/spdk/ansible/README.md
new file mode 100644 (file)
index 0000000..20299a7
--- /dev/null
@@ -0,0 +1,36 @@
+# spdk-ansible: deploy spdk
+## Install ssh server
+    sudo apt-get install openssh-server
+
+    if you use root to run spdk-ansible, you should open the file of
+    /etc/ssh/sshd_config and modify:
+    PermitRootLogin yes
+    sudo /etc/init.d/ssh restart
+
+    generate ssh-token:
+    ssh-keygen -t rsa
+    ssh-copy-id -i ~/.ssh/id_rsa.pub <romte_ip(eg: username@hostName or username@hostIp)>
+
+##  Install the ansible tool:
+    sudo add-apt-repository ppa:ansible/ansible
+    sudo apt-get update
+    sudo apt-get install ansible
+
+##  Configure Inventory, default in /etc/ansible/hosts:
+    [spdk_server]
+    your_host_name or your_host_ip
+
+##  Check if the hosts could be reached:
+    ansible all -m ping
+
+##  Download spdk-ansible
+    git clone https://github.com/hellowaywewe/spdk-ansible.git
+
+##  configure spdk-ansible
+    Configure common.yml according to required vars.
+    Configure site.yml according to required tasks.
+
+## Run ansible playbook: (under spdk-ansible root directory)
+    ansible-playbook site.yml  --extra-vars "ansible_sudo_pass=your_user_password"
+    if you use root to run,you can execute directly:
+    ansible-playbook site.yml
diff --git a/src/spdk/ansible/group_vars/common.yml b/src/spdk/ansible/group_vars/common.yml
new file mode 100644 (file)
index 0000000..bf72caf
--- /dev/null
@@ -0,0 +1,21 @@
+###########
+# GENERAL #
+###########
+
+
+remote_url: https://github.com/spdk/spdk.git
+
+user_dir: /home/wewe
+
+ceph_dir: /home/wewe/ceph
+
+# when SPDK is installed independently, set enabled_install: spdk_alone
+# if not, set enabled_install: ceph_spdk
+enabled_install: spdk_alone
+
+# when enabled_install == "spdk_alone",set spdk_dir: /home/<your_user_name>/spdk.
+# when enabled_install == "ceph_spdk",set spdk_dir: /home/<your_uesr_name>/ceph/src/spdk
+spdk_dir: /home/wewe/spdk
+
+#system_version include: Ubuntu, Debian, entos, Fedora, FreeBSD
+system_version: Ubuntu
diff --git a/src/spdk/ansible/site.yml b/src/spdk/ansible/site.yml
new file mode 100644 (file)
index 0000000..4742181
--- /dev/null
@@ -0,0 +1,11 @@
+---
+
+- name: install spdk
+  become: True
+  hosts: all
+  gather_facts: False
+  vars_files:
+    - group_vars/common.yml
+  tasks:
+    - include_tasks: tasks/install.yml
+
diff --git a/src/spdk/ansible/tasks/install.yml b/src/spdk/ansible/tasks/install.yml
new file mode 100644 (file)
index 0000000..7957ba8
--- /dev/null
@@ -0,0 +1,33 @@
+---
+- name: download spdk source code
+  shell: git clone "{{ remote_url }}"
+  args:
+    chdir: "{{ user_dir }}"
+  when: enabled_install == "spdk_alone"
+
+- name: download spdk source code into ceph
+  shell: git submodule update --init src/spdk
+  args:
+    chdir: "{{ ceph_dir }}"
+  when: enabled_install == "ceph_spdk"
+
+- name: Install the spdk dependency packages
+  shell: sudo ./scripts/pkgdep.sh
+  args:
+    chdir: "{{ spdk_dir }}"
+
+- name: Download dpdk
+  raw: cd {{ spdk_dir }} && sudo git submodule update --init
+
+### deploy spdk in Ubuntu, Debian, Centos, Fedora
+- name: deploy the spdk
+  raw: ((cd {{ spdk_dir }}/dpdk && make install T=x86_64-native-linuxapp-gcc DESTDIR=./) && (cd {{ spdk_dir }} && ./configure --with-dpdk=./dpdk/x86_64-native-linuxapp-gcc)) && (cd {{ spdk_dir }} && make)
+  when:
+    - (system_version == 'Ubuntu' or system_version == 'Debian') or (system_version == 'Centos' or system_version == 'Fedora')
+
+
+### deploy spdk in FreeBSD
+- name: deploy the spdk
+  raw: ((cd {{ spdk_dir }}/dpdk && gmake install T=x86_64-native-linuxapp-gcc DESTDIR=./) && (cd {{ spdk_dir }} && ./configure --with-dpdk=./dpdk/x86_64-native-linuxapp-gcc)) && (cd {{ spdk_dir }} && gmake)
+  when:
+    - system_version == 'FreeBSD'
diff --git a/src/spdk/test/runtest.py b/src/spdk/test/runtest.py
new file mode 100644 (file)
index 0000000..8020e76
--- /dev/null
@@ -0,0 +1,15 @@
+#! /usr/bin/env python
+
+import os
+import sys
+
+
+def run_test(test_path):
+    os.system(test_path)
+
+
+if __name__ == "__main__":
+    py_file = sys.argv[0]
+    py_path = os.path.abspath(os.path.dirname(py_file))
+    test_path = os.path.join(py_path, 'unittest.sh')
+    run_test(test_path)
diff --git a/src/spdk/test/unittest.sh b/src/spdk/test/unittest.sh
new file mode 100755 (executable)
index 0000000..7e4c8f0
--- /dev/null
@@ -0,0 +1,131 @@
+#!/usr/bin/env bash
+#
+# Environment variables:
+#  $valgrind    Specify the valgrind command line, if not
+#               then a default command line is used
+
+set -xe
+
+# if ASAN is enabled, use it.  If not use valgrind if installed but allow
+# the env variable to override the default shown below.
+if [ -z ${valgrind+x} ]; then
+       if grep -q '#undef SPDK_CONFIG_ASAN' config.h && hash valgrind; then
+               valgrind='valgrind --leak-check=full --error-exitcode=2'
+       else
+               valgrind=''
+       fi
+fi
+
+# setup local unit test coverage if cov is available
+if hash lcov && grep -q '#define SPDK_CONFIG_COVERAGE 1' config.h; then
+       cov_avail="yes"
+else
+       cov_avail="no"
+fi
+if [ "$cov_avail" = "yes" ]; then
+       # set unit test output dir if not specified in env var
+       if [ -z ${UT_COVERAGE+x} ]; then
+               UT_COVERAGE="ut_coverage"
+       fi
+       mkdir -p $UT_COVERAGE
+       export LCOV_OPTS="
+               --rc lcov_branch_coverage=1
+               --rc lcov_function_coverage=1
+               --rc genhtml_branch_coverage=1
+               --rc genhtml_function_coverage=1
+               --rc genhtml_legend=1
+               --rc geninfo_all_blocks=1
+               "
+       export LCOV="lcov $LCOV_OPTS --no-external"
+       # zero out coverage data
+       $LCOV -q -c -i -d . -t "Baseline" -o $UT_COVERAGE/ut_cov_base.info
+fi
+
+$valgrind test/unit/lib/bdev/bdev.c/bdev_ut
+$valgrind test/unit/lib/bdev/scsi_nvme.c/scsi_nvme_ut
+$valgrind test/unit/lib/bdev/gpt/gpt.c/gpt_ut
+
+$valgrind test/unit/lib/blob/blob.c/blob_ut
+$valgrind test/unit/lib/blobfs/tree.c/tree_ut
+
+$valgrind test/lib/blobfs/blobfs_async_ut/blobfs_async_ut
+# blobfs_sync_ut hangs when run under valgrind, so don't use $valgrind
+test/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut
+
+$valgrind test/unit/lib/nvme/nvme.c/nvme_ut
+$valgrind test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut
+$valgrind test/unit/lib/nvme/nvme_ctrlr_cmd.c/nvme_ctrlr_cmd_ut
+$valgrind test/unit/lib/nvme/nvme_ns.c/nvme_ns_ut
+$valgrind test/unit/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut
+$valgrind test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut
+$valgrind test/unit/lib/nvme/nvme_pcie.c/nvme_pcie_ut
+$valgrind test/unit/lib/nvme/nvme_quirks.c/nvme_quirks_ut
+
+$valgrind test/unit/lib/ioat/ioat.c/ioat_ut
+
+$valgrind test/unit/lib/json/json_parse.c/json_parse_ut
+$valgrind test/unit/lib/json/json_util.c/json_util_ut
+$valgrind test/unit/lib/json/json_write.c/json_write_ut
+
+$valgrind test/unit/lib/jsonrpc/jsonrpc_server.c/jsonrpc_server_ut
+
+$valgrind test/unit/lib/log/log.c/log_ut
+
+$valgrind test/unit/lib/nvmf/ctrlr.c/ctrlr_ut
+$valgrind test/unit/lib/nvmf/ctrlr_bdev.c/ctrlr_bdev_ut
+$valgrind test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut
+$valgrind test/unit/lib/nvmf/request.c/request_ut
+$valgrind test/unit/lib/nvmf/subsystem.c/subsystem_ut
+
+$valgrind test/unit/lib/scsi/dev.c/dev_ut
+$valgrind test/unit/lib/scsi/lun.c/lun_ut
+$valgrind test/unit/lib/scsi/scsi.c/scsi_ut
+$valgrind test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut
+
+$valgrind test/unit/lib/iscsi/param.c/param_ut
+$valgrind test/unit/lib/iscsi/tgt_node.c/tgt_node_ut test/unit/lib/iscsi/tgt_node.c/tgt_node.conf
+$valgrind test/unit/lib/iscsi/iscsi.c/iscsi_ut
+
+$valgrind test/unit/lib/util/bit_array.c/bit_array_ut
+$valgrind test/unit/lib/util/crc32_ieee.c/crc32_ieee_ut
+$valgrind test/unit/lib/util/crc32c.c/crc32c_ut
+$valgrind test/unit/lib/util/io_channel.c/io_channel_ut
+$valgrind test/unit/lib/util/string.c/string_ut
+
+if [ $(uname -s) = Linux ]; then
+$valgrind test/unit/lib/vhost/vhost.c/vhost_ut
+fi
+
+# local unit test coverage
+if [ "$cov_avail" = "yes" ]; then
+       $LCOV -q -d . -c -t "$(hostname)" -o $UT_COVERAGE/ut_cov_test.info
+       $LCOV -q -a $UT_COVERAGE/ut_cov_base.info -a $UT_COVERAGE/ut_cov_test.info -o $UT_COVERAGE/ut_cov_total.info
+       $LCOV -q -a $UT_COVERAGE/ut_cov_total.info -o $UT_COVERAGE/ut_cov_unit.info
+       $LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'app/*' -o $UT_COVERAGE/ut_cov_unit.info
+       $LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'examples/*' -o $UT_COVERAGE/ut_cov_unit.info
+       $LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'include/*' -o $UT_COVERAGE/ut_cov_unit.info
+       $LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'lib/vhost/rte_vhost/*' -o $UT_COVERAGE/ut_cov_unit.info
+       $LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'test/*' -o $UT_COVERAGE/ut_cov_unit.info
+       rm -f $UT_COVERAGE/ut_cov_base.info $UT_COVERAGE/ut_cov_test.info
+       genhtml $UT_COVERAGE/ut_cov_unit.info --output-directory $UT_COVERAGE
+       git clean -f "*.gcda"
+fi
+
+set +x
+
+echo
+echo
+echo "====================="
+echo "All unit tests passed"
+echo "====================="
+if [ "$cov_avail" = "yes" ]; then
+       echo "Note: coverage report is here: ./$UT_COVERAGE"
+else
+       echo "WARN: lcov not installed or SPDK built without coverage!"
+fi
+if grep -q '#undef SPDK_CONFIG_ASAN' config.h && [ "$valgrind" = "" ]; then
+       echo "WARN: neither valgrind nor ASAN is enabled!"
+fi
+
+echo
+echo