Browse Source

fix: test_conn_mgr flakiness — wait for BGP nodeinfo, not just INIT links

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.
feature/x25519-migration
Evgeny 3 months ago
parent
commit
80177c9b3e
  1. 8
      tests/test_conn_mgr.c

8
tests/test_conn_mgr.c

@ -39,7 +39,7 @@
static struct UTUN_INSTANCE* g_a = NULL, *g_b = NULL; static struct UTUN_INSTANCE* g_a = NULL, *g_b = NULL;
static struct UASYNC* ua = NULL; static struct UASYNC* ua = NULL;
static int result = 0; static volatile int result = 0;
static void* ttimer = NULL; static void* ttimer = NULL;
static char tdir[] = "/tmp/utun_cm_XXXXXX"; static char tdir[] = "/tmp/utun_cm_XXXXXX";
static char ca[256], cb[256]; 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) { static void test1(void* arg) {
(void)arg; if (result) return; (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); 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); 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) { static void test2(void* arg) {
(void)arg; if (result) return; (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; } 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); 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); fprintf(stderr, "Test 2: status state=%d type=%d\n", st, ty); fflush(stderr);

Loading…
Cancel
Save