Skip to content

System test test_iam_policy fails with PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python #1159

@parthea

Description

@parthea

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 ===============================

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/python-spanner API.type: cleanupAn internal cleanup or hygiene concern.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions