Commit Graph

229 Commits

Author SHA1 Message Date
Takashi Kajinami 835e7f36a5 Remove unused run_sql_cmd
The run_sql_cmd method in functional tests is not used. The method uses
Engine.execute() method which was removed in 2.0.

Change-Id: I6f9ea1dfd852a2d311e17964da0ea56c052b3fda
2024-04-15 11:54:16 +09:00
Abhishek Kekane 9b9111f819 Make `centralized_db` cache driver default
Made `centralized_db` cache driver as default driver so that we
can test it using tempest jobs in gate.

Implements blueprint centralized-cache-db
Depends-On: https://review.opendev.org/c/openstack/devstack/+/907110

Change-Id: Id94e93e3ba3fc207b39c7dbff92495805aa0f6f9
2024-03-05 19:35:20 +00:00
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
Takashi Kajinami b6b9f043ff Replace usage of deprecated [DATABASE] sql_connection
This option was deprecated in oslo.db a long ago and was removed in
master.

Change-Id: Iba6aa00e4f86fc4b82fa354fddf2fc7d6b47c52f
2024-01-28 01:06:30 +09:00
Takashi Kajinami fa9450d5b5 Deploy healthcheck middleware as app instead of filter
Using the healthcheck middleware as a filter is deprecated and
the middleware should be used as an application[1].
 [1] 6feaa13610c450c8486f969703768db5319b4846

This change updates definition and usage of the healthcheck middleware
accordingly to avoid the following deprecation warning.

DeprecationWarning: Using function/method 'Healthcheck.factory()' is
deprecated: The healthcheck middleware must now be configured as
an application, not as a filter.

Closes-Bug: #1937901
Change-Id: Id41e0313a481bea4e2bb14c69f2ad8a2070aa9be
2023-05-02 19:21:42 +02:00
Cyril Roelandt 41da684fe4 Fix functional test failures with PasteDeploy 3.x
PasteDeploy replaced pkg_resources with importlib_metadata[1] in 3.0.
This causes functional test failures because the line breaks in the
example configs from glance/tests/functional/__init__.py are read as a
"prefix" by PasteDeploy. For instance,

paste.filter_factory =
  glance.api.middleware.version_negotiation:VersionNegotiationFilter.factory

is read as "\nglance.api.middleware.version_negotiation:VersionNegotiationFilter.factory".

This might be a bug in PasteDeploy or (quite unlikely) in
configparser.ConfigParser rather than in our code, so this issue should
be revisited at some point. For now, remove the cosmetic line breaks in
order to fix our gates.

[1] ef58c20961

Change-Id: I1e557e731cceb3cfbc4ebc3f0887adf372a91d1d
2023-04-12 20:37:47 +02:00
Pranali Deore b20cc91e6f Remove deprecated ``enforce_secure_rbac`` option
As per the revised SRBAC community goals, glance service is now
switching to new defaults by default hence removing the deprecated
``enforce_secure_rbac`` option which is no longer needed.

The ``enforce_secure_rbac`` option was introduced EXPERIMENTAL in
Wallaby release for operators to opt into enforcing authorization
based on common RBAC personas.

Related blueprint secure-rbac

Change-Id: I273527c85d30c1c09c086c73c892aaa6d127df6b
2023-02-16 11:12:59 +00:00
Pranali Deore 8c04d19e88 Enabled new defaults and scope checks by default
Enabling the enforce scope and new defaults by default in glance

Related blueprint secure-rbac

Change-Id: I0808dc0b1b34b527e38aa137c1dd25e1fc06409f
2023-02-16 11:11:31 +00:00
Abhishek Kekane c1a2b9e221 Immediate caching of an image
Till now glance was dependent on periodic job to get image
cached locally and also has dependency on ``cachemanage``
middleware for the same.

This patch removes the periodic job and dependency of
``cachemanage`` middleware and initiates immediate caching
of an image via ``PUT /cache/image_id`` API call.

Co-Author: Dan Smith <dms@danplanet.com>

Implements: blueprint instant-caching
Change-Id: I9ab3f1b7595e22dbb03af95168314352a44eb930
2022-07-19 05:14:38 +00:00
Erno Kuvaja 87eae327bf Cache management API endpoints
This change adds the new cache API endpoints and their related
new policies.

