On Wed, 9 Oct 2019 06:03:03 +0000 "Zhang, Chen" <chen.zh...@intel.com> wrote:
> > -----Original Message----- > > From: Lukas Straub <lukasstra...@web.de> > > Sent: Saturday, October 5, 2019 9:06 PM > > To: qemu-devel <qemu-de...@nongnu.org> > > Cc: Zhang, Chen <chen.zh...@intel.com>; Jason Wang > > <jasow...@redhat.com>; Wen Congyang <wencongya...@huawei.com>; > > Xie Changlong <xiechanglon...@gmail.com>; Kevin Wolf > > <kw...@redhat.com>; Max Reitz <mre...@redhat.com>; qemu-block > > <qemu-block@nongnu.org> > > Subject: [PATCH v6 2/4] tests/test-replication.c: Add test for for secondary > > node continuing replication > > > > This simulates the case that happens when we resume COLO after failover. > > > > Signed-off-by: Lukas Straub <lukasstra...@web.de> > > --- > > tests/test-replication.c | 52 > > ++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 52 insertions(+) > > > > diff --git a/tests/test-replication.c b/tests/test-replication.c index > > f085d1993a..8e18ecd998 100644 > > --- a/tests/test-replication.c > > +++ b/tests/test-replication.c > > @@ -489,6 +489,56 @@ static void test_secondary_stop(void) > > teardown_secondary(); > > } > > > > +static void test_secondary_continuous_replication(void) > > +{ > > + BlockBackend *top_blk, *local_blk; > > + Error *local_err = NULL; > > + > > + top_blk = start_secondary(); > > + replication_start_all(REPLICATION_MODE_SECONDARY, &local_err); > > + g_assert(!local_err); > > + > > + /* write 0x22 to s_local_disk (IMG_SIZE / 2, IMG_SIZE) */ > > + local_blk = blk_by_name(S_LOCAL_DISK_ID); > > + test_blk_write(local_blk, 0x22, IMG_SIZE / 2, IMG_SIZE / 2, false); > > + > > + /* replication will backup s_local_disk to s_hidden_disk */ > > + test_blk_read(top_blk, 0x11, IMG_SIZE / 2, > > + IMG_SIZE / 2, 0, IMG_SIZE, false); > > + > > + /* write 0x33 to s_active_disk (0, IMG_SIZE / 2) */ > > + test_blk_write(top_blk, 0x33, 0, IMG_SIZE / 2, false); > > + > > + /* do failover (active commit) */ > > + replication_stop_all(true, &local_err); > > + g_assert(!local_err); > > + > > + /* it should ignore all requests from now on */ > > Should we need add teardown_secondary() here? I don't think so. It is used to remove the block node after each test and I'm doing that below. Regards, Lukas Straub > Thanks > Zhang Chen > > > + > > + /* start after failover */ > > + replication_start_all(REPLICATION_MODE_PRIMARY, &local_err); > > + g_assert(!local_err); > > + > > + /* checkpoint */ > > + replication_do_checkpoint_all(&local_err); > > + g_assert(!local_err); > > + > > + /* stop */ > > + replication_stop_all(true, &local_err); > > + g_assert(!local_err); > > + > > + /* read from s_local_disk (0, IMG_SIZE / 2) */ > > + test_blk_read(top_blk, 0x33, 0, IMG_SIZE / 2, > > + 0, IMG_SIZE / 2, false); > > + > > + > > + /* read from s_local_disk (IMG_SIZE / 2, IMG_SIZE) */ > > + test_blk_read(top_blk, 0x22, IMG_SIZE / 2, > > + IMG_SIZE / 2, 0, IMG_SIZE, false); > > + > > + teardown_secondary(); > > +} > > + > > static void test_secondary_do_checkpoint(void) > > { > > BlockBackend *top_blk, *local_blk; > > @@ -584,6 +634,8 @@ int main(int argc, char **argv) > > g_test_add_func("/replication/secondary/write", test_secondary_write); > > g_test_add_func("/replication/secondary/start", test_secondary_start); > > g_test_add_func("/replication/secondary/stop", test_secondary_stop); > > + g_test_add_func("/replication/secondary/continuous_replication", > > + test_secondary_continuous_replication); > > g_test_add_func("/replication/secondary/do_checkpoint", > > test_secondary_do_checkpoint); > > g_test_add_func("/replication/secondary/get_error_all", > > -- > > 2.20.1 >