googleapis/python-spanner

tests.system.test_session_api: test_transaction_batch_update_w_parent_span failed

flaky-bot opened this issue · 2 comments

Note: #951 was also for this test, but it was closed more than 10 days ago. So, I didn't mark it flaky.


commit: 78b73f0
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 6 == 5
E + where 6 = len((<opentelemetry.sdk.trace.ReadableSpan object at 0x7fd8984eba60>, <opentelemetry.sdk.trace.ReadableSpan object at 0x7f...etry.sdk.trace.ReadableSpan object at 0x7fd8984969a0>, <opentelemetry.sdk.trace.ReadableSpan object at 0x7fd8984ebd30>))

tests/system/test_session_api.py:1115: AssertionError

Test passed for commit a973a3a (Build Status, Sponge)! Closing this issue.

Looks like this issue is flaky. 😟

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

A human should fix and close this.


commit: a8fb395
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((<opentelemetry.sdk.trace.ReadableSpan object at 0x7fdc3677e670>, <opentelemetry.sdk.trace.ReadableSpan object at 0x7f...sdk.trace.ReadableSpan object at 0x7fdc3679bca0>, <opentelemetry.sdk.trace.ReadableSpan object at 0x7fdc3679b220>, ...))

tests/system/test_session_api.py:1115: AssertionError