-
Notifications
You must be signed in to change notification settings - Fork 85
Add half_open_resource_timeout for net http #198
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,8 @@ Metrics/MethodLength: | |
|
|
||
| Metrics/ClassLength: | ||
| Max: 500 | ||
| Exclude: | ||
| - test/**/* | ||
|
|
||
| Metrics/AbcSize: | ||
| Max: 50 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,42 @@ def test_semian_identifier | |
| end | ||
| end | ||
|
|
||
| def test_changes_timeout_when_half_open_and_configured | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if I'm doing this right, is there a better way of half opening the circuit?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'll need help with this test, I can't seem to be able to trigger the right thing. I do hit the |
||
| http = Net::HTTP.new(SemianConfig['toxiproxy_upstream_host'], SemianConfig['http_toxiproxy_port']) | ||
| expected_read_timeout = http.read_timeout | ||
| expected_open_timeout = http.open_timeout | ||
| options = proc do |host, port| | ||
| { | ||
| tickets: 3, | ||
| success_threshold: 2, | ||
| error_threshold: 2, | ||
| error_timeout: 10, | ||
| open_circuit_server_errors: true, | ||
| name: "#{host}_#{port}", | ||
| half_open_resource_timeout: 1, | ||
| } | ||
| end | ||
|
|
||
| with_semian_configuration(options) do | ||
| with_server do | ||
| Toxiproxy['semian_test_net_http'].downstream(:latency, latency: 2000).apply do | ||
| http.get('/200') | ||
| end | ||
|
|
||
| half_open_cicuit! | ||
|
|
||
| Toxiproxy['semian_test_net_http'].downstream(:latency, latency: 2000).apply do | ||
| assert_raises Net::ReadTimeout do | ||
| http.get('/200') | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| assert_equal expected_read_timeout, http.read_timeout | ||
| assert_equal expected_open_timeout, http.open_timeout | ||
| end | ||
|
|
||
| def test_trigger_open | ||
| with_semian_configuration do | ||
| with_server do | ||
|
|
@@ -396,6 +432,12 @@ def test_persistent_state_after_server_restart | |
|
|
||
| private | ||
|
|
||
| def half_open_cicuit!(backwards_time_travel = 10) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sirupsen I wanted to use the CircuitBreakerHelper but the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine with me. |
||
| Timecop.travel(Time.now - backwards_time_travel) do | ||
| open_circuit! | ||
| end | ||
| end | ||
|
|
||
| def with_semian_configuration(options = DEFAULT_SEMIAN_CONFIGURATION) | ||
| orig_semian_options = Semian::NetHTTP.semian_configuration | ||
| Semian::NetHTTP.instance_variable_set(:@semian_configuration, nil) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this? 👂
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small bikeshed, I can bring back the old syntax. I am used to assigning the value directly from the if, not sure which syntax you guys prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for context: The reason this kind of thing might frowned upon is because it causes a 7 line diff that we have to review manually to ensure that a typo size bug isn't added to the library.