From e5d939bdce5d3ac99dce2db681859a4594871e43 Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Thu, 26 Jun 2014 14:57:35 +0530 Subject: [PATCH] Support Storage Policy - Rev 8 * Added a version of .functests script that does not replace existing SAIO conf files and rings. This expects the appropriate setup to be ready before running functional tests. Signed-off-by: Prashanth Pai --- .functests | 48 ++++++--------- .functests-ci | 111 ++++++++++++++++++++++++++++++++++ gluster/swift/obj/diskfile.py | 3 + tox.ini | 8 ++- 4 files changed, 138 insertions(+), 32 deletions(-) create mode 100755 .functests-ci diff --git a/.functests b/.functests index 93a0d83..1e1b9f5 100755 --- a/.functests +++ b/.functests @@ -34,15 +34,9 @@ sudo_env() cleanup() { - print "Stopping memcached" - sudo service memcached stop - print "Stopping swift sevices" - sudo_env swift-init main stop print "Cleaning SoF mount point" sudo rm -rf /mnt/swiftonfile/test/* > /dev/null 2>&1 sudo setfattr -x user.swift.metadata /mnt/swiftonfile/test > /dev/null 2>&1 - print "Invoking SAIO's resetswift script" - resetswift } fail() @@ -56,8 +50,25 @@ fail() print """ Before proceeding forward, please make sure you already have: -1. SAIO deployment. (with resetswift and remakerings script) +1. SAIO deployment. 2. XFS/GlusterFS mounted at /mnt/swiftonfile/test +3. Added swiftonfile policy section to swift.conf file. + Example: + + [storage-policy:2] + name = swiftonfile + default = yes + +4. Copied etc/object-server.conf-gluster to /etc/swift/object-server/5.conf + +5. Generated ring files for swiftonfile policy. + Example: for policy with index 2 + + swift-ring-builder object-2.builder create 1 1 1 + swift-ring-builder object-2.builder add r1z1-127.0.0.1:6050/test 1 + swift-ring-builder object-2.builder rebalance + +6. Started memcached and swift services. """ prompt=true @@ -73,31 +84,8 @@ if $prompt; then fi fi -print "Invoking SAIO's resetswift script" -resetswift - -print "Invoking SAIO's remakerings script" -remakerings - -print "Copying conf files into /etc/swift. This will replace swift.conf and test.conf" -\cp etc/object-server.conf-gluster /etc/swift/object-server/5.conf -\cp test/functional/conf/swift.conf /etc/swift/swift.conf -\cp test/functional/conf/test.conf /etc/swift/test.conf - -print "Generating additional object-rings for swiftonfile SP" -cd /etc/swift -swift-ring-builder object-2.builder create 1 1 1 -swift-ring-builder object-2.builder add r1z1-127.0.0.1:6050/test 1 -swift-ring-builder object-2.builder rebalance -cd - - export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf -print "Starting memcached" -sudo service memcached start || fail "Unable to start memcached" -print "Starting swift services" -sudo_env swift-init main start || fail "Unable to start swift" - mkdir functional_tests_result > /dev/null 2>&1 print "Runnning functional tests" diff --git a/.functests-ci b/.functests-ci new file mode 100755 index 0000000..93a0d83 --- /dev/null +++ b/.functests-ci @@ -0,0 +1,111 @@ +#!/bin/bash + +# Copyright (c) 2013 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This program expects to be run by tox in a virtual python environment +# so that it does not pollute the host development system + +GREEN='\e[0;32m' +RED='\e[0;31m' +NC='\e[0m' # No Color + +print() +{ + echo -e "\n${GREEN}$*${NC}" +} + +sudo_env() +{ + sudo bash -c "PATH=$PATH $*" +} + +cleanup() +{ + print "Stopping memcached" + sudo service memcached stop + print "Stopping swift sevices" + sudo_env swift-init main stop + print "Cleaning SoF mount point" + sudo rm -rf /mnt/swiftonfile/test/* > /dev/null 2>&1 + sudo setfattr -x user.swift.metadata /mnt/swiftonfile/test > /dev/null 2>&1 + print "Invoking SAIO's resetswift script" + resetswift +} + +fail() +{ + cleanup + echo -e "\n${RED}$1${NC}" + exit 1 +} + +### MAIN ### + +print """ +Before proceeding forward, please make sure you already have: +1. SAIO deployment. (with resetswift and remakerings script) +2. XFS/GlusterFS mounted at /mnt/swiftonfile/test +""" + +prompt=true +if [ "$1" == "-q" ]; then + prompt=false +fi + +if $prompt; then + read -p "Continue ? " -r + if [[ $REPLY =~ ^[Nn]$ ]] + then + exit 1 + fi +fi + +print "Invoking SAIO's resetswift script" +resetswift + +print "Invoking SAIO's remakerings script" +remakerings + +print "Copying conf files into /etc/swift. This will replace swift.conf and test.conf" +\cp etc/object-server.conf-gluster /etc/swift/object-server/5.conf +\cp test/functional/conf/swift.conf /etc/swift/swift.conf +\cp test/functional/conf/test.conf /etc/swift/test.conf + +print "Generating additional object-rings for swiftonfile SP" +cd /etc/swift +swift-ring-builder object-2.builder create 1 1 1 +swift-ring-builder object-2.builder add r1z1-127.0.0.1:6050/test 1 +swift-ring-builder object-2.builder rebalance +cd - + +export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf + +print "Starting memcached" +sudo service memcached start || fail "Unable to start memcached" +print "Starting swift services" +sudo_env swift-init main start || fail "Unable to start swift" + +mkdir functional_tests_result > /dev/null 2>&1 + +print "Runnning functional tests" +nosetests -v --exe \ + --with-xunit \ + --xunit-file functional_tests_result/gluster-swift-generic-functional-TC-report.xml \ + --with-html-output \ + --html-out-file functional_tests_result/gluster-swift-generic-functional-result.html \ + test/functional || fail "Functional tests failed" +cleanup +exit 0 diff --git a/gluster/swift/obj/diskfile.py b/gluster/swift/obj/diskfile.py index 4a786eb..3b9d040 100644 --- a/gluster/swift/obj/diskfile.py +++ b/gluster/swift/obj/diskfile.py @@ -589,6 +589,9 @@ class DiskFile(object): # Don't store a value for data_file until we know it exists. self._data_file = None + # Account name contains resller_prefix which is retained and not + # stripped. This to conform to Swift's behavior where account name + # entry in Account DBs contain resller_prefix. self._account = account self._container = container diff --git a/tox.ini b/tox.ini index bb954bf..44a4bce 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27,pep8,functest +envlist = py26,py27,pep8,functest,functest-ci minversion = 1.6 skipsdist = True @@ -7,7 +7,6 @@ skipsdist = True usedevelop = True install_command = pip install --allow-external netifaces --allow-insecure netifaces -U {opts} {packages} whitelist_externals=bash - yes setenv = VIRTUAL_ENV={envdir} NOSE_WITH_OPENSTACK=1 NOSE_OPENSTACK_COLOR=1 @@ -37,6 +36,11 @@ setenv = VIRTUAL_ENV={envdir} [tox:jenkins] downloadcache = ~/cache/pip +# To be used by Jenkins +[testenv:functest-ci] +changedir = {toxinidir} +commands = bash ./.functests-ci -q + [testenv:functest] changedir = {toxinidir} commands = bash ./.functests -q