aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/ci/clean_images.sh15
-rwxr-xr-xtests/ci/load_images.sh63
-rwxr-xr-xtests/ci/prepare_env.sh10
-rwxr-xr-xtests/ci/prepare_storperf_admin-rc.sh5
-rw-r--r--tests/ci/requirements.txt79
-rw-r--r--tests/ci/scp_storperf_admin-rc.sh11
-rwxr-xr-xtests/ci/yardstick-verify12
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc001.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc005.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc007.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc009.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc010.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc011.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc012.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc014.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc020.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc021.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc038.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc069.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc070.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc071.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc072.yaml2
-rw-r--r--tests/opnfv/test_suites/opnfv_components.yaml16
-rw-r--r--tests/opnfv/test_suites/opnfv_features.yaml52
-rw-r--r--tests/opnfv/test_suites/opnfv_performance.yaml62
-rw-r--r--tests/opnfv/test_suites/opnfv_smoke.yaml14
-rw-r--r--tests/unit/api/utils/test_common.py65
-rw-r--r--tests/unit/api/utils/test_influx.py82
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vsperf.py10
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_storperf.py4
-rw-r--r--tests/unit/cmd/commands/test_env.py29
-rw-r--r--tests/unit/common/test_httpClient.py33
-rw-r--r--tests/unit/common/test_openstack_utils.py41
-rw-r--r--tests/unit/test_ssh.py105
37 files changed, 595 insertions, 157 deletions
diff --git a/tests/ci/clean_images.sh b/tests/ci/clean_images.sh
index 05f68a7ed..fa4a54df6 100755
--- a/tests/ci/clean_images.sh
+++ b/tests/ci/clean_images.sh
@@ -15,15 +15,22 @@ cleanup()
echo
echo "========== Cleanup =========="
- if ! glance image-list; then
+ if ! openstack image list; then
return
fi
- for image in $(glance image-list | grep -e cirros-0.3.3 -e yardstick-trusty-server -e Ubuntu-14.04 \
+ for image in $(openstack image list | grep -e cirros-0.3.3 -e yardstick-image -e Ubuntu-14.04 \
-e yardstick-vivid-kernel | awk '{print $2}'); do
echo "Deleting image $image..."
- glance image-delete $image || true
+ openstack image delete $image || true
done
- nova flavor-delete yardstick-flavor &> /dev/null || true
+ openstack flavor delete yardstick-flavor &> /dev/null || true
}
+
+main()
+{
+ cleanup
+}
+
+main
diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh
index 49b972777..e1d717749 100755
--- a/tests/ci/load_images.sh
+++ b/tests/ci/load_images.sh
@@ -12,6 +12,18 @@
set -e
+YARD_IMG_ARCH=amd64
+export YARD_IMG_ARCH
+
+if ! grep -q "Defaults env_keep += \"YARD_IMG_ARCH\"" "/etc/sudoers"; then
+ sudo echo "Defaults env_keep += \"YARD_IMG_ARCH YARDSTICK_REPO_DIR\"" >> /etc/sudoers
+fi
+
+ARCH_SCRIPT="test -f /etc/fuel_openstack_arch && grep -q arm64 /etc/fuel_openstack_arch"
+if [ "$INSTALLER_TYPE" == "fuel" ]; then
+ sshpass -p r00tme ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root $INSTALLER_IP "${ARCH_SCRIPT}" && YARD_IMG_ARCH=arm64
+fi
+
UCA_HOST="cloud-images.ubuntu.com"
if [ $YARD_IMG_ARCH = "arm64" ]; then
export VIVID_IMG_URL="http://${UCA_HOST}/vivid/current/vivid-server-cloudimg-arm64.tar.gz"
@@ -63,11 +75,12 @@ load_yardstick_image()
if [ ! -f $VIVID_KERNEL ]; then
tar zxf $VIVID_IMAGE $(basename $VIVID_KERNEL)
fi
- create_vivid_kernel=$(glance --os-image-api-version 1 image-create \
- --name yardstick-vivid-kernel \
- --is-public true --disk-format qcow2 \
+ create_vivid_kernel=$(openstack image create \
+ --public \
+ --disk-format qcow2 \
--container-format bare \
- --file $VIVID_KERNEL)
+ --file $VIVID_KERNEL \
+ yardstick-vivid-kernel)
GLANCE_KERNEL_ID=$(echo "$create_vivid_kernel" | grep " id " | awk '{print $(NF-1)}')
if [ -z "$GLANCE_KERNEL_ID" ]; then
@@ -89,19 +102,21 @@ load_yardstick_image()
fi
if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
- output=$(eval glance --os-image-api-version 1 image-create \
- --name yardstick-trusty-server \
- --is-public true --disk-format root-tar \
+ output=$(eval openstack image create \
+ --public \
+ --disk-format root-tar \
--container-format bare \
$EXTRA_PARAMS \
- --file $RAW_IMAGE)
+ --file $RAW_IMAGE \
+ yardstick-image)
else
- output=$(eval glance --os-image-api-version 1 image-create \
- --name yardstick-trusty-server \
- --is-public true --disk-format qcow2 \
+ output=$(eval openstack image create \
+ --public \
+ --disk-format qcow2 \
--container-format bare \
$EXTRA_PARAMS \
- --file $QCOW_IMAGE)
+ --file $QCOW_IMAGE \
+ yardstick-image)
fi
echo "$output"
@@ -135,12 +150,12 @@ load_cirros_image()
EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
fi
- output=$(glance image-create \
- --name cirros-0.3.3 \
+ output=$(openstack image create \
--disk-format qcow2 \
--container-format bare \
$EXTRA_PARAMS \
- --file $image_file)
+ --file $image_file \
+ cirros-0.3.3)
echo "$output"
CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
@@ -165,12 +180,12 @@ load_ubuntu_image()
EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
fi
- output=$(glance image-create \
- --name Ubuntu-14.04 \
+ output=$(openstack image create \
--disk-format qcow2 \
--container-format bare \
$EXTRA_PARAMS \
- --file $ubuntu_image_file)
+ --file $ubuntu_image_file \
+ Ubuntu-14.04)
echo "$output"
UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
@@ -185,26 +200,26 @@ load_ubuntu_image()
create_nova_flavor()
{
- if ! nova flavor-list | grep -q yardstick-flavor; then
+ if ! openstack flavor list | grep -q yardstick-flavor; then
echo
echo "========== Create nova flavor =========="
# Create the nova flavor used by some sample test cases
- nova flavor-create yardstick-flavor 100 512 3 1
+ openstack flavor create --id 100 --ram 512 --disk 3 --vcpus 1 yardstick-flavor
# DPDK-enabled OVS requires guest memory to be backed by large pages
if [[ "$DEPLOY_SCENARIO" == *"-ovs-"* ]]; then
- nova flavor-key yardstick-flavor set hw:mem_page_size=large
+ openstack flavor set --property hw:mem_page_size=large yardstick-flavor
fi
# VPP requires guest memory to be backed by large pages
if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
- nova flavor-key yardstick-flavor set hw:mem_page_size=large
+ openstack flavor set --property hw:mem_page_size=large yardstick-flavor
fi
fi
}
main()
{
- QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-trusty-server.img"
- RAW_IMAGE="/tmp/workspace/yardstick/yardstick-trusty-server.tar.gz"
+ QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img"
+ RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz"
build_yardstick_image
load_yardstick_image
diff --git a/tests/ci/prepare_env.sh b/tests/ci/prepare_env.sh
index 130969fa1..be59b7f37 100755
--- a/tests/ci/prepare_env.sh
+++ b/tests/ci/prepare_env.sh
@@ -74,13 +74,6 @@ verify_connectivity() {
error "Can not talk to $ip."
}
-YARD_IMG_ARCH=amd64
-export YARD_IMG_ARCH
-
-if ! grep -q "Defaults env_keep += \"YARD_IMG_ARCH\"" "/etc/sudoers"; then
- sudo echo "Defaults env_keep += \"YARD_IMG_ARCH YARDSTICK_REPO_DIR\"" >> /etc/sudoers
-fi
-
ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
if [ "$INSTALLER_TYPE" == "fuel" ]; then
@@ -90,9 +83,6 @@ if [ "$INSTALLER_TYPE" == "fuel" ]; then
sshpass -p r00tme scp 2>/dev/null $ssh_options \
root@${INSTALLER_IP}:~/.ssh/id_rsa /root/.ssh/id_rsa &> /dev/null
- ARCH_SCRIPT="test -f /etc/fuel_openstack_arch && grep -q arm64 /etc/fuel_openstack_arch"
- sshpass -p r00tme ssh $ssh_options -l root $INSTALLER_IP "${ARCH_SCRIPT}" && YARD_IMG_ARCH=arm64
-
sshpass -p r00tme ssh 2>/dev/null $ssh_options \
root@${INSTALLER_IP} fuel node>fuel_node
diff --git a/tests/ci/prepare_storperf_admin-rc.sh b/tests/ci/prepare_storperf_admin-rc.sh
index 0401719ff..b3dc2e58e 100755
--- a/tests/ci/prepare_storperf_admin-rc.sh
+++ b/tests/ci/prepare_storperf_admin-rc.sh
@@ -9,14 +9,15 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+# Prepare storperf_admin-rc for StorPerf.
+
AUTH_URL=${OS_AUTH_URL}
USERNAME=${OS_USERNAME:-admin}
PASSWORD=${OS_PASSWORD:-console}
TENANT_NAME=${OS_TENANT_NAME:-admin}
VOLUME_API_VERSION=${OS_VOLUME_API_VERSION:-2}
PROJECT_NAME=${OS_PROJECT_NAME:-$TENANT_NAME}
-TENANT_ID=`keystone tenant-get admin|grep 'id'|awk -F '|' '{print $3}'|sed -e 's/^[[:space:]]*//'`
-
+TENANT_ID=`openstack project show admin|grep '\bid\b' |awk -F '|' '{print $3}'|sed -e 's/^[[:space:]]*//'`
rm -f ~/storperf_admin-rc
touch ~/storperf_admin-rc
diff --git a/tests/ci/requirements.txt b/tests/ci/requirements.txt
deleted file mode 100644
index 4d1a16993..000000000
--- a/tests/ci/requirements.txt
+++ /dev/null
@@ -1,79 +0,0 @@
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-appdirs==1.4.0
-Babel==2.2.0
-backport-ipaddress==0.1
-cliff==2.0.0
-cmd2==0.6.8
-coverage==4.1b2
-debtcollector==1.3.0
-ecdsa==0.13
-extras==0.0.3
-fixtures==1.4.0
-flake8==2.5.4
-funcsigs==0.4
-functools32==3.2.3.post2
-futures==3.0.5
-iso8601==0.1.11
-Jinja2==2.8
-jsonpatch==1.13
-jsonpointer==1.10
-jsonschema==2.5.1
-keystoneauth1==2.3.0
-linecache2==1.0.0
-lxml==3.5.0
-MarkupSafe==0.23
-mccabe==0.4.0
-mock==1.3.0
-monotonic==1.0
-msgpack-python==0.4.7
-netaddr==0.7.18
-netifaces==0.10.4
-nose==1.3.7
-openstacksdk==0.8.1
-os-client-config==1.16.0
-oslo.config==3.9.0
-oslo.i18n==3.4.0
-oslo.serialization==2.4.0
-oslo.utils==3.7.0
-paramiko==1.16.0
-pbr==1.8.1
-pep8==1.7.0
-positional==1.0.1
-prettytable==0.7.2
-pycrypto==2.6.1
-pyflakes==1.0.0
-pyparsing==2.1.0
-pyrsistent==0.11.12
-python-cinderclient==1.6.0
-python-glanceclient==2.0.0
-python-heatclient==1.0.0
-python-keystoneclient==2.3.1
-python-mimeparse==1.5.1
-python-neutronclient==4.1.1
-python-novaclient==3.3.0
-python-openstackclient==2.2.0
-python-subunit==1.2.0
-python-swiftclient==3.0.0
-pytz==2015.7
-PyYAML==3.11
-requests==2.9.1
-requestsexceptions==1.1.3
-scp==0.10.2
-simplejson==3.8.2
-six==1.10.0
-stevedore==1.12.0
-testrepository==0.0.20
-testtools==2.0.0
-traceback2==1.4.0
-unicodecsv==0.14.1
-unittest2==1.1.0
-warlock==1.2.0
-wrapt==1.10.6
diff --git a/tests/ci/scp_storperf_admin-rc.sh b/tests/ci/scp_storperf_admin-rc.sh
index af2885b01..7c3896d88 100644
--- a/tests/ci/scp_storperf_admin-rc.sh
+++ b/tests/ci/scp_storperf_admin-rc.sh
@@ -1,5 +1,16 @@
#!/bin/bash
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# Copy storperf_admin-rc to deployment location.
+
ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
sshpass -p root scp 2>/dev/null $ssh_options ~/storperf_admin-rc \
root@192.168.200.1:/root/ &> /dev/null
diff --git a/tests/ci/yardstick-verify b/tests/ci/yardstick-verify
index 2b7ec9d34..f9d98a4da 100755
--- a/tests/ci/yardstick-verify
+++ b/tests/ci/yardstick-verify
@@ -160,9 +160,9 @@ run_test()
mkdir -p /etc/yardstick
- cat << EOF >> /etc/yardstick/yardstick.conf
+ cat << EOF > /etc/yardstick/yardstick.conf
[DEFAULT]
-debug = True
+debug = False
dispatcher = ${DISPATCHER_TYPE}
[dispatcher_file]
@@ -301,8 +301,8 @@ main()
# check OpenStack services
echo "Checking OpenStack services:"
- for cmd in "glance image-list" "nova list" "heat stack-list"; do
- echo " checking ${cmd/%\ */} ..."
+ for cmd in "openstack image list" "openstack server list" "openstack stack list"; do
+ echo " checking ${cmd} ..."
if ! $cmd >/dev/null; then
echo "error: command \"$cmd\" failed"
exit 1
@@ -311,7 +311,7 @@ main()
echo
echo "Checking for External network:"
- for net in $(neutron net-list --router:external True -c name -f value); do
+ for net in $(openstack network list --external -c Name -f value); do
echo " external network: $net"
done
@@ -320,8 +320,6 @@ main()
source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh
- cleanup
-
trap "error_exit" EXIT SIGTERM
source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc001.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc001.yaml
index 899ee963c..aa2980f69 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc001.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc001.yaml
@@ -31,7 +31,7 @@ scenarios:
context:
name: yardstick
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc005.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc005.yaml
index 6e50157fc..f5a2778e8 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc005.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc005.yaml
@@ -35,8 +35,8 @@ scenarios:
context:
name: yardstick-TC005
- image: yardstick-trusty-server
- flavor: m1.small
+ image: yardstick-image
+ flavor: yardstick-flavor
user: ubuntu
servers:
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml
index 8b21c5bf1..7221518ab 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml
@@ -16,7 +16,7 @@ scenarios:
vlan_net_2_name: apexlake_outbound_network
vlan_subnet_2_name: apexlake_outbound_subnet
vnic_type: direct
- vtc_flavor: m1.large
+ vtc_flavor: yardstick-flavor
runner:
type: Iteration
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc007.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc007.yaml
index 107c28d1d..6f99ea6f2 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc007.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc007.yaml
@@ -19,7 +19,7 @@ scenarios:
vlan_net_2_name: apexlake_outbound_network
vlan_subnet_2_name: apexlake_outbound_subnet
vnic_type: direct
- vtc_flavor: m1.large
+ vtc_flavor: yardstick-flavor
num_of_neighbours: 2
amount_of_ram: 1G
number_of_cores: 2
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml
index 1cec80ff6..a2f5f3adc 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml
@@ -37,7 +37,7 @@ scenarios:
context:
name: yardstick-TC008
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc009.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc009.yaml
index 82a55d751..f9fa1b778 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc009.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc009.yaml
@@ -32,7 +32,7 @@ scenarios:
context:
name: yardstick-TC009
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc010.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc010.yaml
index aeb18543e..6c7f96799 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc010.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc010.yaml
@@ -25,8 +25,8 @@ scenarios:
context:
name: yardstick-TC010
- image: yardstick-trusty-server
- flavor: m1.small
+ image: yardstick-image
+ flavor: yardstick-flavor
user: ubuntu
servers:
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc011.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc011.yaml
index 5d21e2814..4cd3119bb 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc011.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc011.yaml
@@ -23,7 +23,7 @@ scenarios:
context:
name: demo
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc012.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc012.yaml
index 3bdb8cb9a..ba246ff11 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc012.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc012.yaml
@@ -26,8 +26,8 @@ scenarios:
context:
name: demo
- image: yardstick-trusty-server
- flavor: m1.small
+ image: yardstick-image
+ flavor: yardstick-flavor
user: ubuntu
servers:
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc014.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc014.yaml
index 648657f22..1ac0f2961 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc014.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc014.yaml
@@ -19,7 +19,7 @@ scenarios:
context:
name: yardstick-TC014
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
@@ -29,4 +29,4 @@ context:
networks:
test:
- cidr: '10.0.1.0/24' \ No newline at end of file
+ cidr: '10.0.1.0/24'
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc020.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc020.yaml
index 7e5756001..cbdaf3970 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc020.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc020.yaml
@@ -15,7 +15,7 @@ scenarios:
vlan_net_2_name: apexlake_outbound_network
vlan_subnet_2_name: apexlake_outbound_subnet
vnic_type: direct
- vtc_flavor: m1.large
+ vtc_flavor: yardstick-flavor
runner:
type: Iteration
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc021.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc021.yaml
index 769d75618..17249785a 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc021.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc021.yaml
@@ -15,7 +15,7 @@ scenarios:
vlan_net_2_name: apexlake_outbound_network
vlan_subnet_2_name: apexlake_outbound_subnet
vnic_type: direct
- vtc_flavor: m1.large
+ vtc_flavor: yardstick-flavor
num_of_neighbours: 2
amount_of_ram: 1G
number_of_cores: 2
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml
index 5e2177a6e..cd42098d2 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml
@@ -64,7 +64,7 @@ scenarios:
context:
name: yardstick-TC037
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc038.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc038.yaml
index 128f94045..c2e5b4028 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc038.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc038.yaml
@@ -64,7 +64,7 @@ scenarios:
context:
name: yardstick-TC038
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc069.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc069.yaml
index 637e160c6..dcc34d80d 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc069.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc069.yaml
@@ -25,7 +25,7 @@ scenarios:
context:
name: yardstick-TC069
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc070.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc070.yaml
index 28b28b9ab..931587b5b 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc070.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc070.yaml
@@ -66,7 +66,7 @@ scenarios:
context:
name: yardstick-TC070
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc071.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc071.yaml
index 644010916..6f006eeaf 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc071.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc071.yaml
@@ -64,7 +64,7 @@ scenarios:
context:
name: yardstick-TC071
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc072.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc072.yaml
index f3e6d4c40..e1fa33173 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc072.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc072.yaml
@@ -66,7 +66,7 @@ scenarios:
context:
name: yardstick-TC072
- image: yardstick-trusty-server
+ image: yardstick-image
flavor: yardstick-flavor
user: ubuntu
diff --git a/tests/opnfv/test_suites/opnfv_components.yaml b/tests/opnfv/test_suites/opnfv_components.yaml
new file mode 100644
index 000000000..ff4923e03
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_components.yaml
@@ -0,0 +1,16 @@
+---
+# Yardstick components task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "opnfv_yardstick-components"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc074.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"public_network": "ext-net",
+ "StorPerf_ip": "192.168.200.1"}'
diff --git a/tests/opnfv/test_suites/opnfv_features.yaml b/tests/opnfv/test_suites/opnfv_features.yaml
new file mode 100644
index 000000000..3621f1367
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_features.yaml
@@ -0,0 +1,52 @@
+---
+# Yardstick features task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "opnfv_yardstick-features"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc027.yaml
+ constraint:
+ installer: compass,fuel
+ pod: huawei-pod1,lf-pod2
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
+ lf-pod2: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
+-
+ file_name: opnfv_yardstick_tc045.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc046.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc047.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc048.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc049.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc050.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc051.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc052.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc053.yaml
+ constraint:
+ installer: fuel
diff --git a/tests/opnfv/test_suites/opnfv_performance.yaml b/tests/opnfv/test_suites/opnfv_performance.yaml
new file mode 100644
index 000000000..71b1e2ef9
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_performance.yaml
@@ -0,0 +1,62 @@
+---
+# Yardstick performance task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "opnfv_yardstick-performance"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc043.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node4.LF","target": "node5.LF"}'
+-
+ file_name: opnfv_yardstick_tc055.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC055"}'
+-
+ file_name: opnfv_yardstick_tc063.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC063"}'
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
+-
+ file_name: opnfv_yardstick_tc075.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node1.LF"}'
diff --git a/tests/opnfv/test_suites/opnfv_smoke.yaml b/tests/opnfv/test_suites/opnfv_smoke.yaml
new file mode 100644
index 000000000..f773bec87
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_smoke.yaml
@@ -0,0 +1,14 @@
+---
+# Yardstick smoke task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "opnfv_yardstick-smoke"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
diff --git a/tests/unit/api/utils/test_common.py b/tests/unit/api/utils/test_common.py
new file mode 100644
index 000000000..5d177409e
--- /dev/null
+++ b/tests/unit/api/utils/test_common.py
@@ -0,0 +1,65 @@
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+
+from api.utils import common
+
+
+class TranslateToStrTestCase(unittest.TestCase):
+
+ def test_translate_to_str_unicode(self):
+ input_str = u'hello'
+ output_str = common.translate_to_str(input_str)
+
+ result = 'hello'
+ self.assertEqual(result, output_str)
+
+ def test_translate_to_str_dict_list_unicode(self):
+ input_str = {
+ u'hello': {u'hello': [u'world']}
+ }
+ output_str = common.translate_to_str(input_str)
+
+ result = {
+ 'hello': {'hello': ['world']}
+ }
+ self.assertEqual(result, output_str)
+
+
+class GetCommandListTestCase(unittest.TestCase):
+
+ def test_get_command_list_no_opts(self):
+ command_list = ['a']
+ opts = {}
+ args = 'b'
+ output_list = common.get_command_list(command_list, opts, args)
+
+ result_list = ['a', 'b']
+ self.assertEqual(result_list, output_list)
+
+ def test_get_command_list_with_opts_args(self):
+ command_list = ['a']
+ opts = {
+ 'b': 'c',
+ 'task-args': 'd'
+ }
+ args = 'e'
+
+ output_list = common.get_command_list(command_list, opts, args)
+
+ result_list = ['a', 'e', '--b', '--task-args', 'd']
+ self.assertEqual(result_list, output_list)
+
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/api/utils/test_influx.py b/tests/unit/api/utils/test_influx.py
new file mode 100644
index 000000000..0852da2dd
--- /dev/null
+++ b/tests/unit/api/utils/test_influx.py
@@ -0,0 +1,82 @@
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+import mock
+import uuid
+import datetime
+
+from api.utils import influx
+
+
+class GetDataDbClientTestCase(unittest.TestCase):
+
+ @mock.patch('api.utils.influx.ConfigParser')
+ def test_get_data_db_client_dispatcher_not_influxdb(self, mock_parser):
+ mock_parser.ConfigParser().get.return_value = 'file'
+ try:
+ influx.get_data_db_client()
+ except Exception as e:
+ self.assertIsInstance(e, RuntimeError)
+
+
+class GetIpTestCase(unittest.TestCase):
+
+ def test_get_url(self):
+ url = 'http://localhost:8086/hello'
+ output = influx._get_ip(url)
+
+ result = 'localhost'
+ self.assertEqual(result, output)
+
+
+class WriteDataTestCase(unittest.TestCase):
+
+ @mock.patch('api.utils.influx.get_data_db_client')
+ def test_write_data(self, mock_get_client):
+ measurement = 'tasklist'
+ field = {'status': 1}
+ timestamp = datetime.datetime.now()
+ tags = {'task_id': str(uuid.uuid4())}
+
+ influx._write_data(measurement, field, timestamp, tags)
+ mock_get_client.assert_called_with()
+
+
+class WriteDataTasklistTestCase(unittest.TestCase):
+
+ @mock.patch('api.utils.influx._write_data')
+ def test_write_data_tasklist(self, mock_write_data):
+ task_id = str(uuid.uuid4())
+ timestamp = datetime.datetime.now()
+ status = 1
+ influx.write_data_tasklist(task_id, timestamp, status)
+
+ field = {'status': status, 'error': ''}
+ tags = {'task_id': task_id}
+ mock_write_data.assert_called_with('tasklist', field, timestamp, tags)
+
+
+class QueryTestCase(unittest.TestCase):
+
+ @mock.patch('api.utils.influx.ConfigParser')
+ def test_query_dispatcher_not_influxdb(self, mock_parser):
+ mock_parser.ConfigParser().get.return_value = 'file'
+ try:
+ sql = 'select * form tasklist'
+ influx.query(sql)
+ except Exception as e:
+ self.assertIsInstance(e, RuntimeError)
+
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_vsperf.py b/tests/unit/benchmark/scenarios/networking/test_vsperf.py
index cb5c09ab3..25d52212b 100644
--- a/tests/unit/benchmark/scenarios/networking/test_vsperf.py
+++ b/tests/unit/benchmark/scenarios/networking/test_vsperf.py
@@ -39,17 +39,17 @@ class VsperfTestCase(unittest.TestCase):
}
self.args = {
'options': {
- 'testname': 'rfc2544_p2p_continuous',
+ 'testname': 'p2p_rfc2544_continuous',
'traffic_type': 'continuous',
- 'pkt_sizes': '64',
+ 'frame_size': '64',
'bidirectional': 'True',
'iload': 100,
- 'duration': 29,
'trafficgen_port1': 'eth1',
'trafficgen_port2': 'eth3',
'external_bridge': 'br-ex',
- 'conf-file': 'vsperf-yardstick.conf',
- 'setup-script': 'setup_yardstick.sh',
+ 'conf_file': 'vsperf-yardstick.conf',
+ 'setup_script': 'setup_yardstick.sh',
+ 'test_params': 'TRAFFICGEN_DURATION=30;',
},
'sla': {
'metrics': 'throughput_rx_fps',
diff --git a/tests/unit/benchmark/scenarios/storage/test_storperf.py b/tests/unit/benchmark/scenarios/storage/test_storperf.py
index d87ed733c..8fc97d2ed 100644
--- a/tests/unit/benchmark/scenarios/storage/test_storperf.py
+++ b/tests/unit/benchmark/scenarios/storage/test_storperf.py
@@ -43,7 +43,7 @@ def mocked_requests_job_get(*args, **kwargs):
self.content = json_data
self.status_code = status_code
- return MockResponseJobGet('{"_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}', 200)
+ return MockResponseJobGet('{"status": "completed", "_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}', 200)
def mocked_requests_job_post(*args, **kwargs):
@@ -152,7 +152,7 @@ class StorPerfTestCase(unittest.TestCase):
s = storperf.StorPerf(args, self.ctx)
s.setup_done = True
- sample_output = '{"_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}'
+ sample_output = '{"status": "completed", "_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}'
expected_result = json.loads(sample_output)
diff --git a/tests/unit/cmd/commands/test_env.py b/tests/unit/cmd/commands/test_env.py
new file mode 100644
index 000000000..af1ab8030
--- /dev/null
+++ b/tests/unit/cmd/commands/test_env.py
@@ -0,0 +1,29 @@
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+import mock
+
+from yardstick.cmd.commands.env import EnvCommand
+
+
+class EnvCommandTestCase(unittest.TestCase):
+
+ @mock.patch('yardstick.cmd.commands.env.HttpClient')
+ def test_do_influxdb(self, mock_http_client):
+ env = EnvCommand()
+ env.do_influxdb({})
+ self.assertTrue(mock_http_client().post.called)
+
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/common/test_httpClient.py b/tests/unit/common/test_httpClient.py
new file mode 100644
index 000000000..b39dc2332
--- /dev/null
+++ b/tests/unit/common/test_httpClient.py
@@ -0,0 +1,33 @@
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+import mock
+import json
+
+from yardstick.common import httpClient
+
+
+class HttpClientTestCase(unittest.TestCase):
+
+ @mock.patch('yardstick.common.httpClient.requests')
+ def test_post(self, mock_requests):
+ url = 'http://localhost:5000/hello'
+ data = {'hello': 'world'}
+ headers = {'Content-Type': 'application/json'}
+ httpClient.HttpClient().post(url, data)
+ mock_requests.post.assert_called_with(url, data=json.dumps(data),
+ headers=headers)
+
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/common/test_openstack_utils.py b/tests/unit/common/test_openstack_utils.py
new file mode 100644
index 000000000..ef619aace
--- /dev/null
+++ b/tests/unit/common/test_openstack_utils.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# Unittest for yardstick.common.openstack_utils
+
+import unittest
+import mock
+
+from yardstick.common import openstack_utils
+
+
+class GetCredentialsTestCase(unittest.TestCase):
+
+ @mock.patch('yardstick.common.openstack_utils.os')
+ def test_get_credentials(self, mock_os):
+ mock_os.getenv.return_value = ('2')
+ openstack_utils.get_credentials()
+
+
+class GetHeatApiVersionTestCase(unittest.TestCase):
+
+ @mock.patch('yardstick.common.openstack_utils.os')
+ def test_get_heat_api_version(self, mock_os):
+ API = 'HEAT_API_VERSION'
+ openstack_utils.get_heat_api_version()
+ mock_os.getenv.assert_called_with(API)
+
+ @mock.patch('yardstick.common.openstack_utils.os')
+ def test_get_heat_api_version(self, mock_os):
+ mock_os.getenv.return_value = ('2')
+ expected_result = '2'
+ api_version = openstack_utils.get_heat_api_version()
+ self.assertEqual(api_version, expected_result)
diff --git a/tests/unit/test_ssh.py b/tests/unit/test_ssh.py
index a27052462..045ac0f1b 100644
--- a/tests/unit/test_ssh.py
+++ b/tests/unit/test_ssh.py
@@ -17,7 +17,10 @@
# rally/tests/unit/common/test_sshutils.py
import os
+import socket
import unittest
+from cStringIO import StringIO
+
import mock
from yardstick import ssh
@@ -162,10 +165,10 @@ class SSHTestCase(unittest.TestCase):
def test_send_command(self, mock_paramiko):
paramiko_sshclient = self.test_client._get_client()
with mock.patch.object(paramiko_sshclient, "exec_command") \
- as mock_paramiko_exec_command:
+ as mock_paramiko_exec_command:
self.test_client.send_command('cmd')
mock_paramiko_exec_command.assert_called_once_with('cmd',
- get_pty=True)
+ get_pty=True)
class SSHRunTestCase(unittest.TestCase):
@@ -275,6 +278,23 @@ class SSHRunTestCase(unittest.TestCase):
self.assertEqual(send_calls, self.fake_session.send.mock_calls)
@mock.patch("yardstick.ssh.select")
+ def test_run_stdin_keep_open(self, mock_select):
+ """Test run method with stdin.
+
+ Third send call was called with "e2" because only 3 bytes was sent
+ by second call. So remainig 2 bytes of "line2" was sent by third call.
+ """
+ mock_select.select.return_value = ([], [], [])
+ self.fake_session.exit_status_ready.side_effect = [0, 0, 0, True]
+ self.fake_session.send_ready.return_value = True
+ self.fake_session.send.side_effect = len
+ fake_stdin = StringIO("line1\nline2\n")
+ self.test_client.run("cmd", stdin=fake_stdin, keep_stdin_open=True)
+ call = mock.call
+ send_calls = [call("line1\nline2\n")]
+ self.assertEqual(send_calls, self.fake_session.send.mock_calls)
+
+ @mock.patch("yardstick.ssh.select")
def test_run_select_error(self, mock_select):
self.fake_session.exit_status_ready.return_value = False
mock_select.select.return_value = ([], [], [True])
@@ -288,6 +308,87 @@ class SSHRunTestCase(unittest.TestCase):
self.fake_session.exit_status_ready.return_value = False
self.assertRaises(ssh.SSHTimeout, self.test_client.run, "cmd")
+ @mock.patch("yardstick.ssh.open", create=True)
+ def test__put_file_shell(self, mock_open):
+ with mock.patch.object(self.test_client, "run") as run_mock:
+ self.test_client._put_file_shell("localfile", "remotefile", 0o42)
+ run_mock.assert_called_once_with(
+ 'cat > "remotefile"&& chmod -- 042 "remotefile"',
+ stdin=mock_open.return_value.__enter__.return_value)
+
+ @mock.patch("yardstick.ssh.open", create=True)
+ def test__put_file_shell_space(self, mock_open):
+ with mock.patch.object(self.test_client, "run") as run_mock:
+ self.test_client._put_file_shell("localfile",
+ "filename with space", 0o42)
+ run_mock.assert_called_once_with(
+ 'cat > "filename with space"&& chmod -- 042 "filename with '
+ 'space"',
+ stdin=mock_open.return_value.__enter__.return_value)
+
+ @mock.patch("yardstick.ssh.open", create=True)
+ def test__put_file_shell_tilde(self, mock_open):
+ with mock.patch.object(self.test_client, "run") as run_mock:
+ self.test_client._put_file_shell("localfile", "~/remotefile", 0o42)
+ run_mock.assert_called_once_with(
+ 'cat > ~/"remotefile"&& chmod -- 042 ~/"remotefile"',
+ stdin=mock_open.return_value.__enter__.return_value)
+
+ @mock.patch("yardstick.ssh.open", create=True)
+ def test__put_file_shell_tilde_spaces(self, mock_open):
+ with mock.patch.object(self.test_client, "run") as run_mock:
+ self.test_client._put_file_shell("localfile", "~/file with space",
+ 0o42)
+ run_mock.assert_called_once_with(
+ 'cat > ~/"file with space"&& chmod -- 042 ~/"file with space"',
+ stdin=mock_open.return_value.__enter__.return_value)
+
+ @mock.patch("yardstick.ssh.os.stat")
+ def test__put_file_sftp(self, mock_stat):
+ sftp = self.fake_client.open_sftp.return_value = mock.MagicMock()
+ sftp.__enter__.return_value = sftp
+
+ mock_stat.return_value = os.stat_result([0o753] + [0] * 9)
+
+ self.test_client._put_file_sftp("localfile", "remotefile")
+
+ sftp.put.assert_called_once_with("localfile", "remotefile")
+ mock_stat.assert_called_once_with("localfile")
+ sftp.chmod.assert_called_once_with("remotefile", 0o753)
+ sftp.__exit__.assert_called_once_with(None, None, None)
+
+ def test__put_file_sftp_mode(self):
+ sftp = self.fake_client.open_sftp.return_value = mock.MagicMock()
+ sftp.__enter__.return_value = sftp
+
+ self.test_client._put_file_sftp("localfile", "remotefile", mode=0o753)
+
+ sftp.put.assert_called_once_with("localfile", "remotefile")
+ sftp.chmod.assert_called_once_with("remotefile", 0o753)
+ sftp.__exit__.assert_called_once_with(None, None, None)
+
+ def test_put_file_SSHException(self):
+ exc = ssh.paramiko.SSHException
+ self.test_client._put_file_sftp = mock.Mock(side_effect=exc())
+ self.test_client._put_file_shell = mock.Mock()
+
+ self.test_client.put_file("foo", "bar", 42)
+ self.test_client._put_file_sftp.assert_called_once_with("foo", "bar",
+ mode=42)
+ self.test_client._put_file_shell.assert_called_once_with("foo", "bar",
+ mode=42)
+
+ def test_put_file_socket_error(self):
+ exc = socket.error
+ self.test_client._put_file_sftp = mock.Mock(side_effect=exc())
+ self.test_client._put_file_shell = mock.Mock()
+
+ self.test_client.put_file("foo", "bar", 42)
+ self.test_client._put_file_sftp.assert_called_once_with("foo", "bar",
+ mode=42)
+ self.test_client._put_file_shell.assert_called_once_with("foo", "bar",
+ mode=42)
+
def main():
unittest.main()