From patchwork Sun Sep 15 19:20:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11146069 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AF2E13BD for ; Sun, 15 Sep 2019 19:23:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E50CF21479 for ; Sun, 15 Sep 2019 19:23:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="qPSOLGEh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E50CF21479 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:56546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9a7L-0005jF-Tv for patchwork-qemu-devel@patchwork.kernel.org; Sun, 15 Sep 2019 15:23:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39580) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9a4T-0003cC-Gp for qemu-devel@nongnu.org; Sun, 15 Sep 2019 15:20:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9a4S-000135-Db for qemu-devel@nongnu.org; Sun, 15 Sep 2019 15:20:29 -0400 Received: from mout.web.de ([212.227.17.12]:48195) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9a4S-00012p-5O for qemu-devel@nongnu.org; Sun, 15 Sep 2019 15:20:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1568575211; bh=lS0He1ZjyrE6labtN6cAGz+FTFA0a9A2XqfoJ6l9fU0=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=qPSOLGEhqn6jTwrNrZzeaC+n+e4vH1kbohGQdRd5pGFTTOcCcL0hEYblpm7uacEzO zZyD9wmd32hx1IO4Jh/BokEsdbAksFsQssAcEtImJDI0ySAmbUUqWlZDwEPb4SuHDL Az+nUc2nBCdp6eL8ZTkPk2Fb1LbglObAzTB34Q/s= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.53]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MEEa4-1huDz92iVM-00FTS3; Sun, 15 Sep 2019 21:20:11 +0200 Date: Sun, 15 Sep 2019 21:20:07 +0200 From: Lukas Straub To: qemu-devel Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:Vzl09lb6jnQfDzrpdso9QKB96CqjdVmHW1XbotCrhBPNcCpfiY0 9gzopBdCbXNDwn6WmmjoCTFL+0EXrH1fTQJrP/JF5sFBBCcAw+6DFbe/9N7VSSHlKujMw7y wwAO42bF3qWDz3CAo0QtWXOuBK7HBdyvOumscDbQxSEGmGy1+FgJ7BJJU2iugQFtGwF1rwr Krx8wNihHFJqUzu43lZNg== X-UI-Out-Filterresults: notjunk:1;V03:K0:lDJn2w27Pqk=:jiYHm9lNPCyFQH3xwHyU7k fUkyGyAQkwcSzsQo4igztbUa/lDN1a/iAf8g3hujgP0J0DUhSOGkoaJ1+lWjb3YZmBqvzESRq JJZL22UKzKyAFSnPQZSjd/7JiYJVAfzLJI8c79C/MD+33uDwEFJdOtDRQ7fOpymTHB8rY0/j/ +ziQ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3Z7Nm6neLZyw8Q+OV3i+k d7XhwXmyuDUJdnphpxC9L8Y4GqhZUaoKfD7puQ9iFLeBD4yWwgOf25MWsctc= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.12 Subject: [Qemu-devel] [PATCH v5 2/4] tests/test-replication.c: Add test for ignoring requests after failover X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Wen Congyang , Jason Wang , mreitz@redhat.com, Zhang Chen , Xie Changlong Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This simulates the case that happens when we resume COLO after failover. Signed-off-by: Lukas Straub --- tests/test-replication.c | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) -- 2.20.1 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",