Implements-bp: https://blueprints.launchpad.net/glance/+spec/cache-api
Change-Id: I69162e19bf095ef11fbac56a1ea2159d1caefba7
2022-02-14 15:14:17 +00:00
Stephen Finucane 87ba56161b Remove six.moves.urllib usage
Change-Id: I71be65ef7b8f710e9317419d7b38559b39f461b0
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-01-27 14:54:05 +00:00
Stephen Finucane 39e667a145 Remove six.moves.range usage
This is the same as the 'range' keyword in Python 3

Change-Id: If3aa008522c24e870b7bf13de32b8ed1b27cb519
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-01-27 14:54:05 +00:00
Stephen Finucane 0562e3335b Remove six.add_metaclass usage
Change-Id: If0d2ad8357ea759638c6b83c04ec7a2f3cf9f6bd
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-12-21 11:38:47 +00:00
Cyril Roelandt 0ca2f92161 Fix typos
Change-Id: I5e7776324c01e467799b1296c35b84dc0c10cce2
2021-10-13 03:02:52 +02:00
Zuul 02cf73ca2b Merge "Reproduce bug #1932337" 2021-09-14 19:01:15 +00:00
Lance Bragstad 4e68e5da6f Remove duplicate _url() methods from functional test classes
Most of the functional tests contain a version of _url(). The
implementations don't really differ, outside of one that accepts a
protocol and another that is specific to IPV6 for a single test case.

This commit moves the common method to the functional base class and
removes the duplicated logic across the functional test implementations.

Change-Id: I0b161ad404bdb53e3c1cfe878f78a71c239cf40e
2021-09-10 08:14:52 -07:00
Dan Smith b55dbb28c6 Reproduce bug #1932337
This reproduces the behavior described in bug 1932337, where a post-
upgrade GET by a non-owning user will return an error for a valid image
because the cinder store migration cannot complete.

This asserts the broken behavior to reproduce the problem, and the
rest of the test will be enabled when the bug is fixed.

Note that the test for this was duplicating code from the base class,
and since some changes were needed to those methods, this removes the
duplication and modifies only the base.

Change-Id: I741e6377b3aa40c14d637f0fbdf396dc468f6ebd
2021-09-08 15:17:49 -07:00
Abhishek Kekane ea13046919 Check policies for Image Cache in API
This patch enforces policy checks required for caching images
in API layer.

Partially-Implements: blueprint policy-refactor
Depends-On: https://review.opendev.org/c/openstack/nova/+/688802

Change-Id: Ie17b8f5bf308b8f07915ea18ace9b49955b8f0f0
2021-08-30 07:26:51 +00:00
Abhishek Kekane 6c87a18d4c Check policies for image import operation in API
This patch enforces policy checks required for importing/copying image
data to store in API layer.

Partially-Implements: blueprint policy-refactor

Change-Id: I18a5187d80bf76c0dc6f22dd8c96a8ffa0f46dc1
2021-08-24 20:09:24 +00:00
Abhishek Kekane 82111150d6 Check deactivate, reactivate policy in the API
Move deactivate/reactivate policy changes in API layer.

Partially-Implements: blueprint policy-refactor

Change-Id: Ia6e51228aee1ddf09734f922c5f6f3eb4ece60c1
2021-08-23 05:54:00 +00:00
Abhishek Kekane 99331d7efa Move metadef namespace policy checks in the API
This change also includes change in index method for 'GET' all
namespaces to not include properties, objects, tags, associations
etc. in the response if policies of either one is disabled.

The MetadefAPIPolicy object will raise Forbidden for cases where an
operation is forbidden, but the namespace would be otherwise visible to
the user, and NotFound otherwise to obscure the existence of namespaces
that the user can not otherwise see.

Partially implements: blueprint policy-refactor

Change-Id: I59cd3bbd98065457bf0c9cfaf6888b7f56f7617c
Depends-On: https://review.opendev.org/c/openstack/grenade/+/803317
2021-08-11 18:59:01 +00:00
Dan Smith 2fef2e6c4f Add api_patch() to SynchronousAPIBase
This makes it easier to run PATCH operations against the API from
synchronous functional tests. It also adds a status assertion to
one of the upload methods which makes it easier to determine when
an operation was denied.

