Skip to content

cfg: fix losing stats parameter on update #287

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed

### Fixed
* Preset `stats_quantile_tolerated_error` `crud.cfg` parameter is no
more lost on configuration update (#284).

## [0.11.1] - 06-05-22

Expand Down
2 changes: 1 addition & 1 deletion crud/cfg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ local function configure_stats(cfg, opts)
opts.stats_quantiles = cfg.stats_quantiles
end

if opts.stats_quantiles == nil then
if opts.stats_quantile_tolerated_error == nil then
opts.stats_quantile_tolerated_error = cfg.stats_quantile_tolerated_error
end

Expand Down
22 changes: 22 additions & 0 deletions test/integration/cfg_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,25 @@ group.test_role_reload_preserves_values = function(g)
local cfg = router:eval("return require('crud').cfg")
t.assert_equals(cfg.stats, true)
end

group.test_gh_284_preset_stats_quantile_tolerated_error_is_preserved = function(g)
-- Arrange some cfg values so test case will not depend on defaults.
local cfg = g.cluster:server('router'):eval(
"return require('crud').cfg(...)",
{{ stats = false }})
t.assert_equals(cfg.stats, false)

-- Set stats_quantile_tolerated_error.
local cfg = g.cluster:server('router'):eval(
"return require('crud').cfg(...)",
{{ stats_quantile_tolerated_error = 1e-4 }})
t.assert_equals(cfg.stats_quantile_tolerated_error, 1e-4)

-- Set another cfg parameter, assert preset stats_quantile_tolerated_error presents.
local cfg = g.cluster:server('router'):eval(
"return require('crud').cfg(...)",
{{ stats = true }})
t.assert_equals(cfg.stats, true)
t.assert_equals(cfg.stats_quantile_tolerated_error, 1e-4,
'Preset stats_quantile_tolerated_error presents')
end