23 Commits

Author SHA1 Message Date
Timur Alperovich
edfeae3723 Add delimiter to get_account().
Exposes the delimiter parameter, which the Swift API supports for
container listings.

Change-Id: Id8dfce01a9b64de9d1222aab9a4a682ce9e0f2b7
2018-11-30 22:58:36 +00:00
Tim Burke
411ef48e5b Stop leaking quite so many connections
While investigating the failures when you move func tests to py3, I
noticed a whole bunch of

   ResourceWarning: unclosed <socket.socket ...>

noise. This should fix it.

While we're at it, make get_capabilities less stupid.

Change-Id: I3913e9334090b04a78143e0b70f621aad30fc642
Related-Change: I86d24104033b490a35178fc504d88c1e4a566628
2018-11-09 09:55:30 -08:00
Tim Burke
85bb28eab4 Remove some pointless code
Change-Id: I3163834c330c5ea44c1096e83127588c88f0d761
2018-06-22 16:23:57 -07:00
Jenkins
9531369c23 Merge "Make functests py3-compatible" 2017-01-24 01:28:27 +00:00
Pallavi
b6cf56deb9 Use ConfigParser instead of SafeConfigParser
The SafeConfigParser class has been renamed to ConfigParser in Python
3.2. This alias will be removed in future versions.So we can use
ConfigParser directly instead.

Change-Id: Ie0292271229ee77d1bc57dd897ebbbb3d3c059aa
Closes-Bug: #1618666
2016-10-17 08:56:44 +00:00
Tim Burke
ab60e08e2e Convert numeric and boolean header values to strings
Recently, requests got a bit more picky about what types of data it will
accept as header values [1]. The reasons for this are generally sound;
str()ing arbitrary objects just before pushing them out a socket may not
do what the developer wanted/expected.

However, there are a few standard types that developers may be sending
that we should convert for them as a convenience. Now, we'll convert all
int, float, and bool values to strings before sending them on to
requests.

Change-Id: I6c2f451009cb03cb78812f54e4ed8566076de821
Closes-Bug: 1614932
2016-08-25 11:32:08 -07:00
Tim Burke
304da900da Make functests py3-compatible
Change-Id: I2b3bf17e874cf049eccab4c85ceac7da10d258ef
2016-08-24 17:27:52 -07:00
Marek Kaleta
4a2465fb12 Add copy object method
Implement copy object method in swiftclient Connection, Service and CLI.

Although COPY functionality can be accomplished with 'X-Copy-From'
header in PUT request, using copy is more convenient especially when
using copy for updating object metadata non-destructively.

Closes-Bug: 1474939
Change-Id: I1338ac411f418f4adb3d06753d044a484a7f32a4
2016-08-23 14:37:11 -07:00
Tim Burke
bed6bbd5ef Drop testtools from test-requirements.txt
My understanding is that it was mainly being used so we could have sane
testing on py26.  With py26 support being dropped, we no longer need it.

Also drop discover from test-requirements.txt, as we don't seem to
actually use it.

Change-Id: Iee04c42890596d3b483c1473169480a3ae19aac8
Related-Change: I37116731db11449d0c374a6a83a3a43789a19d5f
2016-02-12 09:57:58 -08:00
Stuart McLaren
4af623bcf1 Retry download of object body
Currently the swift client retries establishing a connection to the server
(by default up to 5 times).  However, when downloading an object, once
the connection has been established and the inital headers have been
returned, no attempt is made to retry.

So, for example, if 99MB of a 100MB object have been downloaded and the
connection is then lost, the download will fail.  This patch changes the
behaviour to re-establish the connection and fetch the remaining bytes
using the 'Range' header to offset.

Data retry is not yet supported if the original request is for a subset
of the object data (ie uses the 'Range' header), or if resp_chunk_size
has not been set.

The object's etag is checked using If-Match to make sure the object data
hasn't changed since the start of the download.

Change-Id: Iab47f10081ff39f6d344dbc2479cbc3bfd1c5b29
2016-01-08 17:12:02 +00:00
Alistair Coles
ab34609050 Add functional test for object PUT with raw iterator
Adds a functional test to verify change made in [1]

[1] change id I19579ed7a0181ac3f488433e7c1839f7f7a040b8

Change-Id: I45dbf66edab645e6339e67906aee5faa4fb7efbd
2016-01-05 18:25:19 +00:00
Lisak, Peter
df1f4f3e39 swiftclient content-type header
According to help `swift upload -h` you can add a customized request header 'Content-Type'.
But actually it is ignored (cleared and default is used) if subcommand is upload.

Subcommand post works as expected in help.

Bug fix: Use 'Content-Type' from the customized request headers also if
uploading.

