From 9c428f92cc838fda853a23b1e0d2a878722f4d6c Mon Sep 17 00:00:00 2001 From: Jacob Champion Date: Tue, 9 Jan 2018 19:02:41 -0800 Subject: [PATCH] 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. --- src/backend/mock.mk | 1 - .../replication/test/gp_replication_test.c | 82 +------------------ 2 files changed, 1 insertion(+), 82 deletions(-) diff --git a/src/backend/mock.mk b/src/backend/mock.mk index bd7448ad05..a826ade65c 100644 --- a/src/backend/mock.mk +++ b/src/backend/mock.mk @@ -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 \ diff --git a/src/backend/replication/test/gp_replication_test.c b/src/backend/replication/test/gp_replication_test.c index 024a251a03..b1cb5d062d 100644 --- a/src/backend/replication/test/gp_replication_test.c +++ b/src/backend/replication/test/gp_replication_test.c @@ -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); } -- GitLab