summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@fscked.org>2010-07-06 08:49:50 -0700
committerMike Perry <mikeperry-git@fscked.org>2010-07-06 12:11:13 -0700
commit7bbdf71a82bb064b2ca0eb3a296b4abab6b5ff2b (patch)
treebde6a589e599d25866d7d6c7a357c33601d1bfcb /src/test
parent6bb8747ffbd18e08f9724bb8e4f2a16f22ed6612 (diff)
downloadtor-7bbdf71a82bb064b2ca0eb3a296b4abab6b5ff2b.tar.gz
tor-7bbdf71a82bb064b2ca0eb3a296b4abab6b5ff2b.zip
Fix unittest failure in bug 1660.
We now record large times as abandoned, to prevent a filter step from happening and skewing our results. Also, issue a warn for a rare case that can happen for funky values of Xm or too many abandoned circuits. Can happen (very rarely) during unit tests, but should not be possble during live operation, due to network liveness filters and discard logic.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/test/test.c b/src/test/test.c
index fbcfedbc9a..a753db27f6 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -470,6 +470,7 @@ test_circuit_timeout(void)
or_state_t state;
char *msg;
int i, runs;
+ double close_ms;
circuit_build_times_init(&initial);
circuit_build_times_init(&estimate);
circuit_build_times_init(&final);
@@ -478,27 +479,31 @@ test_circuit_timeout(void)
circuitbuild_running_unit_tests();
#define timeout0 (build_time_t)(30*1000.0)
- initial.Xm = 750;
+ initial.Xm = 3000;
circuit_build_times_initial_alpha(&initial,
CBT_DEFAULT_QUANTILE_CUTOFF/100.0,
timeout0);
+ close_ms = MAX(circuit_build_times_calculate_timeout(&initial,
+ CBT_DEFAULT_CLOSE_QUANTILE/100.0),
+ CBT_DEFAULT_TIMEOUT_INITIAL_VALUE);
do {
- int n = 0;
for (i=0; i < CBT_DEFAULT_MIN_CIRCUITS_TO_OBSERVE; i++) {
- if (circuit_build_times_add_time(&estimate,
- circuit_build_times_generate_sample(&initial, 0, 1)) == 0) {
- n++;
+ build_time_t sample = circuit_build_times_generate_sample(&initial,0,1);
+
+ if (sample > close_ms) {
+ circuit_build_times_add_time(&estimate, CBT_BUILD_ABANDONED);
+ } else {
+ circuit_build_times_add_time(&estimate, sample);
}
}
circuit_build_times_update_alpha(&estimate);
timeout1 = circuit_build_times_calculate_timeout(&estimate,
CBT_DEFAULT_QUANTILE_CUTOFF/100.0);
circuit_build_times_set_timeout(&estimate);
- log_warn(LD_CIRC, "Timeout1 is %lf, Xm is %d", timeout1, estimate.Xm);
+ log_notice(LD_CIRC, "Timeout1 is %lf, Xm is %d", timeout1, estimate.Xm);
+ /* 2% error */
} while (fabs(circuit_build_times_cdf(&initial, timeout0) -
- circuit_build_times_cdf(&initial, timeout1)) > 0.02
- /* 2% error */
- && estimate.total_build_times < CBT_NCIRCUITS_TO_OBSERVE);
+ circuit_build_times_cdf(&initial, timeout1)) > 0.02);
test_assert(estimate.total_build_times <= CBT_NCIRCUITS_TO_OBSERVE);
@@ -510,7 +515,7 @@ test_circuit_timeout(void)
CBT_DEFAULT_QUANTILE_CUTOFF/100.0);
circuit_build_times_set_timeout(&final);
- log_warn(LD_CIRC, "Timeout2 is %lf, Xm is %d", timeout2, final.Xm);
+ log_notice(LD_CIRC, "Timeout2 is %lf, Xm is %d", timeout2, final.Xm);
/* 5% here because some accuracy is lost due to histogram conversion */
test_assert(fabs(circuit_build_times_cdf(&initial, timeout0) -