Change-Id: If0d1354b6214b909527341078fe1769aa6587457
2015-10-22 08:54:13 +00:00
Jenkins
795476e013 Merge "Run functional tests using keystone auth options" 2015-07-02 00:14:41 +00:00
Alistair Coles
f0aad4c364 Run functional tests using keystone auth options
Makes the existing functional tests run using three
auth modes: tempauth (v1), keystone v2 and keystone v3.
The latter uses an account in a non-default domain
(which exists in devstack setup).

This should help avoid regressions in handling different
auth options.

Change-Id: Ifee6a4fa418242892bf73eda5e2cad7b803b1bee
2015-06-04 12:54:43 +00:00
Jenkins
ec3e2ab3a0 Merge "Allow reading from object body on download" 2015-06-04 12:08:07 +00:00
Stuart McLaren
b6457e0f95 Allow reading from object body on download
Currently, get_object returns a generator. This allows access to the
object's data in multiples of 'resp_chunk_size'.

This patch adds a read function to also allow accessing the object data
using read(size).

This allows, for example, the consumer of an object (where no byte range
has been specified) to read up to certain boundaries while streaming to
a new Large Object with segments of a specified size.

Reading and chunking can be safely mixed.

Related-Bug: 1367925
Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>
Change-Id: I1cfb67f45afc7015fd896f1a89bebae048871769
2015-03-24 10:45:33 +00:00
Tim Burke
a4fb70ece1 Compare each chunk of large objects when uploading
Previously, we compared the ETag from Swift against the MD5 of the
entire large object. However, the ETag for large objects is generally
the MD5 of the concatenation of the ETags for each segment, unless the
object is a DLO whose segments span more than one page of a container
listing. Rather than worry about ETags, just compare each chunk of the
segmented file. This allows the use of --skip-identical when uploading
SLOs and DLOs.

Additionally, there are several test-related improvements:
 * The default arguments for OutputManager are now evaluated on
   construction, rather than on definition, so that
   TestOutputManager.test_instantiation will succeed when using nosetest
   as a test runner. (See also: bug 1251507)
 * An account_username option is now available in the functional tests
   config file for auth systems that do not follow the account:username
   format.
 * CaptureOutput no longer writes to the captured stream, and
   MockHttpTest now captures output. These were polluting test output
   unnecessarily. (See also: bug 1201376)

Change-Id: Ic484e9a0c186c9283c4012c6a2fa77b96b8edf8a
Closes-Bug: #1201376
Closes-Bug: #1379252
Related-Bug: #1251507
2015-03-23 18:35:45 -07:00
Christian Schwede
5ecff2868e Use skipTest from testtools instead of inherited Exception
SkipTest is raised if there is no func_test section in the Swift test
config file. However, the currently raised Exception will result in a
failed test, not in a test marked as skipped.

Since we already use testtools we can use the included skipTest easily.

Change-Id: I1bbb1f9dbe31fb0698d774550708d1196b266625
2014-10-08 07:10:23 +00:00
Jenkins
5e18d95cb2 Merge "Remove testtools.main() call from tests" 2014-05-24 09:16:59 +00:00
Christian Schwede
258420f410 Fix Python3 bugs
This patch fixes three issues that were found running
functional tests with Python 3:

1. python-requests sets 'application/x-www-form-urlencoded' as
   content-type if the input is not a string object and no
   content-type is given.

2. Encoding of the headers is now only done if required. This
   prevents comparisons between unencoded headers and encoded
   prefixes and avoids unnecessary forloop-iterations.
   One unittest was extended to ensure it works for unencoded
   and encoded headers with or without the prefix.

3. Functional tests recently switched to using byte data for
   testing, thus the comparison needs to be a byte object as well.

Change-Id: I035f8b4b9c9ccdc79820b907770a48f86d0343b4
2014-05-21 14:54:18 +01:00
Christian Schwede
876238a134 Remove testtools.main() call from tests
There is no testtools.main() at all (this was a
unittest.main() before). Let's remove this unused
and non-working code.

The following code can be used if someone needs
to start tests manually:

    python -m unittest <test_file.py>

Change-Id: Id5162ac73825584df6c23dbe68786ff3355fc6ae
2014-05-20 14:54:41 +00:00
Alex Gaynor
30244399dd Make the function tests Python3-import friendly
Change-Id: Ic73fc2a6f6712505eda71fa2e2e91ac680ced9a3
2014-05-07 07:27:58 -07:00
Christian Schwede
eb94ac076d Add functional tests for python-swiftclient
Coverage for swiftclient.client is 71% with these tests.

Unit tests have been moved into another subdirectory
to separate them from functional tests.

Change-Id: Ib8c4d78f7169cee893f82906f6388a5b06c45602
2014-05-05 11:53:37 +02:00