Skip to content

tests.system.test_database_api: test_create_role_grant_access_success failed #994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
flaky-bot bot opened this issue Aug 4, 2023 · 1 comment
Closed
Labels
api: spanner Issues related to the googleapis/python-spanner API. flakybot: flaky Tells the Flaky Bot not to close or comment on this issue. flakybot: issue An issue filed by the Flaky Bot. Should not be added manually. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@flaky-bot
Copy link

flaky-bot bot commented Aug 4, 2023

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: a32594f
buildURL: Build Status, Sponge
status: failed

Test output
not_emulator = None
shared_instance = 
databases_to_delete = []
database_dialect = 
def test_create_role_grant_access_success(
    not_emulator, shared_instance, databases_to_delete, database_dialect
):
    creator_role_parent = _helpers.unique_id("role_parent", separator="_")
    creator_role_orphan = _helpers.unique_id("role_orphan", separator="_")

    temp_db_id = _helpers.unique_id("dfl_ldrr_upd_ddl", separator="_")
    temp_db = shared_instance.database(temp_db_id, database_dialect=database_dialect)

    create_op = temp_db.create()
    databases_to_delete.append(temp_db)
    create_op.result(DBAPI_OPERATION_TIMEOUT)  # raises on failure / timeout.
    # Create role and grant select permission on table contacts for parent role.
    if database_dialect == DatabaseDialect.GOOGLE_STANDARD_SQL:
        ddl_statements = _helpers.DDL_STATEMENTS + [
            f"CREATE ROLE {creator_role_parent}",
            f"CREATE ROLE {creator_role_orphan}",
            f"GRANT SELECT ON TABLE contacts TO ROLE {creator_role_parent}",
        ]
    elif database_dialect == DatabaseDialect.POSTGRESQL:
        ddl_statements = _helpers.DDL_STATEMENTS + [
            f"CREATE ROLE {creator_role_parent}",
            f"CREATE ROLE {creator_role_orphan}",
            f"GRANT SELECT ON TABLE contacts TO {creator_role_parent}",
        ]

    operation = temp_db.update_ddl(ddl_statements)
    operation.result(DBAPI_OPERATION_TIMEOUT)  # raises on failure / timeout.

    # Perform select with orphan role on table contacts.
    # Expect PermissionDenied exception.
    temp_db = shared_instance.database(temp_db_id, database_role=creator_role_orphan)
    with pytest.raises(exceptions.PermissionDenied):
        with temp_db.snapshot() as snapshot:
            results = snapshot.execute_sql("SELECT * FROM contacts")
            for row in results:
                pass

    # Perform select with parent role on table contacts. Expect success.
    temp_db = shared_instance.database(temp_db_id, database_role=creator_role_parent)
    with temp_db.snapshot() as snapshot:
        snapshot.execute_sql("SELECT * FROM contacts")

    if database_dialect == DatabaseDialect.GOOGLE_STANDARD_SQL:
        ddl_remove_roles = [
            f"REVOKE SELECT ON TABLE contacts FROM ROLE {creator_role_parent}",
            f"DROP ROLE {creator_role_parent}",
            f"DROP ROLE {creator_role_orphan}",
        ]
    elif database_dialect == DatabaseDialect.POSTGRESQL:
        ddl_remove_roles = [
            f"REVOKE SELECT ON TABLE contacts FROM {creator_role_parent}",
            f"DROP ROLE {creator_role_parent}",
            f"DROP ROLE {creator_role_orphan}",
        ]
    # Revoke permission and Delete roles.
    operation = temp_db.update_ddl(ddl_remove_roles)
  operation.result(DBAPI_OPERATION_TIMEOUT)  # raises on failure / timeout.

tests/system/test_database_api.py:469:


self = <google.api_core.operation.Operation object at 0x7f633c1f8490>
timeout = 240, retry = None, polling = None

