diff mbox series

[v3,14/14] tests/qtest: migration-test: Add tests for file-based migration

Message ID 20221028103914.908728-15-nborisov@suse.com
State New
Headers show
Series File-based migration support and fixed-ram features | expand

Commit Message

Nikolay Borisov Oct. 28, 2022, 10:39 a.m. UTC
Add basic tests for file-based migration as well as for the 'fixed-ram'
feature.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 tests/qtest/migration-test.c | 46 ++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

Comments

Daniel P. Berrangé Feb. 10, 2023, 5:17 p.m. UTC | #1
On Fri, Oct 28, 2022 at 01:39:14PM +0300, Nikolay Borisov wrote:
> Add basic tests for file-based migration as well as for the 'fixed-ram'
> feature.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  tests/qtest/migration-test.c | 46 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
> 
> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
> index ef4427ff4d41..de877473f193 100644
> --- a/tests/qtest/migration-test.c
> +++ b/tests/qtest/migration-test.c
> @@ -748,6 +748,7 @@ static void test_migrate_end(QTestState *from, QTestState *to, bool test_dest)
>      cleanup("migsocket");
>      cleanup("src_serial");
>      cleanup("dest_serial");
> +    cleanup("migfile");
>  }
>  
>  #ifdef CONFIG_GNUTLS
> @@ -1359,6 +1360,14 @@ static void test_precopy_common(MigrateCommon *args)
>           * hanging forever if migration didn't converge */
>          wait_for_migration_complete(from);
>  
> +        /*
> +         * For file based migration the target must begin its migration after
> +         * the source has finished
> +         */
> +        if (strstr(args->connect_uri, "file:")) {
> +            migrate_incoming_qmp(to, args->connect_uri, "{}");
> +        }
> +
>          if (!got_stop) {
>              qtest_qmp_eventwait(from, "STOP");
>          }
> @@ -1514,6 +1523,39 @@ static void test_precopy_unix_xbzrle(void)
>      test_precopy_common(&args);
>  }
>  
> +static void test_precopy_unix_file(void)
> +{
> +    g_autofree char *uri = g_strdup_printf("file:%s/migfile", tmpfs);
> +    MigrateCommon args = {
> +        .connect_uri = uri,
> +        .listen_uri = "defer",
> +    };
> +
> +    test_precopy_common(&args);
> +}
> +
> +static void *
> +test_migrate_fixed_ram_start(QTestState *from,
> +                             QTestState *to)
> +{
> +    migrate_set_capability(from, "fixed-ram", true);
> +    migrate_set_capability(to, "fixed-ram", true);
> +
> +    return NULL;
> +}
> +
> +static void test_precopy_unix_fixed_ram(void)
> +{
> +    g_autofree char *uri = g_strdup_printf("file:%s/migfile", tmpfs);
> +    MigrateCommon args = {
> +        .connect_uri = uri,
> +        .listen_uri = "defer",
> +        .start_hook = test_migrate_fixed_ram_start,
> +    };
> +
> +    test_precopy_common(&args);
> +}
> +
>  static void test_precopy_tcp_plain(void)
>  {
>      MigrateCommon args = {
> @@ -2506,6 +2548,10 @@ int main(int argc, char **argv)
>                     test_precopy_unix_tls_psk);
>  #endif
>  
> +    qtest_add_func("/migration/precopy/unix/file", test_precopy_unix_file);
> +    qtest_add_func("/migration/precopy/unix/fixed-ram",
> +                   test_precopy_unix_fixed_ram);

Minor point '/unix' would indicate this is testing UNIX socket backend
for migration. The paths for the tests would be better as

    /migration/precopy/file/stream-ram
    /migration/precopy/file/fixed-ram

With regards,
Daniel
diff mbox series

Patch

diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index ef4427ff4d41..de877473f193 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -748,6 +748,7 @@  static void test_migrate_end(QTestState *from, QTestState *to, bool test_dest)
     cleanup("migsocket");
     cleanup("src_serial");
     cleanup("dest_serial");
+    cleanup("migfile");
 }
 
 #ifdef CONFIG_GNUTLS
@@ -1359,6 +1360,14 @@  static void test_precopy_common(MigrateCommon *args)
          * hanging forever if migration didn't converge */
         wait_for_migration_complete(from);
 
+        /*
+         * For file based migration the target must begin its migration after
+         * the source has finished
+         */
+        if (strstr(args->connect_uri, "file:")) {
+            migrate_incoming_qmp(to, args->connect_uri, "{}");
+        }
+
         if (!got_stop) {
             qtest_qmp_eventwait(from, "STOP");
         }
@@ -1514,6 +1523,39 @@  static void test_precopy_unix_xbzrle(void)
     test_precopy_common(&args);
 }
 
+static void test_precopy_unix_file(void)
+{
+    g_autofree char *uri = g_strdup_printf("file:%s/migfile", tmpfs);
+    MigrateCommon args = {
+        .connect_uri = uri,
+        .listen_uri = "defer",
+    };
+
+    test_precopy_common(&args);
+}
+
+static void *
+test_migrate_fixed_ram_start(QTestState *from,
+                             QTestState *to)
+{
+    migrate_set_capability(from, "fixed-ram", true);
+    migrate_set_capability(to, "fixed-ram", true);
+
+    return NULL;
+}
+
+static void test_precopy_unix_fixed_ram(void)
+{
+    g_autofree char *uri = g_strdup_printf("file:%s/migfile", tmpfs);
+    MigrateCommon args = {
+        .connect_uri = uri,
+        .listen_uri = "defer",
+        .start_hook = test_migrate_fixed_ram_start,
+    };
+
+    test_precopy_common(&args);
+}
+
 static void test_precopy_tcp_plain(void)
 {
     MigrateCommon args = {
@@ -2506,6 +2548,10 @@  int main(int argc, char **argv)
                    test_precopy_unix_tls_psk);
 #endif
 
+    qtest_add_func("/migration/precopy/unix/file", test_precopy_unix_file);
+    qtest_add_func("/migration/precopy/unix/fixed-ram",
+                   test_precopy_unix_fixed_ram);
+
     if (has_uffd) {
         /*
          * NOTE: psk test is enough for postcopy, as other types of TLS