tox==2.9.1
+-e ../../../python-common
\ No newline at end of file
import pytest
-from ceph.deployment.drive_group import DriveGroupSpec, DeviceSelection, DriveGroupValidationError
from orchestrator import InventoryDevice, ReadCompletion, raise_if_exception
-
-def test_DriveGroup():
- dg_json = {
- 'host_pattern': 'hostname',
- 'data_devices': {'paths': ['/dev/sda']}
- }
-
- dg = DriveGroupSpec.from_json(dg_json)
- assert dg.hosts(['hostname']) == ['hostname']
- assert dg.data_devices.paths == ['/dev/sda']
-
-
-def test_DriveGroup_fail():
- with pytest.raises(TypeError):
- DriveGroupSpec.from_json({})
-
-
-def test_drivegroup_pattern():
- dg = DriveGroupSpec('node[1-3]', DeviceSelection())
- assert dg.hosts(['node{}'.format(i) for i in range(10)]) == ['node1', 'node2', 'node3']
-
-
-def test_drive_selection():
- devs = DeviceSelection(paths=['/dev/sda'])
- spec = DriveGroupSpec('node_name', data_devices=devs)
- assert spec.data_devices.paths == ['/dev/sda']
-
- with pytest.raises(DriveGroupValidationError, match='exclusive'):
- DeviceSelection(paths=['/dev/sda'], rotates=False)
-
def test_inventory_device():
i_d = InventoryDevice()
s = i_d.pretty_print()
--- /dev/null
+import pytest
+
+from ceph.deployment.drive_group import DriveGroupSpec, DeviceSelection, DriveGroupValidationError
+
+def test_DriveGroup():
+ dg_json = {
+ 'host_pattern': 'hostname',
+ 'data_devices': {'paths': ['/dev/sda']}
+ }
+
+ dg = DriveGroupSpec.from_json(dg_json)
+ assert dg.hosts(['hostname']) == ['hostname']
+ assert dg.data_devices.paths == ['/dev/sda']
+
+
+def test_DriveGroup_fail():
+ with pytest.raises(TypeError):
+ DriveGroupSpec.from_json({})
+
+
+def test_drivegroup_pattern():
+ dg = DriveGroupSpec('node[1-3]', DeviceSelection())
+ assert dg.hosts(['node{}'.format(i) for i in range(10)]) == ['node1', 'node2', 'node3']
+
+
+def test_drive_selection():
+ devs = DeviceSelection(paths=['/dev/sda'])
+ spec = DriveGroupSpec('node_name', data_devices=devs)
+ assert spec.data_devices.paths == ['/dev/sda']
+
+ with pytest.raises(DriveGroupValidationError, match='exclusive'):
+ DeviceSelection(paths=['/dev/sda'], rotates=False)
--- /dev/null
+[tox]
+envlist = py27, py35, py36, flake8
+skip_missing_interpreters = true
+
+[testenv]
+deps=
+ pytest
+commands=py.test -v {posargs:ceph/tests}
+
+[testenv:flake8]
+deps=flake8
+commands=flake8 {posargs:ceph}
+
+[tool:pytest]
+norecursedirs = .* _* virtualenv
+
+[flake8]
+select=F,E9
--- /dev/null
+#!/usr/bin/env bash
+
+function dump_envvars {
+ echo "WITH_PYTHON2: ->$WITH_PYTHON2<-"
+ echo "WITH_PYTHON3: ->$WITH_PYTHON3<-"
+ echo "ENV_LIST: ->$ENV_LIST<-"
+}
+
+get_cmake_variable() {
+ grep "$1" $CEPH_BUILD_DIR/CMakeCache.txt | cut -d "=" -f 2
+}
+
+script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+: ${CEPH_BUILD_DIR:=$script_dir/../../build}
+: ${WITH_PYTHON2:=$(get_cmake_variable WITH_PYTHON2)}
+: ${WITH_PYTHON3:=$(get_cmake_variable WITH_PYTHON3)}
+
+if [ -f ${TOX_VIRTUALENV}/bin/activate ]
+then
+ source ${TOX_VIRTUALENV}/bin/activate
+else
+ $script_dir/../tools/setup-virtualenv.sh tox_virtualenv
+ source tox_virtualenv/bin/activate
+ pip install tox
+fi
+
+# tox.ini will take care of this.
+export CEPH_BUILD_DIR=$CEPH_BUILD_DIR
+
+if [ "$WITH_PYTHON2" = "ON" ]; then
+ ENV_LIST+="py27,"
+fi
+# WITH_PYTHON3 might be set to "ON" or to the python3 RPM version number
+# prevailing on the system - e.g. "3", "36"
+if [[ "$WITH_PYTHON3" =~ (^3|^ON) ]]; then
+ ENV_LIST+="py3,"
+fi
+# use bash string manipulation to strip off any trailing comma
+ENV_LIST=${ENV_LIST%,}
+
+tox -c tox.ini -e "${ENV_LIST}" "$@"
+TOX_STATUS="$?"
+test "$TOX_STATUS" -ne "0" && dump_envvars
+exit $TOX_STATUS