summaryrefslogtreecommitdiff
path: root/tests/unit/test_shell.py
Commit message (Collapse)AuthorAgeFilesLines
* Rename "tests" directory to be "test" like in the swift repoTim Burke2019-11-061-3402/+0
| | | | | | | | | | | | | In addition to being less confusing for devs, this lets us actually run tempauth tests in swiftclient dsvm jobs. The job definition (over in the swift repo) specifies test/sample.conf, which does not exist in this repo. As a result, those tests would skip with SKIPPING FUNCTIONAL TESTS DUE TO NO CONFIG Change-Id: I558dbf9a657d442e6e19468e543bbec855129eeb
* Delete/overwrite symlinks betterTim Burke2019-08-011-0/+29
| | | | | | | | | | | | | Previously, when deleting a symlink that points to an xLO, we'd clean up the xLO's segments then delete the symlink, leaving the xLO itself busted. Similar trouble would come from overwriting a symlink pointing to an xLO. Check for a Content-Location in the HEAD response and leave such segments. Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com> Change-Id: I45b210cf380a68bd88187c91fa2d63a8b2bb709b
* Optionally display listings in raw jsonClay Gerrard2019-07-091-0/+20
| | | | | | | | | | | | Symlinks have recently added some new keys to container listings. It's very convenient to be able to see and reason about the extra information in container listings. Allowing raw json output is similar with what the client already does for the info command, and it's forward compatible with any listing enhancements added by future middleware development. Change-Id: I88fb38529342ac4e4198aeccd2f10c69c7396704
* Merge "Clean up warnings from newer flake8"Zuul2019-06-281-2/+2
|\
| * Clean up warnings from newer flake8Tim Burke2019-06-271-2/+2
| | | | | | | | Change-Id: I18a6327b3acdd4db5ae80097080c043f7c20c353
* | Fix SLO re-uploadTim Burke2019-06-271-2/+42
|/ | | | | | | | | | | | | | Previously, if you uploaded a file as an SLO then re-uploaded it with the same segment size and mtime, the second upload would go delete the segments it just (re)uploaded. This was due to us tracking old_slo_manifest_paths and new_slo_manifest_paths in different formats; one would have a leading slash while the other would not. Now, normalize to the stripped-slash version so we stop deleting segments we just uploaded. Change-Id: Ibcbed3df4febe81cdf13855656e2daaca8d521b4
* Update hacking versionZhijunWei2019-01-031-6/+6
| | | | | | | 1. update hacking version to latest 2. fix pep8 failed Change-Id: Ifc3bfeff4038c93d8c8cf2c9d7814c3003e73504
* Stop lazy importing keystoneclientTim Burke2018-09-071-34/+29
| | | | | | | | | | | | | | | | There were two basic problems: - We'd try to import on every attempt at getting auth, even when we already know keystoneclient isn't available. - Sometimes devs would hit some crazy import race involving (some combination of?) greenthreads and OS threads. So let's just try the imports *once*, at import time, and have None sentinels if it fails. Try both versions separately to decouple failures; this should let us support a wider range of keystoneclient versions. Change-Id: I2367310aac74f1b7c5ea0cb1a822a491e4ba8e68
* Merge "Back out some version bumps"Zuul2018-07-241-9/+26
|\
| * Back out some version bumpsTim Burke2018-07-111-9/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm giving up on trying to back out all of the test-requirements up-revs, but let's try to stay compatibile with old requests/six. As part of that, only disable some requests warnings on new-enough requests. Note that we should now be compatible with distro packages back to Ubuntu 16.04 and CentOS 6. Our six is still too new for Trusty, but hey, there's less than a year left on that anyway, right? Change-Id: Iccb23638393616f9ec3da660dd5e39ea4ea94220 Related-Change: I2a8f465c8b08370517cbec857933b08fca94ca38
* | Add ability to generate a temporary URL with anmmcardle2018-07-101-5/+25
|/ | | | | | IP range restriction Change-Id: I4734599886e4f4a563162390d0ff3bb1ef639db4
* Add option for user to enter passwordAlistair Coles2018-06-111-3/+54
| | | | | | | | | | | | Add the --prompt option for the CLI which will cause the user to be prompted to enter a password. Any password otherwise specified by --key, --os-password or an environment variable will be ignored. The swift client will exit with a warning if the password cannot be entered without its value being echoed. Closes-Bug: #1357562 Change-Id: I513647eed460007617f129691069c6fb1bfe62d7
* Merge "Allow --meta on upload"Zuul2017-12-081-2/+4
|\
| * Allow --meta on uploadTim Burke2017-07-061-2/+4
| | | | | | | | | | | | | | Previously, the --meta option was only allowed on post or copy subcommands. Change-Id: I87bf0338c34b5e89aa946505bee68dbeb37d784c Closes-Bug: #1616238
* | Allow for uploads from standard input.Timur Alperovich2017-07-261-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | If "-" is passed in for the source, python-swiftclient will upload the object by reading the contents of the standard input. The object name option must be set, as well, and this cannot be used in conjunction with other files. This approach stores the entire contents as one object. A follow on patch will change this behavior to upload from standard input as SLO, unless the segment size is larger than the content size. Change-Id: I1a8be6377de06f702e0f336a5a593408ed49be02
* | Buffer reads from diskTim Burke2017-07-111-6/+6
|/ | | | | | | Otherwise, Python defaults to 8k reads which seems kinda terrible. Change-Id: I3160626e947083af487fd1c3cb0aa6a62646527b Closes-Bug: #1671621
* Merge "Stop sending X-Static-Large-Object headers"Jenkins2017-06-141-1/+0
|\
| * Stop sending X-Static-Large-Object headersTim Burke2017-04-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If we were to include this in a normal PUT, it would 400, but only if slo is actually in the pipeline. If it's *not*, we'll create a normal Swift object and the header sticks. - This is really confusing for users; see the related bug. - If slo is later enabled in the cluster, Swift starts responding 500 with a KeyError because the client and on-disk formats don't match! Change-Id: I1d80c76af02f2ca847123349224ddc36d2a6996b Related-Change: I986c1656658f874172860469624118cc63bff9bc Related-Bug: #1680083
* | Merge "ISO 8601 timestamps for tempurl"Jenkins2017-05-181-5/+75
|\ \
| * | ISO 8601 timestamps for tempurlChristopher Bartz2017-03-291-5/+75
| |/ | | | | | | | | | | | | | | | | Client-side implementation for ISO 8601 timestamp support of tempurl middleware. Please see https://review.openstack.org/#/c/422679/ Change-Id: I76da28b48948475ec1bae5258e0b39a316553fb7
* | respect bulk delete page size and fix logic errorJohn Dickinson2017-04-201-20/+92
|/ | | | | | | | | | | | | | | | | | | | | | | | | | Previously, using SwiftService to delete "many" objects would use bulk delete if available, but it would not respect the bulk delete page size. If the number of objects to delete exceeded the bulk delete page size, SwiftService would ignore the error and nothing would be deleted. This patch changes _should_bulk_delete() to be _bulk_delete_page_size(); instead of returning a simple True/False, it returns the page size for the bulk deleter, or 1 if objects should be deleted one at a time. Delete SDK calls are then spread across multiple bulk DELETEs if the requested number of objects to delete exceeds the returned page size. Fixed the logic in _should_bulk_delete() so that if the object list is exactly 2x the thread count, it will not bulk delete. This is the natural conclusion following the logic that existed previously: if the delete request can be satisfied by every worker thread doing one or two tasks, don't bulk delete. But if it requires a worker thread to do three or more tasks, do a bulk delete instead. Previously, the logic would mean that if every worker thread did exactly two tasks, it would bulk delete. This patch changes a "<" to a "<=". Closes-Bug: 1679851 Change-Id: I3c18f89bac1170dc62187114ef06dbe721afcc2e
* prefix-based tempurls supportChristopher Bartz2017-01-191-2/+31
| | | | | | | | | Implements client-side functionality for prefix-based tempurls. Please see: https://review.openstack.org/#/c/274048/ Change-Id: I8d7701daee888ed1120271a96c0660b01543ca2d
* Merge "modify 'swift <sub_command> —help' display"Jenkins2016-12-131-2/+5
|\
| * modify 'swift <sub_command> —help' displayShashirekha Gundur2016-12-131-2/+5
| | | | | | | | | | | | | | | | | | In python swiftclient: swift <sub_command> —help will now display st_<sub_command>_options + st_<sub_command>_help texts e.g. http://paste.openstack.org/show/589752/ Change-Id: I34e4b2ac29ef395f8ca474ce7a82f59a1fd8c7f4 Closes-Bug: #1621415
* | Merge "Add additional headers for HEAD/GET/DELETE requests."Jenkins2016-11-081-27/+170
|\ \ | |/ |/|
| * Add additional headers for HEAD/GET/DELETE requests.Charles Hsu2016-11-071-27/+170
| | | | | | | | | | Change-Id: I69276ba711057c122f97deac412e492e313c34dd Closes-Bug: 1615830
* | Replace assertTrue(a in b) with assertIn(a, b)Anh Tran2016-10-031-4/+4
|/ | | | Change-Id: I9726c9c051eea9264200ab27b3e556c68d5c927f
* Merge "Fix intermittent test failure"Jenkins2016-09-141-3/+7
|\
| * Fix intermittent test failureTim Burke2016-09-011-3/+7
| | | | | | | | | | | | | | The mock needs to be initialized before calling main, or we get a race to create it between all the uu_threads Change-Id: If7649da13ed9276d7f0e005e999770e09c022a3f
* | Make tempurl command check for valid object pathAlistair Coles2016-09-141-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If the supplied path is not of the form /v1/a/c/o then swift tempurl subcommand will now return an error message. Also removes redundant check for seconds parameter being an int from shell.py because the same check is made when calling utils.generate_temp_url. Drive-by fix for missing param definition for generate_temp_url. Change-Id: I41f4389948b01fadaa5fc4939ea12e0ed2167345 Related-Change: I0fb2ce125fe12d660e4deb778265016bdd5ff31b
* | Make options arguments truely optionalChristian Schwede2016-09-061-0/+16
|/ | | | | | | | | | | | | | Currently the options help, info and debug must exist in the options dictionary; however it might be that this is not the case if a method is imported externally. This patch fixes this. Also support using a storage URL or path as an argument for tempurl, and adding a test to verify correct output in both cases. Related-Bug: 1607519 Related-Bug: 1607523 Closes-Bug: 1607521 Change-Id: I0fb2ce125fe12d660e4deb778265016bdd5ff31b
* Merge "Add copy object method"Jenkins2016-08-241-0/+133
|\
| * Add copy object methodMarek Kaleta2016-08-231-0/+133
| | | | | | | | | | | | | | | | | | | | | | 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
* | Add --json option to `swift capabilities` / `swift info`Tim Burke2016-08-021-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This lets us do things like: $ swift info --json | jq '[.swift.policies[].name]' [ "Standard-Replica", "EC" ] Also, escape more dashes in the man page, so they won't be misinterpreted as hyphens. Change-Id: Ic7690bdbcfc55f55e5dde9bc11bb0644085973ce
* | Merge "Add an option: disable etag check on downloads"Jenkins2016-06-061-0/+18
|\ \
| * | Add an option: disable etag check on downloadsCheng Li2016-06-021-0/+18
| |/ | | | | | | | | | | | | | | This patch is to add an option of disable etag check on downloads. Change-Id: I9ad389dd691942dea6db470ca3f0543eb6e9703e Closes-bug: #1581147
* | Suppress InsecureRequestWarning when using --insecureTim Burke2016-06-011-10/+18
|/ | | | | | | | | The user already knows this is insecure, there's no point in bringing it up again and again. See also: https://github.com/kennethreitz/requests/issues/2214 Change-Id: I7991b2e568407269f84138bc03711147ed080c9c
* Merge "Support client certificate/key"Jenkins2016-05-191-1/+3
|\
| * Support client certificate/keyCedric Brandily2016-04-101-1/+3
| | | | | | | | | | | | | | | | | | This change enables to specify a client certificate/key with: * usual CLI options (--os-cert/--os-key) * usual environment variables ($OS_CERT/$OS_KEY) Closes-Bug: #1565112 Change-Id: I12e151adcb6084d801c6dfed21d82232a3259aea
* | Merge "Tighten up testing for sloppy auth version"Jenkins2016-05-081-4/+10
|\ \
| * | Tighten up testing for sloppy auth versionAlistair Coles2016-05-051-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing test that os-identity-api-version=2 would result in the correct auth_version=2.0 (note 2 -> 2.0) does not verify the sloppy version handling code path. When auth, key and user options are all missing the auth version is always set to 2.0 so the test will always pass. Adding auth, key and user options to the test command will cause the test to verify that the os-identity-api-version option was used and mapped to 2.0. Change-Id: Ifa10cd2b8bf81c082d5e3fa846f993871194fea0
* | | Default to v3 auth if we find a (user|project)-domain-(name|id) optionTim Burke2016-05-031-0/+29
|/ / | | | | | | Change-Id: I4616492752b620de0bf90672142f1071ec9bac83
* | Pull option processing out to service.pyTim Burke2016-05-031-0/+37
| | | | | | | | | | | | | | ...because it seems silly that we do nearly the same thing in two different places Change-Id: Iafafe3c553d00652adb91ceefd0de1479cbcb5da
* | Parse options to dictTim Burke2016-05-031-6/+6
| | | | | | | | | | | | | | This is a first step toward unifying the options parsing magic between shell.py and service.py Change-Id: If001e07978c0bae729ac0cd9b2c2934092c98447
* | Merge "Add tests for thread option validation"Jenkins2016-05-021-0/+95
|\ \ | |/ |/|
| * Add tests for thread option validationTim Burke2016-03-171-0/+95
| | | | | | | | Change-Id: If84714c7ea6be1c95c5898a82db2d4b6c9637242
* | Merge "Port from optparse to argparse"Jenkins2016-04-081-15/+18
|\ \
| * | Port from optparse to argparseTim Burke2016-04-061-15/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why now? * argparse was introduced in Python 3.2 and back-ported to Python 2.7. Until we dropped Python 2.6 support, we were stuck on optparse. * keystoneauth.loading.cli provides register_argparse_arguments and load_from_argparse_arguments helper methods. Now that we're moving toward Keystone Session support, argparse seems required. Closes-Bug: 1553030 Change-Id: I5139fb64a8631a3010680090fd04345f95c55c7b
* | | Merge "Initialize delete_object mock *before* creating all the threads"Jenkins2016-03-181-0/+1
|\ \ \
| * | | Initialize delete_object mock *before* creating all the threadsTim Burke2016-03-171-0/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we'd occasionally get spurious failures like FAIL: test_delete_account (tests.unit.test_shell.TestShell) ---------------------------------------------------------------------- Traceback (most recent call last): File ".../mock/mock.py", line 1721, in _inner return f(*args, **kw) File ".../mock/mock.py", line 1305, in patched return func(*args, **keywargs) File ".../tests/unit/test_shell.py", line 788, in test_delete_account response_dict={})], any_order=True) File ".../mock/mock.py", line 983, in assert_has_calls ), cause) File ".../six.py", line 718, in raise_from raise value AssertionError: (call(u'container', u'object', query_string=None, response_dict={}),) not all found in call list Related-Bug: #1539536 Related-Bug: #1480223 Change-Id: I810894545ca74d3b2f2dbde2d0388eb69c2ba710