提交 9c428f92 编写于 作者: J Jacob Champion 提交者: Xin Zhang

Fix unit test compilation, remove SyncStandbysDefined tests

SetSyncStandbysDefined and friends are now much simpler; there isn't
really anything interesting to test anymore. We already have an
integration test that covers the operation for the whole cluster.
上级 3b80a6e2
......@@ -58,7 +58,6 @@ EXCL_OBJS+=\
src/backend/utils/adt/lockfuncs.o \
src/backend/utils/adt/mac.o \
src/backend/utils/adt/matrix.o \
src/backend/utils/adt/misc.o \
src/backend/utils/adt/oracle_compat.o \
src/backend/utils/adt/pgstatfuncs.o \
src/backend/utils/adt/pivot.o \
......
......@@ -115,84 +115,6 @@ test_GetMirrorStatus_WALSNDSTATE_STREAMING(void **state)
assert_true(response.IsInSync);
}
void
test_SetSyncStandbysDefined(void **state)
{
WalSndCtlData data;
WalSndCtl = &data;
data.sync_standbys_defined = false;
expect_lwlock(LW_EXCLUSIVE);
#ifdef USE_ASSERT_CHECKING
expect_value(LWLockHeldByMe, lockid, SyncRepLock);
will_return(LWLockHeldByMe, true);
#endif
/*
* set_gp_replication_config() should only be called once when mirror first
* comes up to set synchronous wal rep state
*/
expect_string_count(set_gp_replication_config, name, "synchronous_standby_names", 1);
expect_string_count(set_gp_replication_config, value, "*", 1);
will_be_called(set_gp_replication_config);
/* simulate first call when mirror first comes up */
assert_false(WalSndCtl->sync_standbys_defined);
assert_true(SyncRepStandbyNames == NULL);
SetSyncStandbysDefined();
/* relative variables should have updated */
assert_true(WalSndCtl->sync_standbys_defined);
assert_true(strcmp(SyncRepStandbyNames, "*") == 0);
expect_lwlock(LW_EXCLUSIVE);
/* simulate second call after sync state is set which should do nothing */
SetSyncStandbysDefined();
}
void
test_UnsetSyncStandbysDefined(void **state)
{
int shmqueuenext_calls;
WalSndCtlData data;
WalSndCtl = &data;
data.sync_standbys_defined = true;
/* mock SHMQueueNext to skip the SyncRepWakeQueue */
#ifdef USE_ASSERT_CHECKING
shmqueuenext_calls = 4;
#else
shmqueuenext_calls = 2;
#endif
expect_any_count(SHMQueueNext, queue, shmqueuenext_calls);
expect_any_count(SHMQueueNext, curElem, shmqueuenext_calls);
expect_any_count(SHMQueueNext, linkOffset, shmqueuenext_calls);
will_return_count(SHMQueueNext, NULL, shmqueuenext_calls);
expect_lwlock(LW_EXCLUSIVE);
#ifdef USE_ASSERT_CHECKING
expect_value(LWLockHeldByMe, lockid, SyncRepLock);
will_return(LWLockHeldByMe, true);
#endif
/* unset the GUC in-memory */
expect_string_count(set_gp_replication_config, name, "synchronous_standby_names", 1);
expect_string_count(set_gp_replication_config, value, "", 1);
will_be_called(set_gp_replication_config);
/* simulate call when primary is in synchronous replication */
assert_true(WalSndCtl->sync_standbys_defined);
assert_true(strcmp(SyncRepStandbyNames, "*") == 0);
/* call the function we are testing */
UnsetSyncStandbysDefined();
/* relative variables should have updated */
assert_false(WalSndCtl->sync_standbys_defined);
assert_true(strcmp(SyncRepStandbyNames, "") == 0);
}
int
main(int argc, char* argv[])
{
......@@ -203,9 +125,7 @@ main(int argc, char* argv[])
unit_test(test_GetMirrorStatus_WALSNDSTATE_STARTUP),
unit_test(test_GetMirrorStatus_WALSNDSTATE_BACKUP),
unit_test(test_GetMirrorStatus_WALSNDSTATE_CATCHUP),
unit_test(test_GetMirrorStatus_WALSNDSTATE_STREAMING),
unit_test(test_SetSyncStandbysDefined),
unit_test(test_UnsetSyncStandbysDefined)
unit_test(test_GetMirrorStatus_WALSNDSTATE_STREAMING)
};
return run_tests(tests);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册