googleapis / python-spanner

Apache License 2.0
136 stars 88 forks source link

tests.system.test_session_api: test_transaction_batch_update_w_parent_span failed #951

Closed flaky-bot[bot] closed 1 year ago

flaky-bot[bot] commented 1 year ago

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

Test output
sessions_database = 
sessions_to_delete = []
ot_exporter = 
database_dialect = 

    @pytest.mark.skipif(
        not ot_helpers.HAS_OPENTELEMETRY_INSTALLED,
        reason="trace requires OpenTelemetry",
    )
    def test_transaction_batch_update_w_parent_span(
        sessions_database, sessions_to_delete, ot_exporter, database_dialect
    ):
        from opentelemetry import trace

        sd = _sample_data
        param_types = spanner_v1.param_types
        tracer = trace.get_tracer(__name__)

        session = sessions_database.session()
        session.create()
        sessions_to_delete.append(session)

        with session.batch() as batch:
            batch.delete(sd.TABLE, sd.ALL)

        keys = (
            ["p1", "p2"]
            if database_dialect == DatabaseDialect.POSTGRESQL
            else ["contact_id", "email"]
        )
        placeholders = (
            ["$1", "$2"]
            if database_dialect == DatabaseDialect.POSTGRESQL
            else [f"@{key}" for key in keys]
        )

        insert_statement = list(_generate_insert_statements())[0]
        update_statement = (
            f"UPDATE contacts SET email = {placeholders[1]} WHERE contact_id = {placeholders[0]};",
            {keys[0]: 1, keys[1]: "phreddy@example.com"},
            {keys[0]: param_types.INT64, keys[1]: param_types.STRING},
        )
        delete_statement = (
            f"DELETE FROM contacts WHERE contact_id = {placeholders[0]};",
            {keys[0]: 1},
            {keys[0]: param_types.INT64},
        )

        def unit_of_work(transaction):

            status, row_counts = transaction.batch_update(
                [insert_statement, update_statement, delete_statement]
            )
            _check_batch_status(status.code)
            assert len(row_counts) == 3
            for row_count in row_counts:
                assert row_count == 1

        with tracer.start_as_current_span("Test Span"):
            session.run_in_transaction(unit_of_work)

        span_list = ot_exporter.get_finished_spans()
>       assert len(span_list) == 5
E       assert 7 == 5
E        +  where 7 = len((, , , ...))

tests/system/test_session_api.py:1115: AssertionError
flaky-bot[bot] commented 1 year ago

Looks like this issue is flaky. :worried:

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

A human should fix and close this.


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