[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 13/13] throttle: Test throttle_compute_wait() during
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH 13/13] throttle: Test throttle_compute_wait() during bursts |
Date: |
Fri, 5 Feb 2016 12:59:23 +0200 |
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>
---
tests/test-throttle.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tests/test-throttle.c b/tests/test-throttle.c
index 11ede23..2501d6f 100644
--- a/tests/test-throttle.c
+++ b/tests/test-throttle.c
@@ -79,6 +79,7 @@ static void test_leak_bucket(void)
static void test_compute_wait(void)
{
+ unsigned i;
int64_t wait;
int64_t result;
@@ -114,6 +115,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 */
--
2.7.0
- [Qemu-devel] [PATCH 06/13] throttle: Merge all functions that check the configuration into one, (continued)
- [Qemu-devel] [PATCH 06/13] throttle: Merge all functions that check the configuration into one, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 01/13] throttle: Make throttle_compute_timer() static, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 04/13] throttle: Make throttle_is_valid() set errp, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 02/13] throttle: Make throttle_conflicting() set errp, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 12/13] throttle: Check that burst_level leaks correctly, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 07/13] throttle: Use throttle_config_init() to initialize ThrottleConfig, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 08/13] throttle: Add support for burst periods, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 11/13] qapi: Add burst length fields to BlockDeviceInfo, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 13/13] throttle: Test throttle_compute_wait() during bursts,
Alberto Garcia <=
- [Qemu-devel] [PATCH 03/13] throttle: Make throttle_max_is_missing_limit() set errp, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 10/13] qapi: Add burst length parameters to block_set_io_throttle, Alberto Garcia, 2016/02/05
- Re: [Qemu-devel] [PATCH 00/13] throttle: Allow I/O bursts for a user-defined period of time, Kevin Wolf, 2016/02/12
- Re: [Qemu-devel] [Qemu-block] [PATCH 00/13] throttle: Allow I/O bursts for a user-defined period of time, Stefan Hajnoczi, 2016/02/15