-
Notifications
You must be signed in to change notification settings - Fork 23
chore(spec): clean fellowship sediment + retry commands eventually #212
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
Merged
nijeesh-stream
merged 2 commits into
master
from
nijeeshjoshy/chore-fix-queries-users-flake
May 13, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --require spec_helper | ||
| --format documentation | ||
| --profile 25 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # Block matcher that retries `expect { ... }` against an inner matcher until | ||
| # it passes or the budget runs out. Designed for the eventually-consistent | ||
| # bits of the shared-CI backend (e.g. create_command -> get_command races). | ||
| # | ||
| # expect { client.get_command(name) }.to eventually(include('name' => name)) | ||
| # | ||
| # Tweak the budget with chainable `.with_retries(n)` / `.every(seconds)`. | ||
| RSpec::Matchers.define :eventually do |inner_matcher| | ||
| supports_block_expectations | ||
|
|
||
| match do |block| | ||
| @retries = (defined?(@retries_value) && @retries_value) || 3 | ||
| @interval = (defined?(@interval_value) && @interval_value) || 1 | ||
| @last_actual = nil | ||
| @last_error = nil | ||
| attempts = 0 | ||
| loop do | ||
| begin | ||
| @last_actual = block.call | ||
| break true if inner_matcher.matches?(@last_actual) | ||
| rescue StandardError, RSpec::Expectations::ExpectationNotMetError => e | ||
| @last_error = e | ||
| end | ||
| attempts += 1 | ||
| break false if attempts >= @retries | ||
|
|
||
| sleep(@interval) | ||
| end | ||
| end | ||
|
|
||
| chain :with_retries do |n| | ||
| @retries_value = n | ||
| end | ||
|
|
||
| chain :every do |seconds| | ||
| @interval_value = seconds | ||
| end | ||
|
|
||
| failure_message do |_block| | ||
| msg = "expected block to eventually #{inner_matcher.description}" | ||
| msg += "; last value: #{@last_actual.inspect}" unless @last_actual.nil? | ||
| msg += "; last error: #{@last_error.message}" if @last_error | ||
| msg | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # Per-test wall-clock timing emitted to STDOUT so CI logs surface which | ||
| # example is in flight when a runner stalls. The default `--format | ||
| # documentation` reporter prints test names but not timing; `--profile` | ||
| # only summarises at the end (no help when the run hangs before reaching | ||
| # the summary). This hook fills the gap: every example logs | ||
| # `[timing] start ...` on enter and `[timing] N.NN s ...` on exit with | ||
| # its full description path, so an unattended runner stuck mid-test | ||
| # leaves a clear breadcrumb. | ||
| RSpec.configure do |config| | ||
| config.before(:each) do |example| | ||
| example.metadata[:timing_started_at] = Process.clock_gettime(Process::CLOCK_MONOTONIC) | ||
| warn "[timing] start #{example.full_description}" | ||
| end | ||
|
|
||
| config.after(:each) do |example| | ||
| started_at = example.metadata[:timing_started_at] | ||
| next unless started_at | ||
|
|
||
| elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started_at | ||
| status = example.exception ? 'fail' : 'pass' | ||
| warn format( | ||
| '[timing] %<elapsed>.2f s %<status>s %<description>s', | ||
| elapsed: elapsed, | ||
| status: status, | ||
| description: example.full_description | ||
| ) | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.