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

Fix unstable tests by adding 'retry_until()' #5394

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jiahuili430
Copy link
Contributor

@jiahuili430 jiahuili430 commented Jan 10, 2025

Overview

Add retry_until() to avoid request timeout error in search_test.exs.

Error logs:

1) test search returns all items for GET (SearchTest)
   test/elixir/test/search_test.exs:67
   ** (KeyError) key :status_code not found in: %HTTPotion.ErrorResponse{message: "req_timedout"}
	 code: assert resp.status_code == 200
	 stacktrace:
	   test/elixir/test/search_test.exs:74: (test)

Testing recommendations

make elixir-search

Related Issues or Pull Requests

Checklist

  • Code is written and works correctly
  • Changes are covered by tests
  • Any new configurable parameters are documented in rel/overlay/etc/default.ini
  • Documentation changes were made in the src/docs folder
  • Documentation changes were backported (separated PR) to affected branches

@jiahuili430 jiahuili430 changed the title XRFix unstable tests by adding 'retry_until()' Fix unstable tests by adding 'retry_until()' Jan 10, 2025
@jiahuili430 jiahuili430 marked this pull request as draft January 10, 2025 19:50
@@ -71,7 +71,7 @@ defmodule SearchTest do

url = "/#{db_name}/_design/inventory/_search/fruits"
resp = Couch.get(url, query: %{q: "*:*", include_docs: true})
assert resp.status_code == 200
retry_until(fn -> resp.status_code == 200 end)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can do on extra single assert below, just to ensure it's not flapping and once it's hits 200 it stays 200

Copy link
Contributor

Choose a reason for hiding this comment

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

How does retry_until work? Do it have any magic to throw an exception and the whole test body up to that point is retried. Otherwise, if it's as simple as it looks in retry_until(fn -> resp.status_code == 200 end) we'd just be checking the same response and always fail, then we'd have to retry the whole Couch.get(...)?

Add `retry_until()` to avoid request timeout error in search_test.exs.

Error logs:
```
1) test search returns all items for GET (SearchTest)
   test/elixir/test/search_test.exs:67
   ** (KeyError) key :status_code not found in: %HTTPotion.ErrorResponse{message: "req_timedout"}
	 code: assert resp.status_code == 200
	 stacktrace:
	   test/elixir/test/search_test.exs:74: (test)
```
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.

2 participants