Change-Id: Ie67cd0ada86c03d8eac06dfa3d0730d329591628
2021-07-27 07:59:17 -07:00
Dan Smith 8201f5f101 Add a nonvoting functional job with RBAC defaults
This adds a new tox target called functional-py38-rbac which enables
the new secure RBAC policy defaults for all functional tests. To do
this, the functional tests needed a little bit of extra work to
actually set those, and a new non-voting job is added to run these
in CI.

Related to blueprint policy-refactor

Change-Id: Id376193521671bdb0ebc08ea8e563578bbaa541f
2021-06-30 11:49:30 -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 a1e46cca6e Refactor SynchronousAPIBase for more cases
This simply adds some functionality and flexibility to this test base
so that subsequent patches can do some more things.

Related to blueprint glance-unified-quotas

Change-Id: Ic9359aac5dba2b4d7d0d2c7fa92a5b67440e22e0
2021-06-21 07:19:01 -07: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
Dan Smith e9852fb625 Make functional tests set node_staging_uri
Currently it is not possible to configure the staging directory
URI of the functional workers. We need to be able to do that in order
to enable the stage cleaning behavior. Right now, they're all sharing
/tmp/staging, which will cause workers to conflict while running in
parallel. This causes them to use their private test directory,
which may also help some other spurious failures due to interaction.

Related-Bug: #1913625
Change-Id: Ic2ac2a528206c50c38e948a096daf9eb8e5eb715
2021-03-02 11:49:47 -08:00
Cyril Roelandt 7839ab0925 Remove unused option "owner_is_tenant"
This option has been deprecated since Rocky.

Change-Id: I8edc957ad50ec28d80a06e76912f4226cea53562
2021-02-11 16:17:10 +01:00
Ghanshyam Mann c107629f90 [goal] Deprecate the JSON formatted policy file
As per the community goal of migrating the policy file
the format from JSON to YAML[1], we need to do two things:

1. Change the default value of '[oslo_policy] policy_file''
config option from 'policy.json' to 'policy.yaml' with
upgrade checks.

2. Deprecate the JSON formatted policy file on the project side
via warning in doc and releasenotes.

Also convert the ./glance/tests/etc/policy.json to policy.yaml
file. Replace policy.json to policy.yaml ref from doc and tests.

[1]https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html

Depends-On: https://review.opendev.org/c/openstack/nova/+/773192
Change-Id: I17d0374dd4223688e5f95253802a4ae87377953a
2021-01-29 15:31:47 -08:00
Dan Smith 4d9c7b573e Fix a typo in functional helper class
This was a typo (by me) in the original implementation, but since
nothing was testing DELETE calls, it was never noticed.

Change-Id: I81f9d0a53493a1b9793bdaae082093f30df6e032
2021-01-13 09:51:22 -08:00
Dan Smith f32d39230d Move some helper functions to base class
The ImageImportLocking test class has some useful helper functions
that are general enough to be used elsewhere. This moves those
to the SynchronousAPIBase test class.

Change-Id: Idbc6ab16ecac2eb9c83c58432f98414d68e16a52
2021-01-11 17:23:15 -08:00
Brian Rosmaita f102b74a28 Remove 'admin_role' option
This option was deprecated in the Ussuri release by change
I0f61f85a0aaa4f68e345fa08fbb6b039d3d32587 and it is now eligible
for removal following the standard OpenStack deprecation policy.

Change-Id: I78ec79f97bfdcc39772448296140f8d8f35adea1
2020-11-24 20:31:21 -05:00
Zuul 8da47cb5ca Merge "Functional test enhancement for lock busting" 2020-08-29 21:48:08 +00:00
Zuul 5e9a14aee1 Merge "Move SynchronousAPIBase to a generalized location" 2020-08-29 01:45:04 +00:00
Dan Smith 76667323d7 Disable wait_for_fork() kill aggression if expect_exit=True
In some cases, we spawn a process that we expect to run to completion
and exit. In those cases, disable the force-kill logic in wait_for_fork()
to avoid killing those processes too early.

