Commit Graph

77 Commits

Author SHA1 Message Date
Takashi Kajinami 1e99767d0e Drop ineffective options from config file
The following options set in functional tests do not exist.
 [DEFAULT] send_identity_credentials
 [DEFAULT] send_identity_headers

Change-Id: Ia739af13e0f88d0861e453a4d54ecc626e32b34b
2024-01-31 01:16:12 +00:00
Stephen Finucane 9679ffc463 Remove six.moves.http_client usage
This is a rather beefy change due to the number of usages of this
import. The changes are trivial though.

Change-Id: I7badeeaca438b0291f4ed86670e7f217e6372c61
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-01-27 14:54:05 +00:00
Abhishek Kekane 525b6addd0 Make our functional tests compatible with RBAC
Recently we have added new non voting job 'functional-py38-rbac' which
will run our functional tests by enabling Secure RBAC. To run functional
tests with Secure RBAC enabled we need to pass 'reader' role to the
requests as well.

Change-Id: I70e085bd6c07548a9d4802fee651e589276a00e5
2021-07-16 07:58:46 -07:00
Abhishek Kekane 21257615e7 Use default policies in our tests
Made changes to use default policies in our unit and functional tests
rather than referring it from glance/tests/etc/policy.yaml file. Existing
function 'set_policy_rules' can be used to test custom policy rules in
functional testing.

Improvements needed in followup patch:
1. Property protection related unit tests still reads the special policy
from the policy.yaml file, need to make provision to override it instead.

2. Need to remove 'set_policy' function which actually responsible for
above behavior.

Related to blueprint policy-refactor
Change-Id: I0de9b9f9a7de499574101e3366ced730b0cb5fd1
2021-06-30 16:12:25 +00:00
Dan Smith c366ead5ef Fix test_cache_middleware tests to use auth
This fixes the cache tests (and the 'caching' deployment flavor) to
send authorization headers so that they can be checked by later policy
patches.

Change-Id: I6099c7da24e06595e08fd292a5083327b9f0cc64
2021-05-05 08:37:12 -07:00
Lucian Petrut 98b7ef195c Allow glance tests to run on Windows
In order to run the unit and functional Glance tests on Windows, we
have to:

* avoid monkey patching the os module on Windows (which causes Popen
  to fail)
* update sqlite connection URL
* avoid os.fork, not available on Windows.
    * we'll use subprocess.Popen when spinning up http servers.
    * for the really simple ones defined in the test helpers, we'll just
      use threads
* do not attempt to connect to '0.0.0.0', use '127.0.0.1' instead
* some tests aren't properly skipped (xattr ones), so we're covering that
  as well
* skip log rotation test, we can't move in-use files. Log rotation can
  be performed by the log handler itself.
* expect an exception when hitting connection timeouts
* avoid installing unavailable test requirements (xattr, pysendfile)
* pin the instance creation timestamp. some tests that deal with
  markers rely on ordering, which can be flipped if the timestamps are
  identical (can happen in case of resources created one after the
  other, not sure yet if this happens really fast or the clock isn't
  accurate enough).
* add a few seconds to some timeouts (much needed when running the tests
  in VMs).

blueprint windows-support

Change-Id: Ife69f56a3f9f4d81e1e2e47fde4778efd490938f
2019-03-13 16:41:11 +02:00
Erno Kuvaja 3dde3204d5 Remove Images API v1 entry points
This change removes option to configure Images API v1
This change removes Images API v1 endpoints from the router
This change removes all v1 tests
This change removes the v1 dependant glance-cache-manage command

This change does not remove all v1 codebase. Further cleanup and
decoupling will be needed.

Change-Id: Ia086230cc8c92f7b7dfd5b001923110d5bc55d4d
2018-07-13 10:21:49 +01:00
Matthew Treinish c09d157960
Add external lock to image cache sqlite driver db init
This commit adds an external lock to sqlite when launching multiple
worker processes (using uwsgi) the db init will fail for one since the 2
workers will race for initializing the DB. The method is idempotent so
we can safely run it twice in succession, but the lock is necessary to
provides us protection against running it at the same time.

