X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=tst%2Fsyncstorageimpl_test.cpp;fp=tst%2Fsyncstorageimpl_test.cpp;h=570b61af1899b8cfd5999fde2d0db5efe0b864e0;hb=d565df6613d97c08664a00f3fbc7cb5fdcf233f6;hp=78603341487f01f86c84a36f0050b3ae2eda16da;hpb=faf9fc79e58fa4ace9b0ef317b741afb2c1a8abe;p=ric-plt%2Fsdl.git diff --git a/tst/syncstorageimpl_test.cpp b/tst/syncstorageimpl_test.cpp index 7860334..570b61a 100644 --- a/tst/syncstorageimpl_test.cpp +++ b/tst/syncstorageimpl_test.cpp @@ -30,6 +30,7 @@ #include #include #include +#include using namespace shareddatalayer; using namespace shareddatalayer::redis; @@ -59,7 +60,9 @@ namespace SyncStorage::DataMap dataMap; SyncStorage::Keys keys; const SyncStorage::Namespace ns; + std::chrono::steady_clock::duration TEST_READY_WAIT_TIMEOUT; std::chrono::steady_clock::duration TEST_OPERATION_WAIT_TIMEOUT; + int TEST_READY_POLL_WAIT_TIMEOUT; int TEST_OPERATION_POLL_WAIT_TIMEOUT; SyncStorageImplTest(): asyncStorageMockPassedToImplementation(new StrictMock()), @@ -68,7 +71,9 @@ namespace dataMap({{ "key1", { 0x0a, 0x0b, 0x0c } }, { "key2", { 0x0d, 0x0e, 0x0f, 0xff } }}), keys({ "key1", "key2" }), ns("someKnownNamespace"), + TEST_READY_WAIT_TIMEOUT(std::chrono::minutes(1)), TEST_OPERATION_WAIT_TIMEOUT(std::chrono::seconds(1)), + TEST_READY_POLL_WAIT_TIMEOUT(std::chrono::duration_cast(TEST_READY_WAIT_TIMEOUT).count() / 10), TEST_OPERATION_POLL_WAIT_TIMEOUT(std::chrono::duration_cast(TEST_OPERATION_WAIT_TIMEOUT).count() / 10) { expectConstructorCalls(); @@ -156,6 +161,16 @@ namespace })); } + void expectHandleEvents_callWaitReadyAckWithError() + { + EXPECT_CALL(*asyncStorageMockRawPtr, handleEvents()) + .Times(1) + .WillOnce(Invoke([this]() + { + savedReadyAck(AsyncRedisCommandDispatcherErrorCode::NOT_CONNECTED); + })); + } + void expectHandleEvents_callModifyAck() { EXPECT_CALL(*asyncStorageMockRawPtr, handleEvents()) @@ -173,7 +188,6 @@ namespace .WillOnce(SaveArg<1>(&savedReadyAck)); } - void expectModifyAckWithError() { EXPECT_CALL(*asyncStorageMockRawPtr, handleEvents()) @@ -327,6 +341,31 @@ TEST_F(SyncStorageImplTest, EventsAreNotHandledWhenThereIsAnExceptionalCondition syncStorage->set(ns, dataMap); } +TEST_F(SyncStorageImplTest, WaitReadySuccessfully) +{ + InSequence dummy; + expectWaitReadyAsync(); + expectPollWait(TEST_READY_POLL_WAIT_TIMEOUT); + expectHandleEvents_callWaitReadyAck(); + syncStorage->waitReady(ns, TEST_READY_WAIT_TIMEOUT); +} + +TEST_F(SyncStorageImplTest, WaitReadyCanThrowRejectedBySdl) +{ + InSequence dummy; + expectWaitReadyAsync(); + EXPECT_THROW(syncStorage->waitReady(ns, std::chrono::nanoseconds(1)), RejectedBySdl); +} + +TEST_F(SyncStorageImplTest, WaitReadyCanThrowNotConnected) +{ + InSequence dummy; + expectWaitReadyAsync(); + expectPollWait(TEST_READY_POLL_WAIT_TIMEOUT); + expectHandleEvents_callWaitReadyAckWithError(); + EXPECT_THROW(syncStorage->waitReady(ns, TEST_READY_WAIT_TIMEOUT), NotConnected); +} + TEST_F(SyncStorageImplTest, SetSuccessfully) { InSequence dummy;