Related-Bug: #1891190
Change-Id: Ia78d101ae3702d9f761ca8f04b4b10af4a6d84fb
2020-08-25 10:31:45 -07:00
Dan Smith a86062c492 Functional test enhancement for lock busting
This enhances our test for the import lock-busting case to include
freeing the stuck import task and letting the new and old ones proceed
to make sure that the end state looks like what we expect.

Note that this includes another task lock check after exiting the
ImportAction context before we call image save. While writing these
tests I determined that we can end up with the original task racing
to update the image locations. If set_data() took a very long time,
caused our lock to be stolen and another task is running, when our
set_data() finally finishes we may overwrite their newly-added
location when we go to save our (now stale) list. Thus, the extra
task check (imperfectly) tries to avoid us doing anything else after
our task lock is stolen.

Change-Id: I74baf53fac1c3e23f6dc743058165ecb39074626
2020-08-24 06:41:13 -07:00
Dan Smith 36cbc50e7d Move SynchronousAPIBase to a generalized location
The base class for the tests added in test_images_import_locking provides
a mechanism to make API cals directly against the WSGI stack, without
starting a separate server and using the local networking. This is useful
for cases where fault injection of global state needs to be altered, where
this is very difficult in the existing fork-and-exec functional test
model.

This moves that test base class out to the functional module, expands the
documentation a little, and also generalizes the request methods for
wider applicability.

Change-Id: I59e3b5d5d4b69f076092b9950c0d34467a6636ad
2020-08-24 06:41:13 -07:00
Dan Smith 8e8072c16a Make wait_for_fork() more robust against infinite deadlock
There is something about the process handling in the functional test base
that opens the scenario where we might signal our API master child,
waitpid() on it and never return (see bug 1891190). Specifically the
test_reload() case, where the API master is being sent SIGHUP various times,
which may cause it to temporarily mask out SIGTERM or something, which
means it ignores our request. Either way, a deadlock in the tests can
occur when the cleanup() routine goes to waitpid() on that master,
forever.

This change makes our wait_for_fork() helper call waitpid() with WNOHANG
and progressively ramp up the aggression on asking it to stop. First, it
waits for the original signal to be honored, then it starts sending SIGTERM,
followed by SIGKILLs until the overall timeout expires, after which it
fails the test. The latter should only ever happen if something gets
wedged in uninterruptible sleep.

Related-Bug: #1891190
Change-Id: Ie0e91e2ee86f33bcdb63eed74f2d9948108acfd4
2020-08-12 06:55:06 -07:00
Dan Smith 12167a9508 Squelch the stevedore.extension debug logging in functional tests
These are super verbose and log the same thing many times, making the
test output very hard to read. They're not likely to be very useful in
debugging, so just quiet them down.

Change-Id: I7ce94addb5c9a28e9091fa47261638ee488d6f13
2020-08-07 09:43:50 -07:00
Dan Smith 16a5431c66 Make glance-api able to do async tasks in WSGI mode
This teaches glance-api how to do async threading things when it is
running in pure-WSGI mode. In order to do that, a refactoring of things
that currently depend on eventlet is required.

It adds a [wsgi]/task_pool_threads configuration knob, which is used
in the case of pure-WSGI and native threads to constrain the number
of threads in that pool (and thus the task parallelism). This will
allow tuning by the operator, but also lets us default that to just
a single thread in the backport of these fixes so that we can avoid
introducing a new larger footprint in the backport unexpectedly.

Partial-Bug: #1888713
Depends-On: https://review.opendev.org/#/c/742047/
Change-Id: Ie15028b75fb8518ec2b0c0c0386d21782166f759
2020-07-24 11:13:45 -07:00
Erno Kuvaja 3068096199 Cleanup remove api v1 and registry code
Change-Id: I86a3cbf4374bc2b083ccd86f75b88490b305eaab
2020-07-14 10:38:19 +00:00
Erno Kuvaja bbb3ede895 Removal of 'enable_v2_api'
Removal of config option 'enable_v2_api' and its related
operations and tests.

Change-Id: Ic83e7e8077b3fc939990c1f8e9c99b13b7fcd7ad
2020-07-03 19:01:39 +00:00
Erno Kuvaja 673666cbf4 Deprecation cleanout Registry and related
This patch removes majority of the registry and it's related
endpoints and config options that has been deprecated for
removal in various releases.

