From a2c503ba2a36e154fb523f1446962b40550fa8e5 Mon Sep 17 00:00:00 2001 From: Peter Portante Date: Thu, 6 Mar 2014 00:03:03 -0500 Subject: [PATCH] Add missing swift constraint for functional tests Looks like we are keeping at least four lists of the default constraints in various places, and when we added the max_header_size in initial Static Large Object Support commit (5d73da15) we failed to add it to the two locations in the test tree (test/sample.conf and test/functional/tests.py). With this commit we take a small step to consolidate the list of constraints to the constraints module by removing the list from the tests module (note we still have them listed in the sample swift.conf file and the test module's sample.conf file), document the missing reference in the test module's sample.conf file, and, while we're at it, use the SWIFT_CONF_FILE reference where possible. Change-Id: Ic4fa5f1aedec9bc7a7b43ce1a2ca3cdebce6171f --- swift/common/constraints.py | 19 +++++++++++++++++-- test/functional/tests.py | 27 +++------------------------ test/sample.conf | 8 +++++--- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/swift/common/constraints.py b/swift/common/constraints.py index dd5c5c410f..0c23132129 100644 --- a/swift/common/constraints.py +++ b/swift/common/constraints.py @@ -18,12 +18,12 @@ import urllib from urllib import unquote from ConfigParser import ConfigParser, NoSectionError, NoOptionError -from swift.common.utils import ismount, split_path +from swift.common.utils import ismount, split_path, SWIFT_CONF_FILE from swift.common.swob import HTTPBadRequest, HTTPLengthRequired, \ HTTPRequestEntityTooLarge, HTTPPreconditionFailed constraints_conf = ConfigParser() -constraints_conf.read('/etc/swift/swift.conf') +constraints_conf_exists = constraints_conf.read(SWIFT_CONF_FILE) def constraints_conf_int(name, default): @@ -58,6 +58,21 @@ MAX_ACCOUNT_NAME_LENGTH = constraints_conf_int('max_account_name_length', 256) #: Max container name length MAX_CONTAINER_NAME_LENGTH = constraints_conf_int('max_container_name_length', 256) +# A simple dictionary of all the constraints that can be specified in the +# SWIFT_CONF_FILE. +default_constraints = dict(( + ('max_file_size', MAX_FILE_SIZE), + ('max_meta_name_length', MAX_META_NAME_LENGTH), + ('max_meta_value_length', MAX_META_VALUE_LENGTH), + ('max_meta_count', MAX_META_COUNT), + ('max_meta_overall_size', MAX_META_OVERALL_SIZE), + ('max_header_size', MAX_HEADER_SIZE), + ('max_object_name_length', MAX_OBJECT_NAME_LENGTH), + ('container_listing_limit', CONTAINER_LISTING_LIMIT), + ('account_listing_limit', ACCOUNT_LISTING_LIMIT), + ('max_account_name_length', MAX_ACCOUNT_NAME_LENGTH), + ('max_container_name_length', MAX_CONTAINER_NAME_LENGTH))) + # Maximum slo segments in buffer MAX_BUFFERED_SLO_SEGMENTS = 10000 diff --git a/test/functional/tests.py b/test/functional/tests.py index f222d4e9b8..6a9f78d611 100644 --- a/test/functional/tests.py +++ b/test/functional/tests.py @@ -25,40 +25,19 @@ import threading import uuid import unittest from nose import SkipTest -from ConfigParser import ConfigParser from test import get_config from test.functional.swift_test_client import Account, Connection, File, \ ResponseError -from swift.common.constraints import MAX_FILE_SIZE, MAX_META_NAME_LENGTH, \ - MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, \ - MAX_OBJECT_NAME_LENGTH, CONTAINER_LISTING_LIMIT, ACCOUNT_LISTING_LIMIT, \ - MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH +from swift.common.constraints import default_constraints, \ + constraints_conf_exists -default_constraints = dict(( - ('max_file_size', MAX_FILE_SIZE), - ('max_meta_name_length', MAX_META_NAME_LENGTH), - ('max_meta_value_length', MAX_META_VALUE_LENGTH), - ('max_meta_count', MAX_META_COUNT), - ('max_meta_overall_size', MAX_META_OVERALL_SIZE), - ('max_object_name_length', MAX_OBJECT_NAME_LENGTH), - ('container_listing_limit', CONTAINER_LISTING_LIMIT), - ('account_listing_limit', ACCOUNT_LISTING_LIMIT), - ('max_account_name_length', MAX_ACCOUNT_NAME_LENGTH), - ('max_container_name_length', MAX_CONTAINER_NAME_LENGTH))) -constraints_conf = ConfigParser() -conf_exists = constraints_conf.read('/etc/swift/swift.conf') -# Constraints are set first from the test config, then from -# /etc/swift/swift.conf if it exists. If swift.conf doesn't exist, -# then limit test coverage. This allows SAIO tests to work fine but -# requires remote functional testing to know something about the cluster -# that is being tested. config = get_config('func_test') for k in default_constraints: if k in config: # prefer what's in test.conf config[k] = int(config[k]) - elif conf_exists: + elif constraints_conf_exists: # swift.conf exists, so use what's defined there (or swift defaults) # This normally happens when the test is running locally to the cluster # as in a SAIO. diff --git a/test/sample.conf b/test/sample.conf index 32d984e0de..161a588aa2 100644 --- a/test/sample.conf +++ b/test/sample.conf @@ -25,15 +25,17 @@ password2 = testing2 username3 = tester3 password3 = testing3 -# Default constraints if not defined here, the test runner will try -# to set them from /etc/swift/swift.conf. If that file isn't found, -# the test runner will skip tests that depend on these values. +# If not defined here, the test runner will try to use the default constraint +# values as constructed by the constraints module, which will attempt to get +# them from /etc/swift/swift.conf, if possible. Then, if the swift.conf file +# isn't found, the test runner will skip tests that depend on those values. # Note that the cluster must have "sane" values for the test suite to pass. #max_file_size = 5368709122 #max_meta_name_length = 128 #max_meta_value_length = 256 #max_meta_count = 90 #max_meta_overall_size = 4096 +#max_header_size = 8192 #max_object_name_length = 1024 #container_listing_limit = 10000 #account_listing_limit = 10000