summaryrefslogtreecommitdiff
path: root/src/test/test_stats.c
AgeCommit message (Collapse)Author
2022-03-15test: Unit tests for overload onionskin ntorDavid Goulet
Part of #40560 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-12-14fixup! relay: Change DNS timeout label on MetricsPortDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-12-13Merge branch 'ticket40527_046_01' into ticket40527_047_01David Goulet
2021-12-13relay: Don't make DNS timeout trigger an overloadDavid Goulet
Tor has configure libevent to attempt up to 3 times a DNS query for a maximum of 5 seconds each. Once that 5 seconds has elapsed, it consider the query "Timed Out" but tor only gets a timeout if all 3 attempts have failed. For example, using Unbound, it has a much higher threshold of timeout. It is well defined in https://www.nlnetlabs.nl/documentation/unbound/info-timeout/ and has some complexity to it. But the gist is that if it times out, it will be much more than 5 seconds. And so the Tor DNS timeouts are more of a "UX issue" rather than a "network issue". For this reason, we are removing this metric from the overload general signal. See https://gitlab.torproject.org/tpo/network-health/team/-/issues/139 for more information. Fixes #40527 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-10-20relay: Overload state on DNS timeout is now X% over Y secsDavid Goulet
With this commit, we will only report a general overload state if we've seen more than X% of DNS timeout errors over Y seconds. Previous behavior was to report when a single timeout occured which is really too small of a threshold. The value X is a consensus parameters called "overload_dns_timeout_scale_percent" which is a scaled percentage (factor of 1000) so we can represent decimal points for X like 0.5% for instance. Its default is 1000 which ends up being 1%. The value Y is a consensus parameters called "overload_dns_timeout_period_secs" which is the time period for which will gather DNS errors and once over, we assess if that X% has been reached ultimately triggering a general overload signal. Closes #40491 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-10-20test: Add unit tests for DNS timeout overload stateDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-04-13relay: Move "overload-general" from extra-info to server descriptor.Alexander Færøy
Fixes #40364 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-03-18Terminate rep_hist_get_overload_stats_lines() with an NL.tor-0.4.6.1-alphaNick Mathewson
We use it in router.c, where chunks are joined with "", not with NL... so leaving off the terminating NL will lead to an unparseable extrainfo. Found by toralf. Bug not in any released Tor.
2021-03-17Merge branch 'mr/334'George Kadianakis
2021-03-17Rate-limit counter should increase once per minute.George Kadianakis
2021-03-17Implement backbone of overload statistics.George Kadianakis
- Implement overload statistics structure. - Implement function that keeps track of overload statistics. - Implement function that writes overload statistics to descriptor. - Unittest for the whole logic.
2021-03-12Update copyrights to 2021, using "make update-copyright"Nick Mathewson
2020-12-21Merge branch 'mr_240_squashed'Nick Mathewson
2020-12-21test: Fix memleak in test/load_stats_fileDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-12-21Fix timestamp parser in new load_stats_file.Karsten Loesing
The previous parser only considered stats files _starting_ with the timestamp tag, not stats files having the timestamp tag in a later position. While this applies to all current stats files, a future stats file might look differently. Better to fix the function now than be surprised in another 9 years from now. This commit also adds a test case for such future stats, and it fixes stats file paths in newly added unit tests.
2020-12-21relay: Report the entire content of a stats fileDavid Goulet
It turns out that 9 years ago, we stopped appending data into stats file and rather overwrite everytime we have new stats (see commit a6a127c833eace1100aca7ab8ad118862bb8a8b9) The load_stats_file() function was still thinking that we could have the same line many times in the file which turns out to be false since 9 years ago. However, that did not cause problem until IPv6 connection stats came along which introduced a new line in conn-stats: "ipv6-conn-bi-direct ...". Before, that file contained a single line starting with the tag "conn-bi-direct". That very tag appears also in the IPv6 tag (see above) so the load_stats_file() function would consider that the IPv6 line as the last tag to be appeneded to the file and fail to report the line above (for IPv4). It would actually truncate the IPv6 line and report it (removing the "ipv6-" part). In other words, "conn-bi-direct" was not reported and instead "ipv6-conn-bi-direct" was used without the "ipv6-" part. This commit refactors the entire function so that now it looks for a "timestamp tag" to validate and then if everything is fine, returns the entire content of the file. The refactor simplifies the function, adds logging in case of failures and modernize it in terms of coding standard. Unit tests are also added that makes sure the loaded content matches the entire file if timestamp validation passes. Fixes #40226 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-11-25Fix build on 32-bit Windows.Alexander Færøy
Currently Tor fails with the following error: src/test/test_stats.c: In function ‘test_rephist_v3_onions’: src/test/test_stats.c:527:22: error: overflow in implicit constant conversion [-Werror=overflow] update_approx_time(10101010101); This patch changes the constant passed to update_approx_time() to avoid the overflow in the implicit conversion. See: tor#40199
2020-11-03Switch v3_onions_seen_this_period to digest256map_t.George Kadianakis
2020-11-03Abstract v2/v3 "format stats to str" logic into a single function.George Kadianakis
2020-11-03Write unittests for v3 metrics.George Kadianakis
2020-08-01Fix a leak-on-failure on test_get_bandwidth_lines()Nick Mathewson
Spotted by coverity. This is CID 1465571.
2020-07-31test_stats : Removed CONFIG_PRIVATEMrSquanchee
Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
2020-07-31Added tests for bandwidth functionsMrSquanchee
Added tests for 1. commit_max 2. advance_obs 3. add_obs 4. rep_hist_fill_bandwidth_history 5. rep_hist_get_bandwidth_lines (Lightly edited by nickm to use new names from bwhist refactoring.) Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
2020-07-31Added tests for bandwidth functionsMrSquanchee
Added tests for 1. commit_max 2. advance_obs 3. add_obs 4. rep_hist_fill_bandwidth_history 5. rep_hist_get_bandwidth_lines Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
2020-07-10Collect IPv6 bidi connection statisticsNick Mathewson
2020-07-10Change connstats.c identifers to start with conn_statsNick Mathewson
This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ rep_hist_conn_stats_init conn_stats_init \ rep_hist_note_or_conn_bytes conn_stats_note_or_conn_bytes \ rep_hist_reset_conn_stats conn_stats_reset \ rep_hist_format_conn_stats conn_stats_format \ rep_hist_conn_stats_write conn_stats_save \ rep_hist_conn_stats_term conn_stats_terminate \ bidi_map_free_all conn_stats_free_all
2020-07-10Split bidi connection-stats code into a new C file.Nick Mathewson
2020-01-08It's 2020. Update the copyright dates with "make update-copyright"Nick Mathewson
2019-11-05test/stats: Add minimal tests for rephist mtbfteor
Part of 32213.
2019-11-05test: Split stats into its own fileteor
Part of 32213.