* [pve-devel] [PATCH v2 qemu-server] tests: allow running migration tests in parallel
@ 2020-12-17 9:37 Fabian Ebner
2020-12-18 16:50 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Ebner @ 2020-12-17 9:37 UTC (permalink / raw)
To: pve-devel
It's not easily possible to use separate JSON files for the test configuration,
because part of it is generated with perl code. While this could be encoded too,
it seems cleaner to use the "run a single test by specifing the name"
functionality while adding a way for make to obtain a list of the test names.
Each test has (and needs) its own directory now, meaning the log files do not
need to be renamed anymore.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
Changes from v1:
* add definedness check before comparing $single_test_name
test/Makefile | 9 +++--
test/run_qemu_migrate_tests.pl | 62 ++++++++++++++++++++--------------
2 files changed, 44 insertions(+), 27 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index a356057..29b9db6 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,3 +1,6 @@
+MIGRATION_TEST_NAMES := $(shell ./run_qemu_migrate_tests.pl DUMP_NAMES)
+MIGRATION_TEST_TARGETS := $(addprefix test_migration_,$(MIGRATION_TEST_NAMES))
+
all: test
test: test_snapshot test_ovf test_cfg_to_cmd test_pci_addr_conflicts test_qemu_img_convert test_migration
@@ -18,5 +21,7 @@ test_qemu_img_convert: run_qemu_img_convert_tests.pl
test_pci_addr_conflicts: run_pci_addr_checks.pl
./run_pci_addr_checks.pl
-test_migration: run_qemu_migrate_tests.pl MigrationTest/*.pm
- ./run_qemu_migrate_tests.pl
+test_migration: run_qemu_migrate_tests.pl MigrationTest/*.pm $(MIGRATION_TEST_TARGETS)
+
+$(MIGRATION_TEST_TARGETS):
+ ./run_qemu_migrate_tests.pl $(@:test_migration_%=%)
diff --git a/test/run_qemu_migrate_tests.pl b/test/run_qemu_migrate_tests.pl
index 1e3f135..67b9d0e 100755
--- a/test/run_qemu_migrate_tests.pl
+++ b/test/run_qemu_migrate_tests.pl
@@ -417,7 +417,8 @@ sub local_volids_for_vm {
my $tests = [
# each test consists of the following:
-# name - unique name for the test
+# name - unique name for the test which also serves as a dir name and
+# gets passed to make, so don't use whitespace or slash
# target - hostname of target node
# vmid - ID of the VM to migrate
# opts - options for the migrate() call
@@ -1492,17 +1493,30 @@ my $tests = [
},
];
-mkdir $RUN_DIR_PATH;
+my $single_test_name = shift;
-file_set_contents("${RUN_DIR_PATH}/replication_config", to_json($replication_config));
-file_set_contents("${RUN_DIR_PATH}/storage_config", to_json($storage_config));
-file_set_contents("${RUN_DIR_PATH}/source_vdisks", to_json($source_vdisks));
+if (defined($single_test_name) && $single_test_name eq 'DUMP_NAMES') {
+ my $output = '';
+ foreach my $test (@{$tests}) {
+ $output .= $test->{name} . ' ';
+ }
+ print "$output\n";
+ exit 0;
+}
-my $single_test_name = shift;
+mkdir $RUN_DIR_PATH;
foreach my $test (@{$tests}) {
my $name = $test->{name};
next if defined($single_test_name) && $name ne $single_test_name;
+
+ my $run_dir = "${RUN_DIR_PATH}/${name}";
+
+ mkdir $run_dir;
+ file_set_contents("${run_dir}/replication_config", to_json($replication_config));
+ file_set_contents("${run_dir}/storage_config", to_json($storage_config));
+ file_set_contents("${run_dir}/source_vdisks", to_json($source_vdisks));
+
my $expect_die = $test->{expect_die};
my $expected = $test->{expected};
@@ -1525,18 +1539,18 @@ foreach my $test (@{$tests}) {
opts => $test->{opts},
};
- file_set_contents("${RUN_DIR_PATH}/nbd_info", to_json({}));
- file_set_contents("${RUN_DIR_PATH}/source_volids", to_json($source_volids));
- file_set_contents("${RUN_DIR_PATH}/target_volids", to_json($target_volids));
- file_set_contents("${RUN_DIR_PATH}/vm_config", to_json($vm_config));
- file_set_contents("${RUN_DIR_PATH}/vm_status", to_json($test->{vm_status}));
- file_set_contents("${RUN_DIR_PATH}/expected_calls", to_json($test->{expected_calls}));
- file_set_contents("${RUN_DIR_PATH}/fail_config", to_json($fail_config));
- file_set_contents("${RUN_DIR_PATH}/storage_migrate_map", to_json($storage_migrate_map));
- file_set_contents("${RUN_DIR_PATH}/migrate_params", to_json($migrate_params));
+ file_set_contents("${run_dir}/nbd_info", to_json({}));
+ file_set_contents("${run_dir}/source_volids", to_json($source_volids));
+ file_set_contents("${run_dir}/target_volids", to_json($target_volids));
+ file_set_contents("${run_dir}/vm_config", to_json($vm_config));
+ file_set_contents("${run_dir}/vm_status", to_json($test->{vm_status}));
+ file_set_contents("${run_dir}/expected_calls", to_json($test->{expected_calls}));
+ file_set_contents("${run_dir}/fail_config", to_json($fail_config));
+ file_set_contents("${run_dir}/storage_migrate_map", to_json($storage_migrate_map));
+ file_set_contents("${run_dir}/migrate_params", to_json($migrate_params));
$ENV{QM_LIB_PATH} = $QM_LIB_PATH;
- $ENV{RUN_DIR_PATH} = $RUN_DIR_PATH;
+ $ENV{RUN_DIR_PATH} = $run_dir;
my $exitcode = run_command([
'/usr/bin/perl',
"-I${MIGRATE_LIB_PATH}",
@@ -1545,7 +1559,7 @@ foreach my $test (@{$tests}) {
], noerr => 1, errfunc => sub {print "#$name - $_[0]\n"} );
if (defined($expect_die) && $exitcode) {
- my $log = file_get_contents("${RUN_DIR_PATH}/log");
+ my $log = file_get_contents("${run_dir}/log");
my @lines = split /\n/, $log;
my $matched = 0;
@@ -1565,14 +1579,14 @@ foreach my $test (@{$tests}) {
note("mocked migrate call failed, but it was not expected - check log");
}
- my $expected_calls = decode_json(file_get_contents("${RUN_DIR_PATH}/expected_calls"));
+ my $expected_calls = decode_json(file_get_contents("${run_dir}/expected_calls"));
foreach my $call (keys %{$expected_calls}) {
fail($name);
note("expected call '$call' was not made");
}
if (!defined($expect_die)) {
- my $nbd_info = decode_json(file_get_contents("${RUN_DIR_PATH}/nbd_info"));
+ my $nbd_info = decode_json(file_get_contents("${run_dir}/nbd_info"));
foreach my $drive (keys %{$nbd_info}) {
fail($name);
note("drive '$drive' was not mirrored");
@@ -1580,15 +1594,13 @@ foreach my $test (@{$tests}) {
}
my $actual = {
- source_volids => decode_json(file_get_contents("${RUN_DIR_PATH}/source_volids")),
- target_volids => decode_json(file_get_contents("${RUN_DIR_PATH}/target_volids")),
- vm_config => decode_json(file_get_contents("${RUN_DIR_PATH}/vm_config")),
- vm_status => decode_json(file_get_contents("${RUN_DIR_PATH}/vm_status")),
+ source_volids => decode_json(file_get_contents("${run_dir}/source_volids")),
+ target_volids => decode_json(file_get_contents("${run_dir}/target_volids")),
+ vm_config => decode_json(file_get_contents("${run_dir}/vm_config")),
+ vm_status => decode_json(file_get_contents("${run_dir}/vm_status")),
};
is_deeply($actual, $expected, $name);
-
- rename("${RUN_DIR_PATH}/log", "${RUN_DIR_PATH}/log-$name") or die "rename log failed\n";
}
done_testing();
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: Re: [PATCH v2 qemu-server] tests: allow running migration tests in parallel
2020-12-17 9:37 [pve-devel] [PATCH v2 qemu-server] tests: allow running migration tests in parallel Fabian Ebner
@ 2020-12-18 16:50 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2020-12-18 16:50 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Ebner
On 17/12/2020 10:37, Fabian Ebner wrote:
> It's not easily possible to use separate JSON files for the test configuration,
> because part of it is generated with perl code. While this could be encoded too,
> it seems cleaner to use the "run a single test by specifing the name"
> functionality while adding a way for make to obtain a list of the test names.
>
> Each test has (and needs) its own directory now, meaning the log files do not
> need to be renamed anymore.
>
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>
> Changes from v1:
> * add definedness check before comparing $single_test_name
>
> test/Makefile | 9 +++--
> test/run_qemu_migrate_tests.pl | 62 ++++++++++++++++++++--------------
> 2 files changed, 44 insertions(+), 27 deletions(-)
>
>
On my dev VM with 16 cores I now need 4.6s instead of 36s thanks to this, that's
acceptable again.
applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-18 16:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17 9:37 [pve-devel] [PATCH v2 qemu-server] tests: allow running migration tests in parallel Fabian Ebner
2020-12-18 16:50 ` [pve-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox