Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: kostja@tarantool.org
Subject: [tarantool-patches] [PATCH v2 3/6] test: rename some swim test methods and macros
Date: Tue,  9 Apr 2019 14:46:34 +0300	[thread overview]
Message-ID: <993ef40a1729405cf0d72cc9806a0539436c244c.1554809200.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1554809200.git.v.shpilevoy@tarantool.org>
In-Reply-To: <cover.1554809200.git.v.shpilevoy@tarantool.org>

@Kostja thinks it improves redability.
---
 test/unit/swim.c            | 83 +++++++++++++++++++------------------
 test/unit/swim_test_utils.c |  4 +-
 test/unit/swim_test_utils.h |  8 ++--
 3 files changed, 49 insertions(+), 46 deletions(-)

diff --git a/test/unit/swim.c b/test/unit/swim.c
index 860d3211e..5b7b08ae1 100644
--- a/test/unit/swim.c
+++ b/test/unit/swim.c
@@ -51,7 +51,7 @@ static int test_result;
 static void
 swim_test_one_link(void)
 {
-	swim_start_test(6);
+	swim_test_start(6);
 	/*
 	 * Run a simple cluster of two elements. One of them
 	 * learns about another explicitly. Another should add the
@@ -73,13 +73,13 @@ swim_test_one_link(void)
 	   "1 sees 0 as alive");
 	swim_cluster_delete(cluster);
 
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static void
 swim_test_sequence(void)
 {
-	swim_start_test(1);
+	swim_test_start(1);
 	/*
 	 * Run a simple cluster of several elements. Build a
 	 * 'forward list' from them. It should turn into fullmesh
@@ -92,13 +92,13 @@ swim_test_sequence(void)
 	is(swim_cluster_wait_fullmesh(cluster, 10), 0, "sequence");
 	swim_cluster_delete(cluster);
 
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static void
 swim_test_uuid_update(void)
 {
-	swim_start_test(4);
+	swim_test_start(4);
 
 	struct swim_cluster *cluster = swim_cluster_new(2);
 	swim_cluster_add_link(cluster, 0, 1);
@@ -112,24 +112,24 @@ swim_test_uuid_update(void)
 	new_uuid.time_low = 2;
 	is(swim_cfg(s, NULL, -1, -1, -1, &new_uuid), -1,
 	   "can not update to an existing UUID - swim_cfg fails");
-	ok(swim_error_check_match("exists"), "diag says 'exists'");
+	ok(swim_test_error_check_match("exists"), "diag says 'exists'");
 	swim_cluster_delete(cluster);
 
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static void
 swim_test_cfg(void)
 {
-	swim_start_test(16);
+	swim_test_start(16);
 
 	struct swim *s = swim_new();
 	assert(s != NULL);
 	is(swim_cfg(s, NULL, -1, -1, -1, NULL), -1, "first cfg failed - no URI");
-	ok(swim_error_check_match("mandatory"), "diag says 'mandatory'");
+	ok(swim_test_error_check_match("mandatory"), "diag says 'mandatory'");
 	const char *uri = "127.0.0.1:1";
 	is(swim_cfg(s, uri, -1, -1, -1, NULL), -1, "first cfg failed - no UUID");
-	ok(swim_error_check_match("mandatory"), "diag says 'mandatory'");
+	ok(swim_test_error_check_match("mandatory"), "diag says 'mandatory'");
 	struct tt_uuid uuid = uuid_nil;
 	uuid.time_low = 1;
 	is(swim_cfg(s, uri, -1, -1, -1, &uuid), 0, "configured first time");
@@ -148,26 +148,28 @@ swim_test_cfg(void)
 	uuid2.time_low = 2;
 	is(swim_cfg(s2, bad_uri1, -1, -1, -1, &uuid2), -1,
 	   "can not use invalid URI");
-	ok(swim_error_check_match("invalid uri"), "diag says 'invalid uri'");
+	ok(swim_test_error_check_match("invalid uri"),
+	   "diag says 'invalid uri'");
 	is(swim_cfg(s2, bad_uri2, -1, -1, -1, &uuid2), -1,
 	   "can not use domain names");
-	ok(swim_error_check_match("invalid uri"), "diag says 'invalid uri'");
+	ok(swim_test_error_check_match("invalid uri"),
+	   "diag says 'invalid uri'");
 	is(swim_cfg(s2, bad_uri3, -1, -1, -1, &uuid2), -1,
 		    "UNIX sockets are not supported");
-	ok(swim_error_check_match("only IP"), "diag says 'only IP'");
+	ok(swim_test_error_check_match("only IP"), "diag says 'only IP'");
 	is(swim_cfg(s2, uri, -1, -1, -1, &uuid2), -1,
 		    "can not bind to an occupied port");
-	ok(swim_error_check_match("bind"), "diag says 'bind'");
+	ok(swim_test_error_check_match("bind"), "diag says 'bind'");
 	swim_delete(s2);
 	swim_delete(s);
 
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static void
 swim_test_add_remove(void)
 {
-	swim_start_test(13);
+	swim_test_start(13);
 
 	struct swim_cluster *cluster = swim_cluster_new(2);
 	swim_cluster_add_link(cluster, 0, 1);
@@ -179,7 +181,7 @@ swim_test_add_remove(void)
 	is(swim_add_member(s1, swim_member_uri(s2_self),
 			   swim_member_uuid(s2_self)), -1,
 	   "can not add an existing member");
-	ok(swim_error_check_match("already exists"),
+	ok(swim_test_error_check_match("already exists"),
 	   "diag says 'already exists'");
 
 	const char *bad_uri = "127.0.0101010101";
@@ -187,11 +189,12 @@ swim_test_add_remove(void)
 	uuid.time_low = 1000;
 	is(swim_add_member(s1, bad_uri, &uuid), -1,
 	   "can not add a invalid uri");
-	ok(swim_error_check_match("invalid uri"), "diag says 'invalid uri'");
+	ok(swim_test_error_check_match("invalid uri"),
+	   "diag says 'invalid uri'");
 
 	is(swim_remove_member(s2, swim_member_uuid(s2_self)), -1,
 	   "can not remove self");
-	ok(swim_error_check_match("can not remove self"),
+	ok(swim_test_error_check_match("can not remove self"),
 	   "diag says the same");
 
 	isnt(swim_member_by_uuid(s1, swim_member_uuid(s2_self)), NULL,
@@ -214,7 +217,7 @@ swim_test_add_remove(void)
 	 * before its completion.
 	 */
 	swim_cluster_block_io(cluster, 0);
-	swim_run_for(1);
+	swim_test_run_for(1);
 	/*
 	 * Now the message from s1 is in 'fly', round step is not
 	 * finished.
@@ -226,13 +229,13 @@ swim_test_add_remove(void)
 
 	swim_cluster_delete(cluster);
 
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static void
 swim_test_basic_failure_detection(void)
 {
-	swim_start_test(7);
+	swim_test_start(7);
 	struct swim_cluster *cluster = swim_cluster_new(2);
 	swim_cluster_set_ack_timeout(cluster, 0.5);
 
@@ -262,24 +265,24 @@ swim_test_basic_failure_detection(void)
 	/* A member can be removed during an ACK wait. */
 	swim_cluster_block_io(cluster, 1);
 	/* Next round after 1 sec + let ping hang for 0.25 sec. */
-	swim_run_for(1.25);
+	swim_test_run_for(1.25);
 	struct swim *s1 = swim_cluster_node(cluster, 0);
 	struct swim *s2 = swim_cluster_node(cluster, 1);
 	const struct swim_member *s2_self = swim_self(s2);
 	swim_remove_member(s1, swim_member_uuid(s2_self));
 	swim_cluster_unblock_io(cluster, 1);
-	swim_run_for(0.1);
+	swim_test_run_for(0.1);
 	is(swim_cluster_member_status(cluster, 0, 1), MEMBER_ALIVE,
 	   "a member is added back on an ACK");
 
 	swim_cluster_delete(cluster);
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static void
 swim_test_basic_gossip(void)
 {
-	swim_start_test(4);
+	swim_test_start(4);
 	struct swim_cluster *cluster = swim_cluster_new(3);
 	swim_cluster_set_ack_timeout(cluster, 10);
 	/*
@@ -298,7 +301,7 @@ swim_test_basic_gossip(void)
 	 * Wait two no-ACKs on S1 from S2. +1 sec to send a first
 	 * ping.
 	 */
-	swim_run_for(20 + 1);
+	swim_test_run_for(20 + 1);
 	swim_cluster_add_link(cluster, 0, 2);
 	swim_cluster_add_link(cluster, 2, 1);
 	/*
@@ -307,11 +310,11 @@ swim_test_basic_gossip(void)
 	 * S1 from informing S3 about that the S3 IO is blocked
 	 * for a short time.
 	 */
-	swim_run_for(9);
+	swim_test_run_for(9);
 	is(swim_cluster_member_status(cluster, 0, 1), MEMBER_ALIVE,
 	   "S1 still thinks that S2 is alive");
 	swim_cluster_block_io(cluster, 2);
-	swim_run_for(1);
+	swim_test_run_for(1);
 	is(swim_cluster_member_status(cluster, 0, 1), MEMBER_DEAD, "but one "\
 	   "more second, and a third ack timed out - S1 sees S2 as dead");
 	is(swim_cluster_member_status(cluster, 2, 1), MEMBER_ALIVE,
@@ -325,13 +328,13 @@ swim_test_basic_gossip(void)
 	   "S3 learns about dead S2 from S1");
 
 	swim_cluster_delete(cluster);
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static void
 swim_test_probe(void)
 {
-	swim_start_test(2);
+	swim_test_start(2);
 	struct swim_cluster *cluster = swim_cluster_new(2);
 
 	struct swim *s1 = swim_cluster_node(cluster, 0);
@@ -342,13 +345,13 @@ swim_test_probe(void)
 	   "receive ACK on probe and get fullmesh")
 
 	swim_cluster_delete(cluster);
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static void
 swim_test_refute(void)
 {
-	swim_start_test(4);
+	swim_test_start(4);
 	struct swim_cluster *cluster = swim_cluster_new(2);
 	swim_cluster_set_ack_timeout(cluster, 2);
 
@@ -368,13 +371,13 @@ swim_test_refute(void)
 	   "S2 learned its old bigger incarnation 1 from S0");
 
 	swim_cluster_delete(cluster);
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static void
 swim_test_too_big_packet(void)
 {
-	swim_start_test(2);
+	swim_test_start(2);
 	int size = 50;
 	struct swim_cluster *cluster = swim_cluster_new(size);
 	for (int i = 1; i < size; ++i)
@@ -402,13 +405,13 @@ swim_test_too_big_packet(void)
 	is(i, size, "S%d drops all the packets - it should become dead",
 	   drop_id + 1);
 	swim_cluster_delete(cluster);
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static void
 swim_test_undead(void)
 {
-	swim_start_test(2);
+	swim_test_start(2);
 	struct swim_cluster *cluster = swim_cluster_new(2);
 	swim_cluster_set_gc(cluster, SWIM_GC_OFF);
 	swim_cluster_set_ack_timeout(cluster, 1);
@@ -417,17 +420,17 @@ swim_test_undead(void)
 	swim_cluster_set_drop(cluster, 1, true);
 	is(swim_cluster_wait_status(cluster, 0, 1, MEMBER_DEAD, 4), 0,
 	   "member S2 is dead");
-	swim_run_for(5);
+	swim_test_run_for(5);
 	is(swim_cluster_member_status(cluster, 0, 1), MEMBER_DEAD,
 	   "but it is never deleted due to the cfg option");
 	swim_cluster_delete(cluster);
-	swim_finish_test();
+	swim_test_finish();
 }
 
 static int
 main_f(va_list ap)
 {
-	swim_start_test(11);
+	swim_test_start(11);
 
 	(void) ap;
 	swim_test_ev_init();
diff --git a/test/unit/swim_test_utils.c b/test/unit/swim_test_utils.c
index bb413372c..006c7446f 100644
--- a/test/unit/swim_test_utils.c
+++ b/test/unit/swim_test_utils.c
@@ -270,7 +270,7 @@ swim_loop_check_false(struct swim_cluster *cluster, void *data)
 }
 
 void
-swim_run_for(double duration)
+swim_test_run_for(double duration)
 {
 	swim_wait_timeout(duration, NULL, swim_loop_check_false, NULL);
 }
@@ -384,7 +384,7 @@ swim_cluster_wait_incarnation(struct swim_cluster *cluster, int node_id,
 }
 
 bool
-swim_error_check_match(const char *msg)
+swim_test_error_check_match(const char *msg)
 {
 	return strstr(diag_last_error(diag_get())->errmsg, msg) != NULL;
 }
diff --git a/test/unit/swim_test_utils.h b/test/unit/swim_test_utils.h
index d2ef00817..4a1ff4cb8 100644
--- a/test/unit/swim_test_utils.h
+++ b/test/unit/swim_test_utils.h
@@ -61,7 +61,7 @@ swim_cluster_delete(struct swim_cluster *cluster);
 
 /** Check that an error in diag contains @a msg. */
 bool
-swim_error_check_match(const char *msg);
+swim_test_error_check_match(const char *msg);
 
 /** Get a SWIM instance by its ordinal number. */
 struct swim *
@@ -130,15 +130,15 @@ swim_cluster_wait_incarnation(struct swim_cluster *cluster, int node_id,
 
 /** Process SWIM events for @a duration fake seconds. */
 void
-swim_run_for(double duration);
+swim_test_run_for(double duration);
 
-#define swim_start_test(n) { \
+#define swim_test_start(n) { \
 	header(); \
 	say_verbose("-------- SWIM start test %s --------", __func__); \
 	plan(n); \
 }
 
-#define swim_finish_test() { \
+#define swim_test_finish() { \
 	say_verbose("-------- SWIM end test %s --------", __func__); \
 	swim_test_ev_reset(); \
 	check_plan(); \
-- 
2.17.2 (Apple Git-113)

  parent reply	other threads:[~2019-04-09 11:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 11:46 [tarantool-patches] [PATCH v2 0/6] swim dissemination Vladislav Shpilevoy
2019-04-09 11:46 ` [tarantool-patches] [PATCH v2 1/6] swim: encapsulate member bin info into a 'passport' Vladislav Shpilevoy
2019-04-09 11:46 ` [tarantool-patches] [PATCH v2 2/6] swim: make members array decoder be a separate function Vladislav Shpilevoy
2019-04-09 11:46 ` Vladislav Shpilevoy [this message]
2019-04-09 11:46 ` [tarantool-patches] [PATCH v2 4/6] test: speed up swim big cluster failure detection Vladislav Shpilevoy
2019-04-09 11:46 ` [tarantool-patches] [PATCH v2 5/6] test: set packet drop rate instead of flag in swim tests Vladislav Shpilevoy
2019-04-09 11:46 ` [tarantool-patches] [PATCH v2 6/6] swim: introduce dissemination component Vladislav Shpilevoy
2019-04-09 13:47   ` [tarantool-patches] " Konstantin Osipov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=993ef40a1729405cf0d72cc9806a0539436c244c.1554809200.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v2 3/6] test: rename some swim test methods and macros' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox