diff mbox series

[v5,2/4] tests/test-replication.c: Add test for ignoring requests after failover

Message ID e3f1e1ec5b2bd2ce2c9a6c7669284a3fc2fdbaaa.1568574478.git.lukasstraub2@web.de (mailing list archive)
State New, archived
Headers show
Series colo: Add support for continuous replication | expand

Commit Message

Lukas Straub Sept. 15, 2019, 7:20 p.m. UTC
This simulates the case that happens when we resume COLO after failover.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 tests/test-replication.c | 52 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

--
2.20.1

Comments

Zhang Chen Sept. 26, 2019, 5:40 p.m. UTC | #1
> -----Original Message-----
> From: Lukas Straub <lukasstraub2@web.de>
> Sent: Monday, September 16, 2019 3:20 AM
> To: qemu-devel <qemu-devel@nongnu.org>
> Cc: Zhang, Chen <chen.zhang@intel.com>; Jason Wang
> <jasowang@redhat.com>; Wen Congyang <wencongyang2@huawei.com>;
> Xie Changlong <xiechanglong.d@gmail.com>; kwolf@redhat.com;
> mreitz@redhat.com
> Subject: [PATCH v5 2/4] tests/test-replication.c: Add test for ignoring
> requests after failover
> 
> This simulates the case that happens when we resume COLO after failover.
> 

It looks change the title to "Add test for secondary node continuous backup" is better.

> Signed-off-by: Lukas Straub <lukasstraub2@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..5addfc2227 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_failover_then_ignore_requests(void)

Same as title, I think change to "test_secondary_continuous_backup" is more clear.

Thanks
Zhang Chen

> +{
> +    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 */
> +
> +    /* 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/failover_then_ignore_requests",
> +                    test_secondary_failover_then_ignore_requests);
>      g_test_add_func("/replication/secondary/do_checkpoint",
>                      test_secondary_do_checkpoint);
>      g_test_add_func("/replication/secondary/get_error_all",
> --
> 2.20.1
Lukas Straub Sept. 28, 2019, 11:07 a.m. UTC | #2
On Thu, 26 Sep 2019 17:40:03 +0000
"Zhang, Chen" <chen.zhang@intel.com> wrote:

> > -----Original Message-----
> > From: Lukas Straub <lukasstraub2@web.de>
> > Sent: Monday, September 16, 2019 3:20 AM
> > To: qemu-devel <qemu-devel@nongnu.org>
> > Cc: Zhang, Chen <chen.zhang@intel.com>; Jason Wang
> > <jasowang@redhat.com>; Wen Congyang <wencongyang2@huawei.com>;
> > Xie Changlong <xiechanglong.d@gmail.com>; kwolf@redhat.com;
> > mreitz@redhat.com
> > Subject: [PATCH v5 2/4] tests/test-replication.c: Add test for ignoring
> > requests after failover
> >
> > This simulates the case that happens when we resume COLO after failover.
> >
>
> It looks change the title to "Add test for secondary node continuous backup" is better.

Did you mean "continuous replication"? Would "Add test for secondary node continuing replication" be Ok?

> > Signed-off-by: Lukas Straub <lukasstraub2@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..5addfc2227 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_failover_then_ignore_requests(void)
>
> Same as title, I think change to "test_secondary_continuous_backup" is more clear.
>
> Thanks
> Zhang Chen
>
> > +{
> > +    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 */
> > +
> > +    /* 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/failover_then_ignore_requests",
> > +                    test_secondary_failover_then_ignore_requests);
> >      g_test_add_func("/replication/secondary/do_checkpoint",
> >                      test_secondary_do_checkpoint);
> >      g_test_add_func("/replication/secondary/get_error_all",
> > --
> > 2.20.1
>
Zhang Chen Sept. 30, 2019, 8:13 p.m. UTC | #3
> -----Original Message-----
> From: Lukas Straub <lukasstraub2@web.de>
> Sent: Saturday, September 28, 2019 7:07 PM
> To: Zhang, Chen <chen.zhang@intel.com>
> Cc: qemu-devel <qemu-devel@nongnu.org>; Jason Wang
> <jasowang@redhat.com>; Wen Congyang <wencongyang2@huawei.com>;
> Xie Changlong <xiechanglong.d@gmail.com>; kwolf@redhat.com;
> mreitz@redhat.com
> Subject: Re: [PATCH v5 2/4] tests/test-replication.c: Add test for ignoring
> requests after failover
> 
> On Thu, 26 Sep 2019 17:40:03 +0000
> "Zhang, Chen" <chen.zhang@intel.com> wrote:
> 
> > > -----Original Message-----
> > > From: Lukas Straub <lukasstraub2@web.de>
> > > Sent: Monday, September 16, 2019 3:20 AM
> > > To: qemu-devel <qemu-devel@nongnu.org>
> > > Cc: Zhang, Chen <chen.zhang@intel.com>; Jason Wang
> > > <jasowang@redhat.com>; Wen Congyang
> <wencongyang2@huawei.com>; Xie
> > > Changlong <xiechanglong.d@gmail.com>; kwolf@redhat.com;
> > > mreitz@redhat.com
> > > Subject: [PATCH v5 2/4] tests/test-replication.c: Add test for
> > > ignoring requests after failover
> > >
> > > This simulates the case that happens when we resume COLO after
> failover.
> > >
> >
> > It looks change the title to "Add test for secondary node continuous
> backup" is better.
> 
> Did you mean "continuous replication"? Would "Add test for secondary node
> continuing replication" be Ok?

OK for me.

Thanks
Zhang Chen

> 
> > > Signed-off-by: Lukas Straub <lukasstraub2@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..5addfc2227 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_failover_then_ignore_requests(void)
> >
> > Same as title, I think change to "test_secondary_continuous_backup" is
> more clear.
> >
> > Thanks
> > Zhang Chen
> >
> > > +{
> > > +    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 */
> > > +
> > > +    /* 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/failover_then_ignore_request
> > > s",
> > > +                    test_secondary_failover_then_ignore_requests);
> > >      g_test_add_func("/replication/secondary/do_checkpoint",
> > >                      test_secondary_do_checkpoint);
> > >      g_test_add_func("/replication/secondary/get_error_all",
> > > --
> > > 2.20.1
> >
diff mbox series

Patch

diff --git a/tests/test-replication.c b/tests/test-replication.c
index f085d1993a..5addfc2227 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_failover_then_ignore_requests(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 */
+
+    /* 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/failover_then_ignore_requests",
+                    test_secondary_failover_then_ignore_requests);
     g_test_add_func("/replication/secondary/do_checkpoint",
                     test_secondary_do_checkpoint);
     g_test_add_func("/replication/secondary/get_error_all",