def result(self, timeout=_DEFAULT_VALUE, retry=None, polling=None):
    """Get the result of the operation.

    This method will poll for operation status periodically, blocking if
    necessary. If you just want to make sure that this method does not block
    for more than X seconds and you do not care about the nitty-gritty of
    how this method operates, just call it with ``result(timeout=X)``. The
    other parameters are for advanced use only.

    Every call to this method is controlled by the following three
    parameters, each of which has a specific, distinct role, even though all three
    may look very similar: ``timeout``, ``retry`` and ``polling``. In most
    cases users do not need to specify any custom values for any of these
    parameters and may simply rely on default ones instead.

    If you choose to specify custom parameters, please make sure you've
    read the documentation below carefully.

    First, please check :class:`google.api_core.retry.Retry`
    class documentation for the proper definition of timeout and deadline
    terms and for the definition the three different types of timeouts.
    This class operates in terms of Retry Timeout and Polling Timeout. It
    does not let customizing RPC timeout and the user is expected to rely on
    default behavior for it.

    The roles of each argument of this method are as follows:

    ``timeout`` (int): (Optional) The Polling Timeout as defined in
    :class:`google.api_core.retry.Retry`. If the operation does not complete
    within this timeout an exception will be thrown. This parameter affects
    neither Retry Timeout nor RPC Timeout.

    ``retry`` (google.api_core.retry.Retry): (Optional) How to retry the
    polling RPC. The ``retry.timeout`` property of this parameter is the
    Retry Timeout as defined in :class:`google.api_core.retry.Retry`.
    This parameter defines ONLY how the polling RPC call is retried
    (i.e. what to do if the RPC we used for polling returned an error). It
    does NOT define how the polling is done (i.e. how frequently and for
    how long to call the polling RPC); use the ``polling`` parameter for that.
    If a polling RPC throws and error and retrying it fails, the whole
    future fails with the corresponding exception. If you want to tune which
    server response error codes are not fatal for operation polling, use this
    parameter to control that (``retry.predicate`` in particular).

    ``polling`` (google.api_core.retry.Retry): (Optional) How often and
    for how long to call the polling RPC periodically (i.e. what to do if
    a polling rpc returned successfully but its returned result indicates
    that the long running operation is not completed yet, so we need to
    check it again at some point in future). This parameter does NOT define
    how to retry each individual polling RPC in case of an error; use the
    ``retry`` parameter for that. The ``polling.timeout`` of this parameter
    is Polling Timeout as defined in as defined in
    :class:`google.api_core.retry.Retry`.

    For each of the arguments, there are also default values in place, which
    will be used if a user does not specify their own. The default values
    for the three parameters are not to be confused with the default values
    for the corresponding arguments in this method (those serve as "not set"
    markers for the resolution logic).

    If ``timeout`` is provided (i.e.``timeout is not _DEFAULT VALUE``; note
    the ``None`` value means "infinite timeout"), it will be used to control
    the actual Polling Timeout. Otherwise, the ``polling.timeout`` value
    will be used instead (see below for how the ``polling`` config itself
    gets resolved). In other words, this parameter  effectively overrides
    the ``polling.timeout`` value if specified. This is so to preserve
    backward compatibility.

    If ``retry`` is provided (i.e. ``retry is not None``) it will be used to
    control retry behavior for the polling RPC and the ``retry.timeout``
    will determine the Retry Timeout. If not provided, the
    polling RPC will be called with whichever default retry config was
    specified for the polling RPC at the moment of the construction of the
    polling RPC's client. For example, if the polling RPC is
    ``operations_client.get_operation()``, the ``retry`` parameter will be
    controlling its retry behavior (not polling  behavior) and, if not
    specified, that specific method (``operations_client.get_operation()``)
    will be retried according to the default retry config provided during
    creation of ``operations_client`` client instead. This argument exists
    mainly for backward compatibility; users are very unlikely to ever need
    to set this parameter explicitly.

    If ``polling`` is provided (i.e. ``polling is not None``), it will be used
    to control the overall polling behavior and ``polling.timeout`` will
    control Polling Timeout unless it is overridden by ``timeout`` parameter
    as described above. If not provided, the``polling`` parameter specified
    during construction of this future (the ``polling`` argument in the
    constructor) will be used instead. Note: since the ``timeout`` argument may
    override ``polling.timeout`` value, this parameter should be viewed as
    coupled with the ``timeout`` parameter as described above.

    Args:
        timeout (int): (Optional) How long (in seconds) to wait for the
            operation to complete. If None, wait indefinitely.
        retry (google.api_core.retry.Retry): (Optional) How to retry the
            polling RPC. This defines ONLY how the polling RPC call is
            retried (i.e. what to do if the RPC we used for polling returned
            an error). It does  NOT define how the polling is done (i.e. how
            frequently and for how long to call the polling RPC).
        polling (google.api_core.retry.Retry): (Optional) How often and
            for how long to call polling RPC periodically. This parameter
            does NOT define how to retry each individual polling RPC call
            (use the ``retry`` parameter for that).

    Returns:
        google.protobuf.Message: The Operation's result.

    Raises:
        google.api_core.GoogleAPICallError: If the operation errors or if
            the timeout is reached before the operation completes.
    """

    self._blocking_poll(timeout=timeout, retry=retry, polling=polling)

    if self._exception is not None:
        # pylint: disable=raising-bad-type
        # Pylint doesn't recognize that this is valid in this case.
      raise self._exception

E google.api_core.exceptions.FailedPrecondition: 400 Role not found: role_parent_1691134147586. 9: Role not found: role_parent_1691134147586.

.nox/prerelease_deps-3-8-database_dialect-postgresql/lib/python3.8/site-packages/google/api_core/future/polling.py:261: FailedPrecondition

@flaky-bot flaky-bot bot added flakybot: issue An issue filed by the Flaky Bot. Should not be added manually. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Aug 4, 2023
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/python-spanner API. label Aug 4, 2023
@flaky-bot flaky-bot bot added the flakybot: flaky Tells the Flaky Bot not to close or comment on this issue. label Aug 4, 2023
@flaky-bot
Copy link
Author

flaky-bot bot commented Aug 4, 2023

Looks like this issue is flaky. 😟

I'm going to leave this open and stop commenting.

A human should fix and close this.


When run at the same commit (a32594f), this test passed in one build (Build Status, Sponge) and failed in another build (Build Status, Sponge).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner API. flakybot: flaky Tells the Flaky Bot not to close or comment on this issue. flakybot: issue An issue filed by the Flaky Bot. Should not be added manually. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant