20 Commits

Author SHA1 Message Date
Alistair Coles
169a7c7f9e Fix func test --until-failure and --no-discover options
This patch changes functional test classes to subclass
unittest2.TestCase rather than unittest.TestCase.
This fixes errors when attempting to use

tox -e func -- -n <test_path_including_test_method>

and

tox -e func -- --until-failure

Also migrate from using nose.SkipTest to unittest2.SkipTest

Change-Id: I903033f5e01833550b2f2b945894edca4233c4a2
Closes-Bug: 1526725
Co-Authored-By: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2015-12-16 15:28:25 +00:00
Richard Hawkins
9d7f71d575 Modify functional tests to use ostestr/testr
Defcore uses Tempest, which uses Test Repository.
This change makes it easier for Defcore to pull functional
tests from Swift and run them.  Additionally, using testr
allows tests to be run in parallel.

Concurrency set to 1 for now, >1 causes failures for
reasons that are still TBD.

With switch to ostestr all the server logs are being sent to stdout
which makes it completely unreadable. Suppressing the logs by default
now with a flag to enable it if desired.

Co-Authored-By: John Dickinson <me@not.mn>
Co-Authored-By: Robert Collins <rbtcollins@hpe.com>
Co-Authored-By: Matthew Oliver <matt@oliver.net.au>
Co-Authored-By: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>

