[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/21] qtest/migration-test.c: Add tests with compress enabled
From: |
Juan Quintela |
Subject: |
[PULL 09/21] qtest/migration-test.c: Add tests with compress enabled |
Date: |
Fri, 28 Apr 2023 21:11:51 +0200 |
From: Lukas Straub <lukasstraub2@web.de>
There has never been tests for migration with compress enabled.
Add suitable tests, testing with compress-wait-thread = false
too.
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
Acked-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
tests/qtest/migration-test.c | 103 +++++++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 60dd53d3ec..d28b0d9880 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -406,6 +406,41 @@ static void migrate_set_parameter_str(QTestState *who,
const char *parameter,
migrate_check_parameter_str(who, parameter, value);
}
+static long long migrate_get_parameter_bool(QTestState *who,
+ const char *parameter)
+{
+ QDict *rsp;
+ int result;
+
+ rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }");
+ result = qdict_get_bool(rsp, parameter);
+ qobject_unref(rsp);
+ return !!result;
+}
+
+static void migrate_check_parameter_bool(QTestState *who, const char
*parameter,
+ int value)
+{
+ int result;
+
+ result = migrate_get_parameter_bool(who, parameter);
+ g_assert_cmpint(result, ==, value);
+}
+
+static void migrate_set_parameter_bool(QTestState *who, const char *parameter,
+ int value)
+{
+ QDict *rsp;
+
+ rsp = qtest_qmp(who,
+ "{ 'execute': 'migrate-set-parameters',"
+ "'arguments': { %s: %i } }",
+ parameter, value);
+ g_assert(qdict_haskey(rsp, "return"));
+ qobject_unref(rsp);
+ migrate_check_parameter_bool(who, parameter, value);
+}
+
static void migrate_ensure_non_converge(QTestState *who)
{
/* Can't converge with 1ms downtime + 3 mbs bandwidth limit */
@@ -1524,6 +1559,70 @@ static void test_precopy_unix_xbzrle(void)
test_precopy_common(&args);
}
+static void *
+test_migrate_compress_start(QTestState *from,
+ QTestState *to)
+{
+ migrate_set_parameter_int(from, "compress-level", 1);
+ migrate_set_parameter_int(from, "compress-threads", 4);
+ migrate_set_parameter_bool(from, "compress-wait-thread", true);
+ migrate_set_parameter_int(to, "decompress-threads", 4);
+
+ migrate_set_capability(from, "compress", true);
+ migrate_set_capability(to, "compress", true);
+
+ return NULL;
+}
+
+static void test_precopy_unix_compress(void)
+{
+ g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+ MigrateCommon args = {
+ .connect_uri = uri,
+ .listen_uri = uri,
+ .start_hook = test_migrate_compress_start,
+ /*
+ * Test that no invalid thread state is left over from
+ * the previous iteration.
+ */
+ .iterations = 2,
+ };
+
+ test_precopy_common(&args);
+}
+
+static void *
+test_migrate_compress_nowait_start(QTestState *from,
+ QTestState *to)
+{
+ migrate_set_parameter_int(from, "compress-level", 9);
+ migrate_set_parameter_int(from, "compress-threads", 1);
+ migrate_set_parameter_bool(from, "compress-wait-thread", false);
+ migrate_set_parameter_int(to, "decompress-threads", 1);
+
+ migrate_set_capability(from, "compress", true);
+ migrate_set_capability(to, "compress", true);
+
+ return NULL;
+}
+
+static void test_precopy_unix_compress_nowait(void)
+{
+ g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+ MigrateCommon args = {
+ .connect_uri = uri,
+ .listen_uri = uri,
+ .start_hook = test_migrate_compress_nowait_start,
+ /*
+ * Test that no invalid thread state is left over from
+ * the previous iteration.
+ */
+ .iterations = 2,
+ };
+
+ test_precopy_common(&args);
+}
+
static void test_precopy_tcp_plain(void)
{
MigrateCommon args = {
@@ -2530,6 +2629,10 @@ int main(int argc, char **argv)
qtest_add_func("/migration/bad_dest", test_baddest);
qtest_add_func("/migration/precopy/unix/plain", test_precopy_unix_plain);
qtest_add_func("/migration/precopy/unix/xbzrle", test_precopy_unix_xbzrle);
+ qtest_add_func("/migration/precopy/unix/compress/wait",
+ test_precopy_unix_compress);
+ qtest_add_func("/migration/precopy/unix/compress/nowait",
+ test_precopy_unix_compress_nowait);
#ifdef CONFIG_GNUTLS
qtest_add_func("/migration/precopy/unix/tls/psk",
test_precopy_unix_tls_psk);
--
2.40.0
- [PULL 00/21] Migration 20230428 patches, Juan Quintela, 2023/04/28
- [PULL 02/21] migration: Move ram_stats to its own file migration-stats.[ch], Juan Quintela, 2023/04/28
- [PULL 01/21] multifd: We already account for this packet on the multifd thread, Juan Quintela, 2023/04/28
- [PULL 03/21] migration: Rename ram_counters to mig_stats, Juan Quintela, 2023/04/28
- [PULL 04/21] migration: Rename RAMStats to MigrationAtomicStats, Juan Quintela, 2023/04/28
- [PULL 07/21] migration: Drop unused parameter for migration_tls_get_creds(), Juan Quintela, 2023/04/28
- [PULL 05/21] migration/rdma: Split the zero page case from acct_update_position, Juan Quintela, 2023/04/28
- [PULL 06/21] migration/rdma: Unfold last user of acct_update_position(), Juan Quintela, 2023/04/28
- [PULL 08/21] migration: Drop unused parameter for migration_tls_client_create(), Juan Quintela, 2023/04/28
- [PULL 10/21] qtest/migration-test.c: Add postcopy tests with compress enabled, Juan Quintela, 2023/04/28
- [PULL 09/21] qtest/migration-test.c: Add tests with compress enabled,
Juan Quintela <=
- [PULL 11/21] ram.c: Let the compress threads return a CompressResult enum, Juan Quintela, 2023/04/28
- [PULL 14/21] ram.c: Do not call save_page_header() from compress threads, Juan Quintela, 2023/04/28
- [PULL 12/21] ram.c: Dont change param->block in the compress thread, Juan Quintela, 2023/04/28
- [PULL 13/21] ram.c: Reset result after sending queued data, Juan Quintela, 2023/04/28
- [PULL 16/21] ram.c: Remove last ram.c dependency from the core compress code, Juan Quintela, 2023/04/28
- [PULL 15/21] ram.c: Call update_compress_thread_counts from compress_send_queued_data, Juan Quintela, 2023/04/28
- [PULL 18/21] ram.c: Move core decompression code into its own file, Juan Quintela, 2023/04/28
- [PULL 19/21] ram compress: Assert that the file buffer matches the result, Juan Quintela, 2023/04/28
- [PULL 17/21] ram.c: Move core compression code into its own file, Juan Quintela, 2023/04/28
- [PULL 21/21] migration: Initialize and cleanup decompression in migration.c, Juan Quintela, 2023/04/28