tests: convert multifd migration tests to use common helper

Most of the multifd migration test logic is common with the rest of the
precopy tests, so it can use the helper without difficulty. The only
exception of the multifd cancellation test which tries to run multiple
migrations in a row.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20220426160048.812266-7-berrange@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2022-04-26 17:00:45 +01:00 committed by Dr. David Alan Gilbert
parent 83bcba1ec1
commit 490facffcf

View File

@ -1740,26 +1740,12 @@ static void test_migrate_auto_converge(void)
test_migrate_end(from, to, true); test_migrate_end(from, to, true);
} }
static void test_multifd_tcp(const char *method) static void *
test_migrate_precopy_tcp_multifd_start_common(QTestState *from,
QTestState *to,
const char *method)
{ {
MigrateStart args = {};
QTestState *from, *to;
QDict *rsp; QDict *rsp;
g_autofree char *uri = NULL;
if (test_migrate_start(&from, &to, "defer", &args)) {
return;
}
/*
* We want to pick a speed slow enough that the test completes
* quickly, but that it doesn't complete precopy even on a slow
* machine, so also set the downtime.
*/
/* 1 ms should make it not converge*/
migrate_set_parameter_int(from, "downtime-limit", 1);
/* 1GB/s */
migrate_set_parameter_int(from, "max-bandwidth", 1000000000);
migrate_set_parameter_int(from, "multifd-channels", 16); migrate_set_parameter_int(from, "multifd-channels", 16);
migrate_set_parameter_int(to, "multifd-channels", 16); migrate_set_parameter_int(to, "multifd-channels", 16);
@ -1775,41 +1761,58 @@ static void test_multifd_tcp(const char *method)
" 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}"); " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}");
qobject_unref(rsp); qobject_unref(rsp);
/* Wait for the first serial output from the source */ return NULL;
wait_for_serial("src_serial");
uri = migrate_get_socket_address(to, "socket-address");
migrate_qmp(from, uri, "{}");
wait_for_migration_pass(from);
migrate_set_parameter_int(from, "downtime-limit", CONVERGE_DOWNTIME);
if (!got_stop) {
qtest_qmp_eventwait(from, "STOP");
}
qtest_qmp_eventwait(to, "RESUME");
wait_for_serial("dest_serial");
wait_for_migration_complete(from);
test_migrate_end(from, to, true);
} }
static void *
test_migrate_precopy_tcp_multifd_start(QTestState *from,
QTestState *to)
{
return test_migrate_precopy_tcp_multifd_start_common(from, to, "none");
}
static void *
test_migrate_precopy_tcp_multifd_zlib_start(QTestState *from,
QTestState *to)
{
return test_migrate_precopy_tcp_multifd_start_common(from, to, "zlib");
}
#ifdef CONFIG_ZSTD
static void *
test_migrate_precopy_tcp_multifd_zstd_start(QTestState *from,
QTestState *to)
{
return test_migrate_precopy_tcp_multifd_start_common(from, to, "zstd");
}
#endif /* CONFIG_ZSTD */
static void test_multifd_tcp_none(void) static void test_multifd_tcp_none(void)
{ {
test_multifd_tcp("none"); MigrateCommon args = {
.listen_uri = "defer",
.start_hook = test_migrate_precopy_tcp_multifd_start,
};
test_precopy_common(&args);
} }
static void test_multifd_tcp_zlib(void) static void test_multifd_tcp_zlib(void)
{ {
test_multifd_tcp("zlib"); MigrateCommon args = {
.listen_uri = "defer",
.start_hook = test_migrate_precopy_tcp_multifd_zlib_start,
};
test_precopy_common(&args);
} }
#ifdef CONFIG_ZSTD #ifdef CONFIG_ZSTD
static void test_multifd_tcp_zstd(void) static void test_multifd_tcp_zstd(void)
{ {
test_multifd_tcp("zstd"); MigrateCommon args = {
.listen_uri = "defer",
.start_hook = test_migrate_precopy_tcp_multifd_zstd_start,
};
test_precopy_common(&args);
} }
#endif #endif