Change-Id: I75014bd50bf382efebe56bd89c20ffefbdde25f5
2020-06-30 20:41:30 +01:00
Abhishek Kekane 1754c9e2b0 Copy existing image in multiple stores
Added new import method 'copy-image' which will copy existing image into
specified list of stores. Introduced additional task which will serve
as internal plugin which will allow copying existing image into staging
area and then this data will be uploaded to specified stores via regula
import flow.

NOTE: This new import method 'copy-image' is only supported if multiple
stores are enabled in deployment.

APIImpact
Implements: blueprint copy-existing-image
Change-Id: I13eaab7ab013f44ce18465bdbdbe8052942570ff
2020-02-12 05:32:46 +00:00
Abhishek Kekane b55c0a31c0 Remove registry related functional and unit tests
Registry service is deprecated and due for removal since past
couple of cycles. This patch removes functional and unit tests of
registry.

NOTE:
Skipped 'test_create_with_live_time' test as it was dependent on
test_registry_client and test_registry_api modules. Something is
wrong with the test and will be corrected once entire registry code
is removed from the code base.

Change-Id: I560ab5260bed7e43d83b67a00057ac48f9e366e9
2019-12-18 09:23:37 +00:00
Erno Kuvaja 06b2465f59 Remove native ssl support
As eventlet ssl termination is broken with python 3 and
we won't be supporting python 2.7 anymore we will just
remove ssl termination to glance-api and expect the
termination being handled by something else, like HAProxy.

This patch also removes the broken ssl test job as the
non-existing feature is not broken anymore.

Change-Id: Iaf16dfcfdb3a2c93312dcad1ea1229e6b3c8caaa
2019-12-09 15:17:03 +00:00
Abhishek Kekane 6dba83ba3a Rethinking filesystem access
In Rocky multiple backend support is added as experimental feature. In
order to take advantage of this feature it is decided to deprecate
work_dir and node_staging_uri configuration options
and reserve two filesystem stores 'os_glance_tasks_store' and
'os_glance_staging_store', which can be used to get rid of initializing
store via internal functions.

These internal stores are considered "reserved stores" by Glance.
For the time being, these are hard-coded as filesystem stores.  The
store prefix 'os_glance_' is reserved for internal Glance use and
the glance-api service will refuse to start if a store with this
prefix is included in the enabled_backends config option in
glance-api.conf.

NOTE: Because there are no sensible default values for the location
of the datadir for each of these stores, the operator must define
'os_glance_tasks_store' and 'os_glance_staging_store' in
glance-api.conf configuration file as shown below.

[os_glance_tasks_store]
filesystem_store_datadir = /var/lib/glance/tasks_work_dir/

[os_glance_staging_store]
filesystem_store_datadir = /var/lib/glance/staging/

Each filesystem store must have a unique datadir.

Depends-On: https://review.openstack.org/#/c/639765/
Implements: blueprint rethinking-filesystem-access
Change-Id: I86ec513c5fc653dbb97b79d953d8430f014e684f
2019-10-01 09:53:48 +00:00
Abhishek Kekane 73fefddd96 Add periodic job to prefetch images into cache
Added new periodic job which will run as per interval set using
'cache_prefetcher_interval' configuration option and fetch images
which are queued for caching in cache directory.

DocImpact
Change-Id: If2875f7a215aca10a6ed2febc89b02219f90a10d
2019-09-10 15:01:58 +00: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
Abhishek Kekane 6951f8daac Fixed intermittent timeout/failing functional tests
In web-download import method functional tests we are trying to download
a file from 'https://www.openstack.org/assets/openstack-logo/2016R/OpenStack-Logo-Horizontal.eps.zip'.
Here we are assuming image is downloaded and will be active within 20
seconds else will be marked as failed. As of now these tests never
fails in local environment but, external networking will always be unreliable
from the CI environment which sometimes causes these tests to either
timeout or failure.

Instead of using external URL to download the image, deploying local http
server to dowload local image.

Closes-Bug: #1797571
Change-Id: I781666327f092ad439c23eca57128b8fd0334c89
2018-10-12 14:24:16 +00:00