/* * test_phase2_cold_boot.c -- bug-1876: while a standby waits for the * primary's config push, cluster_init_phase2() has nothing to build yet. * That is the normal cold-boot state, but it returned -EINVAL, and its * callers logged it as a WARN ("cluster_init_phase2 on standby rejoin * failed (rc=-22)") every 3 s until the config arrived. It now returns * -EAGAIN, which the callers log at INFO. */ #include #include #include #include "cluster.h" #include "ha.h" #include "myconf.h" #include "xce/cluster_def.h" extern int cluster_init_phase2(cluster_t* c); static void test_phase2_without_config_is_a_wait_not_an_error(void) { cluster_t c; myconf_t conf; memset(&c, 0, sizeof(c)); memset(&conf, 0, sizeof(conf)); c.myconf = &conf; /* cluster_config not pushed yet */ TEST_ASSERT_EQUAL_INT(-EAGAIN, cluster_init_phase2(&c)); TEST_ASSERT_TRUE(ha_phase2_rc_is_waiting(-EAGAIN)); TEST_ASSERT_FALSE(ha_phase2_rc_is_waiting(-EINVAL)); TEST_ASSERT_FALSE(ha_phase2_rc_is_waiting(0)); } void test_phase2_cold_boot(void) { UnitySetTestFile(__FILE__); RUN_TEST(test_phase2_without_config_is_a_wait_not_an_error); }