Skip to content
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

System test test_iam_policy fails with PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python #1159

Open
parthea opened this issue Jul 8, 2024 · 0 comments
Assignees
Labels
api: spanner Issues related to the googleapis/python-spanner API. type: cleanup An internal cleanup or hygiene concern.

Comments

@parthea
Copy link
Contributor

parthea commented Jul 8, 2024

See the presubmit failure Kokoro Prerelease Dependencies in PR #1156 where the system test test_iam_policy fails when using PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python.

To reproduce the issue, install this library using pip install . and run PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python pytest tests/system/test_writer.py::test_append_rows_with_proto3


=================================== FAILURES ===================================
_______________________________ test_iam_policy ________________________________

not_emulator = None
shared_instance = 
databases_to_delete = []

    def test_iam_policy(
        not_emulator,
        shared_instance,
        databases_to_delete,
    ):
        pool = spanner_v1.BurstyPool(labels={"testcase": "iam_policy"})
        temp_db_id = _helpers.unique_id("iam_db", separator="_")
        create_table = (
            "CREATE TABLE policy (\n"
            + "    Id      STRING(36) NOT NULL,\n"
            + "    Field1  STRING(36) NOT NULL\n"
            + ") PRIMARY KEY (Id)"
        )
        create_role = "CREATE ROLE parent"
    
        temp_db = shared_instance.database(
            temp_db_id,
            ddl_statements=[create_table, create_role],
            pool=pool,
        )
        create_op = temp_db.create()
        databases_to_delete.append(temp_db)
        create_op.result(DBAPI_OPERATION_TIMEOUT)
        policy = temp_db.get_iam_policy(3)
    
        assert policy.version == 0
        assert policy.etag == b"\x00 \x01"
    
        new_binding = policy_pb2.Binding(
            role="<REDACTED>",
            members=["<REDACTED>"],
            condition=expr_pb2.Expr(
                title="condition title",
                expression='resource.name.endsWith("/databaseRoles/parent")',
            ),
        )
    
        policy.version = 3
        policy.bindings.append(new_binding)
        temp_db.set_iam_policy(policy)
    
        new_policy = temp_db.get_iam_policy(3)
        assert new_policy.version == 3
>       assert new_policy.bindings == [new_binding]

tests/system/test_database_api.py:297: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = [role: <REDACTED>
members: <REDACTED>
condition {
  expression: "resource.name.endsWith(\"/databaseRoles/parent\")"
  title: "condition title"
}
]
other = [role: <REDACTED>
members: <REDACTED>
condition {
  expression: "resource.name.endsWith(\"/databaseRoles/parent\")"
  title: "condition title"
}
]

    def __eq__(self, other: Any) -> bool:
      """Compares the current instance with another one."""
      if self is other:
        return True
      if not isinstance(other, self.__class__):
>       raise TypeError('Can only compare repeated composite fields against '
                        'other repeated composite fields.')
E       TypeError: Can only compare repeated composite fields against other repeated composite fields.

.nox/8f8a4a6e/lib/python3.12/site-packages/google/protobuf/internal/containers.py:328: TypeError
=============================== warnings summary ===============================
@parthea parthea added the type: cleanup An internal cleanup or hygiene concern. label Jul 8, 2024
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/python-spanner API. label Jul 8, 2024
@parthea parthea mentioned this issue Jul 12, 2024
1 task
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. type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

No branches or pull requests

2 participants