Change-Id: I53ef4a116996a772cf1f3abc2eb0ad60047322d5
Related-Bug: 1177924
2015-12-15 22:30:44 +00:00
Bill Huber
49b9ba37ac pep8 fix: assertEquals -> assertEqual
assertEquals is deprecated in py3 in the following dir:
test/functional/*

Change-Id: Iee7f8ffca9838ccc521107180697d91ac9559405
2015-08-05 22:23:54 -04:00
Samuel Merritt
117b61976f functests: use assertIn and assertNotIn
We have a bunch of assertions like

    self.assertTrue(resp.status in (200, 204))

Sometimes we get smart about failure messages and have something like

    self.assertTrue(resp.status in (200, 204), resp.status)

so we can see what the status was when it failed.

Since we don't have to support Python 2.6 any more, we can use
assertIn/assertNotIn and get nice failure messages for free.

Change-Id: I2d46c9969d41207a89e01017b4c2bc533c3d744f
2015-07-28 12:23:14 +01:00
janonymous
8fe8bee7e0 test/(functional, probe): Replace "self.assert_" by "self.assertTrue"
The assert_() method is deprecated and can be safely replaced by assertTrue().
This patch makes sure that running the tests does not generate warnings
all over the screen.

Change-Id: I74705c6498249337bfdf955d62e0ad972035bc1f
2015-07-28 12:00:00 +01:00
Jenkins
2107fe89c7 Merge "Select policy when running functional test" 2015-07-17 00:26:44 +00:00
Victor Stinner
e5c962a28c Replace xrange() with six.moves.range()
Patch generated by the xrange operation of the sixer tool:
https://pypi.python.org/pypi/sixer

Manual changes:

* Fix indentation for pep8 checks
* Fix TestGreenthreadSafeIterator.test_access_is_serialized of
  test.unit.common.test_utils:
  replace range(1, 11) with list(range(1, 11))
* Fix UnsafeXrange docstring, revert change

Change-Id: Icb7e26135c5e57b5302b8bfe066b33cafe69fe4d
2015-06-23 07:29:15 +00:00
Hisashi Osanai
93de6c73e5 Add metadata size tests on the border
This patch adds a test for a 204 when a single metadata item in a POST causes
the backend aggregate constraints check to be on the border.

Background:
Overall metadata size constraint is enforced in the container and
account backends as well as in the proxy controllers.
Whereas the proxy controller can check that constraints are not exceeded
by a single PUT or POST request, the backend checks that constraints are not
exceeded by the aggregate of all PUTs and POSTs.

The change [1] added a test for a 400 when a single metadata item in
a POST causes the backend aggregate constraints check to go over limit.

[1] I1489e29686013cbd3d70283d8756b548aea3c2e1

Change-Id: Iac86ea71240ddde177e625c279c21aef67659d10
2015-06-04 15:08:13 +00:00
Alistair Coles
8b4af92dac Tighten up overall metadata size tests
Overall metadata size constraint is enforced in the container and account
backends as well as in the proxy controllers. Whereas the proxy controller
can check that constraints are not exceeded by a single PUT or POST request,
the backend checks that constraints are not exceeded by the aggregate of all
PUTs and POSTs.

The current functional tests only exercise the proxy controller checks, since
they test for a 400 when sending excessive metadata in a single POST. This patch
adds a test for a 400 when a single metadata item in a POST causes the backend
aggregate constraints check to go over limit.

The extra coverage of the new assertions can be seen by modifying
swift/common/db.DatabasBroker.validate_metadata() to always return None
immediately - only the new assertions fail when functests are run.

Change-Id: I1489e29686013cbd3d70283d8756b548aea3c2e1
2015-06-01 18:27:26 +01:00
Thiago da Silva
7bdb8266d4 Select policy when running functional test
Add ability to select a storage policy when running
the functional tests by defining the environment variable
SWIFT_TEST_POLICY.

This patch was first introduced by Janie Richling in
feature/ec: https://review.openstack.org/#/c/166097

Co-Authored-By: Janie Richling <jrichli@us.ibm.com>
Co-Authored-By: Christian Schwede <christian.schwede@enovance.com>
Co-Authored-By: Kota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp>
Co-Authored-By: Alistair Coles <alistair.coles@hp.com>

Change-Id: Id96354546088df137def0ae7fd434baf64ed0c51
Signed-off-by: Thiago da Silva <thiago@redhat.com>
2015-04-06 16:35:58 +00:00
Richard (Rick) Hawkins
5b2c27a587 Fix metadata overall limits bug
Currently metadata limits are checked on a per request basis. If
multiple requests are sent within the per request limits, it is
possible to exceed the overall limits.  This patch adds an overall
metadata check to ensure that multiple requests to add metadata to
an account/container will check overall limits before adding
the additional metadata.

Change-Id: Ib9401a4ee05a9cb737939541bd9b84e8dc239c70
Closes-Bug: 1365350
2014-10-02 22:38:13 +00:00
Jenkins
034fae630c Merge "Restrict keystone cross-tenant ACLs to IDs" 2014-09-13 00:53:47 +00:00
saranjan
2a8b43e5e7 Spelling mistakes corrected in comments.
Change-Id: Ibbd7511c3a2b08519feb4db18eca6e000603ea32
2014-09-03 10:40:30 -07:00
anc
a4f634bd89 Restrict keystone cross-tenant ACLs to IDs
The keystoneauth middleware supports cross-tenant access
control using the syntax <tenant>:<user> in container ACLs,
where <tenant> and <user> may currently be either a unique
id or a name. As a result of the keystone v3 API introducing
domains, names are no longer globally unique and are only
unique within a domain. The use of unqualified tenant and
user names in this ACL syntax is therefore not 'safe' in a
keystone v3 environment.

This patch modifies keystoneauth to restrict cross-tenant
ACL matching to use only ids for accounts that are not in
the default domain. For backwards compatibility,
names will still be matched in ACLs when both the requesting
user and tenant are known to be in the default domain AND the
account's tenant is also in the default domain (the default
domain being the domain to which existing tenants are
migrated).

Accounts existing prior to this patch are assumed to be for
tenants in the default domain. New accounts created using a
v2 token scoped on the tenant are also assumed to be in the
default domain. New accounts created using a v3 token scoped
on the tenant will learn their domain membership from the
token info. New accounts created using any unscoped token,
(i.e. with a reselleradmin role) will have unknown domain
membership and therefore be assumed to NOT be in the default
domain.

Despite this provision for backwards compatibility, names
must no longer be used when setting new ACLs in any account,
including new accounts in the default domain.

This change obviously impacts users accustomed to specifying
cross-tenant ACLs in terms of names, and further work will be
necessary to restore those use cases. Some ideas are
discussed under the bug report. With that caveat, this patch
removes the reported vulnerability when using
swift/keystoneauth with a keystone v3 API.

Note: to observe the new 'restricted' behaviour you will need
to setup keystone user(s) and tenant(s) in a non-default domain
and set auth_version = v3.0 in the auth_token middleware config
section of proxy-server.conf. You may also benefit from the
keystone v3 enabled swiftclient patch under review here:
https://review.openstack.org/#/c/91788/

DocImpact

blueprint keystone-v3-support

Closes-Bug:  #1299146

Change-Id: Ib32df093f7450f704127da77ff06b595f57615cb
2014-08-08 15:58:29 +01:00
Yuan Zhou
c11ac01252 Add functional tests for Storage Policy
* additional container tests
 * refactor test cross policy copy
 * make functional tests cleanup better

In-process functional tests only define a single ring and will skip some of
the multi-storage policy tests, but have been updated to reload_policies with
the patched swift.conf.

DocImpact
Implements: blueprint storage-policies
Change-Id: If17bc7b9737558d3b9a54eeb6ff3e6b51463f002
2014-06-18 20:57:09 -07:00
Peter Portante
44b39417ba Read the configuration once for all func tests
Merge the swift_testing module into the functional test module itself,
so that we can read the configuration once for all unit tests, sharing
the same constraints.

Change-Id: I9fbbfdade9adca329cd79f7d4291ba009327c842
2014-04-02 23:48:01 -04:00
Peter Portante
07fcf50c3a Rework use of constraints to ease testing
Prior to this patch both mainline code and testing modules imported
and used constraints directly into their own namespace, or relied on
the namespace of other modules that were not the constraints
module. This meant that if a unit test wanted to change a constraint
for its operation, it had to know how that module was using the
constraint, instead of referencing the constraint module itself.

This patch unifies the use of constraints so that all constraints are
referenced via the constraints module. In turn, this allows a test to
leverage the re-loadable nature of the constraints in the constraints
module.

It addition, a number of functional tests where using the default
values for constraints, instead of the configured value discovered in
a test.conf or in an existing swift.conf. This patch removes those
direct references in favor of the load_constraint() method from the
test/functional/tests.py module.

Change-Id: Ia5313d653c667dd9ca800786de59b59334c34eaa
2014-04-02 23:48:01 -04:00
Hou Ming Wang
87710cc8a2 AssertEquals is deprecated, use assertEqual partI
assertEquals is deprecated in Python 2.7, need drop it.
http://docs.python.org/2/library/unittest.html#deprecated-aliases

Change-Id: Ieec505887f740b99b11ef40878ba3ee7247b78a8
Closes-Bug: #1285040
2014-04-01 16:53:00 -07:00
Clay Gerrard
45e797b967 additional functional tests for account acls
Change-Id: I7d8a8e48066281707862cd07f6b5a012476e8f24
2014-03-25 19:51:58 -07:00
Steve Kowalik
65a03e55cd Move the tests from functionalnosetests
Move the tests from functionalnosetests under functional, so we no
longer have two seperate trees for functional tests. This also drops
the 'nose' name from the directory, so that it doesn't end up with
confusion if we move to testr. Further, since there are no longer two
test runs in .functests, it nows looks very close to the other two.

Change-Id: I8de025c29d71f05072e257df24899927b82c1382
2014-01-07 15:58:11 +08:00