Skip to content

tests.system.test_bucket: test_bucket_w_retention_period failed #910

@flaky-bot

Description

@flaky-bot

This test failed!

To configure my behavior, see the Flaky Bot documentation.

If I'm commenting on this issue too often, add the flakybot: quiet label and
I will stop commenting.


commit: c774ad5
buildURL: Build Status, Sponge
status: failed

Test output
storage_client = 
buckets_to_delete = []
blobs_to_delete = []
def test_bucket_w_retention_period(
    storage_client,
    buckets_to_delete,
    blobs_to_delete,
):
    period_secs = 10
    bucket_name = _helpers.unique_name("w-retention-period")
    bucket = _helpers.retry_429_503(storage_client.create_bucket)(bucket_name)
    buckets_to_delete.append(bucket)

    bucket.retention_period = period_secs
    bucket.default_event_based_hold = False
    bucket.patch()

    # Changes to the bucket will be readable immediately after writing,
    # but configuration changes may take time to propagate.
    _helpers.retry_has_retention_period(bucket.reload)()

    assert bucket.retention_period == period_secs
    assert isinstance(bucket.retention_policy_effective_time, datetime.datetime)
    assert not bucket.default_event_based_hold
    assert not bucket.retention_policy_locked

    blob_name = "test-blob"
    payload = b"DEADBEEF"
    blob = bucket.blob(blob_name)
    blob.upload_from_string(payload)

    blobs_to_delete.append(blob)

    other = bucket.get_blob(blob_name)
    _helpers.retry_has_retention_expiration(other.reload)()

    assert not other.event_based_hold
    assert not other.temporary_hold
    assert isinstance(other.retention_expiration_time, datetime.datetime)

    with pytest.raises(exceptions.Forbidden):
        other.delete()

    bucket.retention_period = None
    bucket.patch()

    # Changes to the bucket will be readable immediately after writing,
    # but configuration changes may take time to propagate.
    _helpers.retry_no_retention_period(bucket.reload)()

    assert bucket.retention_period is None
    assert bucket.retention_policy_effective_time is None
    assert not bucket.default_event_based_hold
    assert not bucket.retention_policy_locked

    _helpers.retry_no_retention_expiration(other.reload)()

    assert not other.event_based_hold
    assert not other.temporary_hold
    assert other.retention_expiration_time is None
  other.delete()

tests/system/test_bucket.py:682:


google/cloud/storage/blob.py:763: in delete
self.bucket.delete_blob(
google/cloud/storage/bucket.py:1650: in delete_blob
client._delete_resource(
google/cloud/storage/client.py:673: in _delete_resource
return self._connection.api_request(
google/cloud/storage/_http.py:72: in api_request
return call()
.nox/system-3-8/lib/python3.8/site-packages/google/api_core/retry.py:283: in retry_wrapped_func
return retry_target(
.nox/system-3-8/lib/python3.8/site-packages/google/api_core/retry.py:190: in retry_target
return target()


self = <google.cloud.storage._http.Connection object at 0x7effb775aa30>
method = 'DELETE', path = '/b/w-retention-period-1668702339004/o/test-blob'
query_params = {'generation': 1668702340605200}, data = None
content_type = None, headers = None, api_base_url = None, api_version = None
expect_json = True, _target_object = None, timeout = 60
extra_api_info = 'gccl-invocation-id/59caab06-0923-4dee-983f-3464e9cf1409'

def api_request(
    self,
    method,
    path,
    query_params=None,
    data=None,
    content_type=None,
    headers=None,
    api_base_url=None,
    api_version=None,
    expect_json=True,
    _target_object=None,
    timeout=_DEFAULT_TIMEOUT,
    extra_api_info=None,
):
    """Make a request over the HTTP transport to the API.

    You shouldn't need to use this method, but if you plan to
    interact with the API using these primitives, this is the
    correct one to use.

    :type method: str
    :param method: The HTTP method name (ie, ``GET``, ``POST``, etc).
                   Required.

    :type path: str
    :param path: The path to the resource (ie, ``'/b/bucket-name'``).
                 Required.

    :type query_params: dict or list
    :param query_params: A dictionary of keys and values (or list of
                         key-value pairs) to insert into the query
                         string of the URL.

    :type data: str
    :param data: The data to send as the body of the request. Default is
                 the empty string.

    :type content_type: str
    :param content_type: The proper MIME type of the data provided. Default
                         is None.

    :type headers: dict
    :param headers: extra HTTP headers to be sent with the request.

    :type api_base_url: str
    :param api_base_url: The base URL for the API endpoint.
                         Typically you won't have to provide this.
                         Default is the standard API base URL.

    :type api_version: str
    :param api_version: The version of the API to call.  Typically
                        you shouldn't provide this and instead use
                        the default for the library.  Default is the
                        latest API version supported by
                        google-cloud-python.

    :type expect_json: bool
    :param expect_json: If True, this method will try to parse the
                        response as JSON and raise an exception if
                        that cannot be done.  Default is True.

    :type _target_object: :class:`object`
    :param _target_object:
        (Optional) Protected argument to be used by library callers. This
        can allow custom behavior, for example, to defer an HTTP request
        and complete initialization of the object at a later time.

    :type timeout: float or tuple
    :param timeout: (optional) The amount of time, in seconds, to wait
        for the server response.

        Can also be passed as a tuple (connect_timeout, read_timeout).
        See :meth:`requests.Session.request` documentation for details.

    :type extra_api_info: string
    :param extra_api_info: (optional) Extra api info to be appended to
        the X-Goog-API-Client header

    :raises ~google.cloud.exceptions.GoogleCloudError: if the response code
        is not 200 OK.
    :raises ValueError: if the response content type is not JSON.
    :rtype: dict or str
    :returns: The API response payload, either as a raw string or
              a dictionary if the response is valid JSON.
    """
    url = self.build_api_url(
        path=path,
        query_params=query_params,
        api_base_url=api_base_url,
        api_version=api_version,
    )

    # Making the executive decision that any dictionary
    # data will be sent properly as JSON.
    if data and isinstance(data, dict):
        data = json.dumps(data)
        content_type = "application/json"

    response = self._make_request(
        method=method,
        url=url,
        data=data,
        content_type=content_type,
        headers=headers,
        target_object=_target_object,
        timeout=timeout,
        extra_api_info=extra_api_info,
    )

    if not 200 <= response.status_code < 300:
      raise exceptions.from_http_response(response)

E google.api_core.exceptions.Forbidden: 403 DELETE https://storage.googleapis.com/storage/v1/b/w-retention-period-1668702339004/o/test-blob?generation=1668702340605200&prettyPrint=false: Object 'w-retention-period-1668702339004/test-blob' is subject to bucket's retention policy and cannot be deleted, overwritten or archived until 2022-11-17T08:25:50.644575-08:00

.nox/system-3-8/lib/python3.8/site-packages/google/cloud/_http/init.py:494: Forbidden

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/python-storage API.flakybot: flakyTells the Flaky Bot not to close or comment on this issue.flakybot: issueAn issue filed by the Flaky Bot. Should not be added manually.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions