Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

fix: Fix for flaky test_read_timestamp_client_side_autocommit test - #1071

Merged
ankiaga merged 4 commits into
googleapis:mainfrom
ankiaga:fix
Jan 10, 2024
Merged

fix: Fix for flaky test_read_timestamp_client_side_autocommit test#1071
ankiaga merged 4 commits into
googleapis:mainfrom
ankiaga:fix

Conversation

@ankiaga

Copy link
Copy Markdown
Contributor

No description provided.

@ankiaga
ankiaga requested review from a teamJanuary 10, 2024 04:37
@product-auto-labelproduct-auto-labelBot added size: xs Pull request size is extra small. api: spanner Issues related to the googleapis/python-spanner API. labels Jan 10, 2024
@ankiagaankiaga changed the title fix: Disabling flaky assertion for test_read_timestamp_client_side_autocommit testfix: Fix for flaky test_read_timestamp_client_side_autocommit testJan 10, 2024
assert isinstance(read_timestamp_query_result_1[0][0], DatetimeWithNanoseconds)

time.sleep(0.25)
self._cursor.execute("SELECT * FROM contacts")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you feel we need to test this command twice? This way we can avoid sleep, just thoughts.
Java does it only once and validates the type of result. https://github.com/googleapis/java-spanner/blob/58f94b200276d879f83e4432716b49baf3206226/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionImplTest.java#L1003

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand your comment clearly. We are executing command twice because we want to confirm that the state is updated in the cursor class and that read timestamps are different.

Also removed the sleep command and inserting a row after discussion with Knut

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it should not be necessary to set the connection in read-only mode for this as long as we are in auto-commit mode. (Having it in read-only mode also does not hurt, so feel free to leave as-is, as long as we are confident that it would work with self._conn.read_only=False` as well.)

@harshachintaharshachinta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but wondering why do we need to execute the command twice and verify the read_timestamp of both.

@ankiagaankiaga added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 10, 2024
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 10, 2024
@ankiagaankiaga added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 10, 2024
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 10, 2024

@olavloiteolavloite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

assert isinstance(read_timestamp_query_result_1[0][0], DatetimeWithNanoseconds)

time.sleep(0.25)
self._cursor.execute("SELECT * FROM contacts")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it should not be necessary to set the connection in read-only mode for this as long as we are in auto-commit mode. (Having it in read-only mode also does not hurt, so feel free to leave as-is, as long as we are confident that it would work with self._conn.read_only=False` as well.)

@ankiaga
ankiaga enabled auto-merge (squash) January 10, 2024 11:48
@ankiaga
ankiaga merged commit 0406ded into googleapis:mainJan 10, 2024
@release-pleaserelease-pleaseBot mentioned this pull request Jan 10, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: spannerIssues related to the googleapis/python-spanner API.size: xsPull request size is extra small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@ankiaga@olavloite@harshachinta@yoshi-kokoro