[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 26/34] throttle: Test throttle_compute_wait() during
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 26/34] throttle: Test throttle_compute_wait() during bursts |
Date: |
Mon, 22 Feb 2016 17:32:44 +0100 |
From: Alberto Garcia <address@hidden>
This test simulates an I/O burst for more than two seconds and checks
that it works as expected.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/test-throttle.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tests/test-throttle.c b/tests/test-throttle.c
index 145ba08..59675fa 100644
--- a/tests/test-throttle.c
+++ b/tests/test-throttle.c
@@ -80,6 +80,7 @@ static void test_leak_bucket(void)
static void test_compute_wait(void)
{
+ unsigned i;
int64_t wait;
int64_t result;
@@ -115,6 +116,27 @@ static void test_compute_wait(void)
/* time required to do half an operation */
result = (int64_t) NANOSECONDS_PER_SECOND / 150 / 2;
g_assert(wait == result);
+
+ /* Perform I/O for 2.2 seconds at a rate of bkt.max */
+ bkt.burst_length = 2;
+ bkt.level = 0;
+ bkt.avg = 10;
+ bkt.max = 200;
+ for (i = 0; i < 22; i++) {
+ double units = bkt.max / 10;
+ bkt.level += units;
+ bkt.burst_level += units;
+ throttle_leak_bucket(&bkt, NANOSECONDS_PER_SECOND / 10);
+ wait = throttle_compute_wait(&bkt);
+ g_assert(double_cmp(bkt.burst_level, 0));
+ g_assert(double_cmp(bkt.level, (i + 1) * (bkt.max - bkt.avg) / 10));
+ /* We can do bursts for the 2 seconds we have configured in
+ * burst_length. We have 100 extra miliseconds of burst
+ * because bkt.level has been leaking during this time.
+ * After that, we have to wait. */
+ result = i < 21 ? 0 : 1.8 * NANOSECONDS_PER_SECOND;
+ g_assert(wait == result);
+ }
}
/* functions to test ThrottleState initialization/destroy methods */
--
1.8.3.1
- [Qemu-devel] [PULL 04/34] block: Fix -incoming with snapshot=on, (continued)
- [Qemu-devel] [PULL 04/34] block: Fix -incoming with snapshot=on, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 15/34] throttle: Make throttle_conflicting() set errp, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 09/34] qemu-img: allow specifying image as a set of options args, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 16/34] throttle: Make throttle_max_is_missing_limit() set errp, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 06/34] qemu-img: add support for --object command line arg, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 14/34] throttle: Make throttle_compute_timer() static, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 05/34] qemu-io: add support for --object command line arg, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 08/34] qemu-nbd: allow specifying image as a set of options args, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 18/34] throttle: Set always an average value when setting a maximum value, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 11/34] qemu-nbd: use no_argument/required_argument constants, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 26/34] throttle: Test throttle_compute_wait() during bursts,
Kevin Wolf <=
- [Qemu-devel] [PULL 17/34] throttle: Make throttle_is_valid() set errp, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 20/34] throttle: Use throttle_config_init() to initialize ThrottleConfig, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 22/34] throttle: Add command-line settings to define the burst periods, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 33/34] qemu-iotests: 140: don't use IDE device, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 24/34] qapi: Add burst length fields to BlockDeviceInfo, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 19/34] throttle: Merge all functions that check the configuration into one, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 25/34] throttle: Check that burst_level leaks correctly, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 30/34] MAINTAINERS: Add myself as maintainer of the throttling code, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 21/34] throttle: Add support for burst periods, Kevin Wolf, 2016/02/22
- [Qemu-devel] [PULL 23/34] qapi: Add burst length parameters to block_set_io_throttle, Kevin Wolf, 2016/02/22