Depends-On: I9a66a8636d12037ff9aa4fb73cc3f9b9343dd7e9
Change-Id: I654c3a5604a89402ba94d9cea44699a48583a7e0
2017-06-18 03:52:18 -04:00
Dharini Chandrasekar dbdc35bb1a Do not serve partial img download reqs from cache
Currently, when a partial download request for an image is received
via v2 api with caching enabled,
* For a new, uncached image:
  An attempt to cache (tee'ing) the partially downloaded image
  is made which is not desirable. While attempting to do this,
  the 206 gets converted to 500 due to a checksum mismatch of
  the partial image getting cached vs the entire image.
* For an already cached image:
  Cache middleware layer serves the request but sends the entire
  image (200 instead of 206)

This patch prevents caching of any partial images that are
being downloaded using v2 api and ensures that any partial
download requests are not served from cache.

Change-Id: I3586c4eda0c36392d3436980f766ed1dd910b47c
Closes-Bug: 1664709
2017-04-06 01:28:04 +00:00
Alexander Bashmakov b93cafcb42 Fix and enable test_cache_middleware test on py35.
Fixed glance.tests.functional.test_cache_middleware tests to work on
python3.5. Enabled running the tests in tox.ini.

Change-Id: Ie5d4ee52c378aae97f3c944aec8be1a1c4a5edd5
2017-03-22 23:01:55 +00:00
Gábor Antal 8a8e5bf56c Extracted HTTP response codes to constants in tests
There are several places in the source code where
HTTP response codes are used as numeric values.

These values are used from six.moves and the
numeric values are replaced by constants.

All of the used status codes were replaced with symbolic constants
from six.moves.http_client.
More about six.moves.http_client can be found at [2],
under the table "Supported renames:".

Also, this change improves code readibility.

This patchset does not extract numeric values from
the code itself, but it can be found at [1].

[1]: Ib9e26dcea927e96e65c626c18421621d3a29a64d
[2]: https://pythonhosted.org/six/#module-six.moves

Change-Id: Idfc7b043552f428f01ac3e47b270ee0639a8f5bc
Closes-Bug: #1520159
2016-10-06 15:17:06 +00:00
kairat_kushaev ecf8aea1e4 Remove verbose option from glance tests
verbose option is going to be deleted soon (see 
https://review.openstack.org/#/c/206437/ for more info
why it deprecated in oslo.log) because it confuses users 
(we already have debug option). So we need to delete it from glance
tests.

Change-Id: Iade46a6097d153f2df0da73554bbfd3e2b1704f5
2016-05-26 15:00:11 +00:00
Stuart McLaren 3077339f9f Return 204 rather than 403 when no image data
As per http://developer.openstack.org/api-ref-image-v2.html:
 "If no image data exists, the call returns the HTTP 204 status code. "

This commit changed that to 403:

 d4d94b290c

We should revert to the juno/kilo/liberty behaviour.

APIImpact

Closes-bug: 1549869

Change-Id: Ie9353bc254d11870abc102a7b9b4c7db3917abb4
2016-02-26 14:50:41 +00:00
Darja Shakhray d4d94b290c Fix error when downloading image status is not active
Added check image_status when downloading image.

Change-Id: I39d49ea8a828863fdf4d5efc98126a9009e4b098
Closes-bug: #1472449
2015-10-13 13:48:41 +00:00
Erno Kuvaja e8e71dba4d Rationalize test asserts
Utilizing assertIn and assertNotIn in a consistent way rather than
assertTrue( x <not> in y) and assertFalse(x in y).

Change-Id: Ic43d107c40a5a50b852ee476b1167c21e5ad86e8
2015-07-09 13:48:49 +00:00
Louis Taylor 2278bcff3b Set filesystem_store_datadir in tests
The new release of glance_store (0.5.0) included
I1d4f95cba47d21f1eb7e580314d01ac8d3481586, which raises errors if
filesystem_store_datadir or filesystem_store_datadirs is not set. Glance
currently is not correctly populating either of those options in certain
unit or functional tests, causing a lot of test failures. This patch
aims to unblock the gate by overriding the CONF option.

Change-Id: I3a9e0c7bfa4a9f38b41e93dce9652c4cc4811a9b
Closes-Bug: #1454384
2015-05-13 11:07:31 +01:00
Doug Hellmann ae21f4dffa Drop use of 'oslo' namespace package
The Oslo libraries have moved all of their code out of the 'oslo'
namespace package into per-library packages. The namespace package was
retained during kilo for backwards compatibility, but will be removed by
the liberty-2 milestone. This change removes the use of the namespace
package, replacing it with the new package names.

The patches in the libraries will be put on hold until application
patches have landed, or L2, whichever comes first. At that point, new
versions of the libraries without namespace packages will be released as
a major version update.

Please merge this patch, or an equivalent, before L2 to avoid problems
with those library releases.

Blueprint: remove-namespace-packages
https://blueprints.launchpad.net/oslo-incubator/+spec/remove-namespace-packages

Change-Id: Ifa8baab33cdb3e606cf175a8c29c3a4ef6c44480
2015-04-28 18:57:45 +00:00
Eddie Sheffield b000c85b7f Add ability to deactivate an image
This patch provides the ability to 'deactivate' an image by
providing two new API calls and a new image status 'deactivated'.
Attempting to download a deactivated image will result in a
403 'Forbidden' return code. Also, image locations won't be visible
for deactivated images unless the user is admin.
All other image operations should remain unaffected.

The two new API calls are:
    - POST /images/{image_id}/actions/deactivate
    - POST /images/{image_id}/actions/reactivate

DocImpact
UpgradeImpact

Change-Id: I32b7cc7ce8404457a87c8c05041aa2a30152b930
Implements: bp deactivate-image
2015-03-13 14:21:11 -04:00
Erno Kuvaja a4f5bf6ab9 Unify using six.moves.range rename everywhere
Mainly to improve consistency, use range() from six.moves
renames across glance.

Behaves consistently like py2 xrange() and py3 range().

Removes unnecessary range() from glace/api/v2/images.py

Change-Id: Id21f923d05600b902f2239e25ef01716c07e74a3
2015-02-25 12:05:36 +00:00
Louis Taylor 41d45dfb1c Move from oslo.utils to oslo_utils
oslo_utils has been moved out of the oslo namespace.

bp drop-namespace-packages

Change-Id: Ie818e72b31efd2a6ab182444967bdfaca9366f4a
2015-01-09 20:01:42 +00:00
Roman Vasilets cb2456ea5e Wrong order of assertEquals args(Glance)
Args of assertEquals method in glance.tests are arranged
in wrong order. In result when test fails it shows incorrect
information about observed and actual data. It's found more
than 2000 times. Right order of arguments is "expected, actual".

Change-Id: Ifea4809f5a696b608a19e36a9ed9e5eec46c8a21
Co-Authored-By: Li Yingjun <liyingjun1988@gmail.com>
Closes-Bug: 1277104
2014-11-13 17:10:09 +02:00
liyingjun 2365a3fb5f Fix assertEqual arguments order
assertEqual method's arguments should be in ('expected', 'actual')
order.

Change-Id: I88b5b0558720a91236b62b6e4a3590901e817f85
Closes-bug: 1277104
2014-09-19 00:25:18 +08:00
Julien Danjou 581cb4ca43 Switch to oslo.serialization
Change-Id: I983bb5b6e2c7fbbd8556ff0f99212803cb0269e9
2014-10-07 14:58:55 +02:00
Julien Danjou 874e643549 Switch to oslo.utils
Change-Id: I47dc734c6d6e2ab99c25701ae3492acd5e442212
2014-10-07 14:55:57 +02:00
Julien Danjou fadbef8511 hacking: upgrade to 0.9.x serie
Change-Id: I252758fd633662de9659a402c5e3d7e3ce1fae0f
2014-10-06 14:41:03 +02:00
Bartosz Fic 0b246bb5f5 Replaces assertEqual with assertTrue and assertFalse
In order to improve coding practices and be aligned to a standard,
self.assertEqual(...,True) statements where replaced with
self.assertTrue and self.assertFalse.

Change-Id: I4150a343493beae03d6f71c88e84f60d14fb60e1
Closes-Bug: #1230127
2014-09-12 10:51:02 +02:00
Julia Varlamova 67c79540c7 Enable hacking H301 and disable H304, H302
Enable hacking H301: one import per line. H304 and H302 check enables too,
so we temporarily disable it since it does not pass.

Fix imports in files below.

Add # noqa to migration scripts.

Change-Id: I6a8d4dcd9c3195d2848f218aafe304b1240ab60c
2014-02-18 16:05:18 +04:00
lizheming 56089303f0 fix bug:range() is not same in py3.x and py2.x
in python3.x, there is no method named xrange(),it
has replaced by range(),which is equal to xrange() in
python2.x. so we must fix this issue.we use six module
to fix this issue.

Change-Id: If4fd7478865e8024025af3e57e42f2a24e1e2bbc
Closes-Bug: #1268439
2014-01-21 12:46:20 +08:00
Noboru arai 8de10b0f34 Remove vim header
No need to set tabstop tons of times, this can be set in your vimrc
file instead.

More disucssion:
http://openstack.10931.n7.nabble.com/Remove-vim-modelines-td21780.html

Change-Id: I3b830a5bb831a63c188109e6fad66ba48884fff3
Partial-Bug: #1229324
2014-01-14 16:03:28 +00:00
Yanis Guenane 16c3a33c0b Migrate json to glance.openstack.common.jsonutils
Every call to json.loads/json.dumps have been changed to
jsonutils.loads/jsonutils.dumps respectively. Import json has been removed
also replaced by import glance.openstack.common.jsonutils

654d80b416dc5f413cb791aa838ec8688bf7da44 Create openstack.common.jsonutils

Change-Id: I8ef580e5eb91526dfaef37050ce1f5c6d88d56b5
Closes-bug: #1257922
2014-01-05 14:38:07 +00:00
Victor Sergeyev 88bb1af1d5 Enable F40X checking
Clean up imports due to F401 and F403 checks.
F401  'module' imported but unused
F403  unable to detect undefined names with wildcard import

Change-Id: I487edb157de1a6babc7ad8a3fb65f195e476c490
2013-11-27 18:15:48 +02:00
Chang Bo Guo 30696aa243 Clean up numeric expressions with oslo constants
Replace numeric expressions with olso constants to make code
more readable. This patch won't replace single 1024 if 1024 not
in an expression like number * 1024.

Change-Id: Ic1137774f0f9a2be89a7c2706d6eb52eb906ff1f
2013-11-21 20:05:19 -08:00
Jenkins 93edd1bdc6 Merge "Changed header from LLC to Foundation based on trademark policies" 2013-11-12 13:41:45 +00:00
Jenkins 3b8a8e73f6 Merge "Remove start index 0 in range()" 2013-10-10 16:00:59 +00:00
Zhi Yan Liu a50bfbf490 Adding 'download_image' policy enforcement to image cache middleware
Currently image cache middleware not care 'download_image' policy, the
enforcement caused user receive empty content but with HTTP 200 code
rather than 403 when client attempt to download image using v2 API. And
the real Forbidden exception be logged in glance-api log which image
application action raised. The end user is confused by this behavior.

Fixes bug: 1235378

Change-Id: Ibaa7ccf8613ee3cce4cb6a72e3206a2c94122222
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2013-10-09 10:28:10 +00:00
Dirk Mueller 518bbf7298 Changed header from LLC to Foundation based on trademark policies
Fixes: Bug 1214176

Change-Id: I4e394c33d810fe7d48066ff7cb6143f7eae25f13
2013-09-10 18:29:53 +02:00
Wu Wenxiang 51c5185eea Remove start index 0 in range()
Remove the useless arg ("start index" = 0) in files, since its default
value is 0, to make code cleaner.

Change-Id: I9d91ab8a8033b9a6c9b77608dea92c91a994c7fc
2013-09-06 16:20:33 +08:00
Wu Wenxiang 844a228c3c Remove unused local vars
Remove unused local vars in test files to make code cleaner.

Change-Id: If97fad2d6b85730ea1cebc477f5f092c1c17976d
2013-08-30 20:07:00 +08:00
John Bresnahan e3b54dd71d Allow tests to run without installation
This patch makes modifications to the way that programs which the various
tests depend on are forked and executed.  This will allow the tests to be
run without installing glance to a python installation (ie: python setup.py
{develop/install} will not be needed).

fixes bug: 1197800

Change-Id: I9687cb7a5b22747d9cea0a1c24057383a8901476
2013-08-14 15:10:55 -10:00
Jenkins a9c8bfd473 Merge "Fix cache delete-all-queued-images for xattr" 2013-07-24 07:49:24 +00:00
Jenkins adb454dcf2 Merge "Fix 'glance-cache-manage list-cached' for xattr" 2013-07-17 23:46:56 +00:00
Hemanth Makkapati 6296320329 removed unused variable 'registry_port'
The unused variable 'registry_port' has been removed from function
'test_cache_manage_delete_cached_images'

Fixes bug 1201585

Change-Id: Ib438989f2dd00952a1a1647c101269055088ddaa
2013-07-15 16:44:17 -04:00
Paul Bourke 7e844389c5 Fix cache delete-all-queued-images for xattr
Deleting all queued images was broken when using caching with the xattr
driver, due to a missing get_cache_files function.

The missing function can be satisfied by substituting the call to
get_cache_files() with get_all_regular_files()

Fixes bug 1197402

Change-Id: Ia7f289e15615ef31865ebfd23902aa1ae1b05d66
2013-07-08 17:08:15 +00:00
Paul Bourke fd9b4cd43d Fix 'glance-cache-manage list-cached' for xattr
The xattr driver for the caching middleware was returning it's
last_modified/last_accessed times in iso8601 format rather than a
timestamp.

This was inconsistent with the sqlite driver and caused the
glance-cache-manage command to fall over when using the xattr driver.

Fixes bug 1197360

Change-Id: Ie72dcd9f41f7a3b7405cda9fe28e1e468fcc1bef
2013-07-03 11:02:05 +00:00
John Bresnahan 039f3d8a59 Convert scripts to entry points
The executable programs used by Glance have historically been scripts
in the ./bin directory.  This patch converts all of the scripts to
entry_points.  This change makes these programs python modules.  Thus
they can be imported and methods in them can be called just like any
other module.  This will allow the tests to call into these programs
directly instead of having to fork out a process.

The conf.py file in the doc tree was causing a name collision with
the python module cmd.  The glance/glance directory was being added
to sys.path which made glance.cmd import with the name cmd.  This
patch also fixes that problem.

blueprint: refactoring-better-faster-stronger-functional-tests
Change-Id: I67ae14b7403af31a5944befcd2ec27a690e81f15
2013-04-29 14:08:29 -10:00
Mark J. Washenberger d6bad91493 Ensure disk_ and container_format during upload
This patch changes the image domain model so that the transition from
'queued' to 'saving' or 'active' status cannot take place if the image's
disk_format or container_format are not set.

Fixes bug 1131994

Change-Id: I454d9df736edd771f9d5d93eca4cd317116cc985
2013-03-07 09:47:21 -08:00
Jenkins 4b705d7ee7 Merge "Fix response code for successful image upload." 2013-03-01 00:00:01 +00:00
Matthew Treinish 16d6ce3527 Fix response code for successful image upload.
The API spec specifies the response code for a successful image
upload is supposed to be 204. However, currently the response is
201. This commit fixes this, and sets the response code to 204.

Fixes bug 1136480

Change-Id: I7ea3926c2dd86961f2dd9bc975b10799560ef20a
2013-02-28 17:54:10 -05:00
Brian Waldon 1397a92327 Remove unused imports
Change-Id: I3e92e2a010dc9ab333e64d18337995d12ad55bc3
2013-02-28 14:49:05 -08:00
Monty Taylor b5e60b7e78 Use testtools for unittest base class.
While doing this, remove some of the nose-isms, which don't play nicely.

Part of blueprint grizzly-testtools

Change-Id: I9ea398b25195ad5f9c5db876c3dbb49ef4a5ee99
2013-01-12 19:17:08 +00:00