]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
bloom-filter: Improve test cases
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 27 Sep 2019 17:37:11 +0000 (19:37 +0200)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 27 Sep 2019 17:39:51 +0000 (19:39 +0200)
commitef17972992807f57ed6ac5dbe49f2902d0127d3d
tree4b80310281c0f7a2f8bb743638b3f2a817ea2b78
parentb6dc4b020a614e070034862cc1d3bc2c3d382a08
bloom-filter: Improve test cases

The integer bloom filter test cases do not really match typical usage
of the bloom filter in actual Ceph code.  In particular:

- the tests use consecutive integer ranges, while Ceph code uses
  hash values uniformly distributed over the uint32_t space;

- the tests pass "int" to the insert and contains functions, which
  causes the generic C++ POD type overload to be selected instead
  of the uint32_t overload that is used by Ceph code.  The POD
  overload is dependent on host byte order, and behaves actually
  different from the uint32_t overload on little-endian systems.

To fix these issues, this patch changes the integer tests to
always pass in uint32_t (instead of int), and to use results
of a pseudo-random number generator instead of consecutive
sequences.  (We assume the period of the generator is long
enough that all values generated within one test instance
are distinct.)

This not only makes the test pass on both big- and little-endian
hosts now, but it also allows tightening of the allowable actual
false positive rates, as they now match much closer the expected
values.

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
src/test/common/test_bloom_filter.cc