From 80177c9b3eedd190b279be32b6a3bb52b395b823 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 30 Jun 2026 00:34:06 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20test=5Fconn=5Fmgr=20flakiness=20?= =?UTF-8?q?=E2=80=94=20wait=20for=20BGP=20nodeinfo,=20not=20just=20INIT=20?= =?UTF-8?q?links?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: test1 used lks() (INIT links up) but conn_mgr needs BGP NODEINFO. Nodeinfo arrives after INIT, so test1 must wait for it. Also made result volatile to prevent loop optimization. --- tests/test_conn_mgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_conn_mgr.c b/tests/test_conn_mgr.c index 1a8ce2c8..c7d995fb 100644 --- a/tests/test_conn_mgr.c +++ b/tests/test_conn_mgr.c @@ -39,7 +39,7 @@ static struct UTUN_INSTANCE* g_a = NULL, *g_b = NULL; static struct UASYNC* ua = NULL; -static int result = 0; +static volatile int result = 0; static void* ttimer = NULL; static char tdir[] = "/tmp/utun_cm_XXXXXX"; static char ca[256], cb[256]; @@ -73,14 +73,14 @@ static void ccb(int r, uint64_t id, void* arg) { static void test1(void* arg) { (void)arg; if (result) return; - if (lks(g_a) < 1 || lks(g_b) < 1) { uasync_set_timeout(ua, 50, NULL, (timeout_callback_t)test1, "t1"); return; } + if (!nodeinfo_find_by_id(g_a->bgp, NID_B)) { uasync_set_timeout(ua, 50, NULL, (timeout_callback_t)test1, "t1"); return; } fprintf(stderr, "Test 1: direct — conn_mgr_connect_node(B)\n"); fflush(stderr); conn_mgr_connect_node(g_a->conn_mgr, NID_B, 0, ccb, NULL); - uasync_set_timeout(ua, 100, NULL, (timeout_callback_t)test2, "t2a"); + uasync_set_timeout(ua, 50, NULL, (timeout_callback_t)test2, "t2a"); } static void test2(void* arg) { (void)arg; if (result) return; - if (!cdone) { uasync_set_timeout(ua, 100, NULL, (timeout_callback_t)test2, "t2b"); return; } + if (!cdone) { uasync_set_timeout(ua, 50, NULL, (timeout_callback_t)test2, "t2b"); return; } if (cresult != CONN_MGR_OK) { fail("connect failed"); return; } uint8_t st, ty; conn_mgr_get_status(g_a->conn_mgr, NID_B, &st, &ty); fprintf(stderr, "Test 2: status state=%d type=%d\n", st, ty); fflush(stderr);