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

tests: Fix Storage flakes #12605

Merged
merged 6 commits into from
Apr 19, 2024
Merged

Conversation

amanda-tarafa
Copy link
Contributor

@jskeet as always, one commit at a time.

@amanda-tarafa amanda-tarafa requested review from a team as code owners April 19, 2024 06:07
Copy link
Collaborator

@jskeet jskeet left a comment

Choose a reason for hiding this comment

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

A couple of very optional suggestions, but we can do them later if we want to do them at all.

// as that's meant to be the time for the change to be eventually consistent.
DateTimeOffset shouldSucceedAfter = DateTimeOffset.UtcNow
+ delayUntilGuaranteedConsistency
// We add 3 seconds just to be on the safe side of clock skews.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Clock skews shouldn't affect this, because it's all relative to the same (local) clock, right? I think we should be able to get rid of that. It doesn't do any harm though...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, you are right.

backoffMs = Math.Max(2 * backoffMs, maxBackoffMs);
}

}while (retry);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: space after } and remove blank line before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

private readonly StorageFixture _fixture;

public HmacKeysTest(StorageFixture fixture) => _fixture = fixture;

[Fact]
public void Lifecycle()
// This test is async because of the helpers for testing eventually consistent changes.
// We are testing sync production code though.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Presumably we could just test the async code instead? Remove a Task.CompletedTask from each lambda...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternatively, we could add an overload of EventuallyAsync that accepts an Action instead of a Func<Task>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the overload and updated these.

@@ -288,6 +288,41 @@ private void CreateAndPopulateReadBucket()

internal void UnregisterBucket(string bucket) => _bucketsToDelete.Remove(bucket);

internal async Task EventuallyAsync(Func<Task> action, TimeSpan delayUntilGuaranteedConsistency)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Having looked at later commits:

  • The calling code might be clearer if we put the timespan first
  • We might want to add an overload taking an Action. (That could call this overload just by calling the action and then returning a completed task.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, done on both.

Copy link
Contributor Author

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

All comments addressed in ordered review commits that I'll push shortly. Thanks!

@@ -288,6 +288,41 @@ private void CreateAndPopulateReadBucket()

internal void UnregisterBucket(string bucket) => _bucketsToDelete.Remove(bucket);

internal async Task EventuallyAsync(Func<Task> action, TimeSpan delayUntilGuaranteedConsistency)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, done on both.

// as that's meant to be the time for the change to be eventually consistent.
DateTimeOffset shouldSucceedAfter = DateTimeOffset.UtcNow
+ delayUntilGuaranteedConsistency
// We add 3 seconds just to be on the safe side of clock skews.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, you are right.

backoffMs = Math.Max(2 * backoffMs, maxBackoffMs);
}

}while (retry);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

private readonly StorageFixture _fixture;

public HmacKeysTest(StorageFixture fixture) => _fixture = fixture;

[Fact]
public void Lifecycle()
// This test is async because of the helpers for testing eventually consistent changes.
// We are testing sync production code though.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the overload and updated these.

@amanda-tarafa
Copy link
Contributor Author

After addressing all comments, these are all green, also locally. Squashing and merging. Thanks!

Given that changes are only eventually consistent.
Given that metadata changes are only eventually effective.
To avoid reaching bucket modification quota.
An HMAC key is not available for use up to 30 seconds after creation.
So that we know what exactly happened if there's a failure.
@amanda-tarafa amanda-tarafa merged commit 3a3f8d5 into googleapis:main Apr 19, 2024
10 checks passed
@amanda-tarafa amanda-tarafa deleted the storage-flakes branch April 19, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants