From cbc856b1907c1560b3d11cdf73847d9d2cf2301b Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Tue, 7 May 2024 15:12:48 +0100 Subject: [PATCH] Separate unit tests and integration tests (#1393) Fixes #1391 --- .clang-tidy | 2 +- .githooks/check-format | 2 +- .github/actions/code_coverage/action.yml | 8 +++-- .github/actions/generate/action.yml | 2 +- .github/workflows/build.yml | 15 ++------- .github/workflows/nightly.yml | 18 +++++++++-- CMakeLists.txt | 17 ++-------- CONTRIBUTING.md | 2 +- conanfile.py | 21 +++++++------ docs/coverage-report.md | 9 ------ src/rpc/README.md | 2 +- tests/CMakeLists.txt | 20 ++++++++++++ tests/common/CMakeLists.txt | 10 ++++++ .../common/data/cassandra}/FakesAndMocks.hpp | 0 .../common/etl}/FakeDiffProvider.hpp | 0 .../common}/feed/FeedTestUtil.hpp | 0 .../common/rpc}/FakesAndMocks.hpp | 4 +-- .../common}/util/FakeAmendmentBlockAction.hpp | 0 .../common}/util/FakeFetchResponse.hpp | 0 {unittests => tests/common}/util/Fixtures.hpp | 0 .../util/MockAmendmentBlockHandler.hpp | 0 .../common}/util/MockBackend.hpp | 0 .../common}/util/MockCache.hpp | 0 .../common}/util/MockCounters.hpp | 0 .../common}/util/MockETLService.hpp | 0 .../common}/util/MockExecutionContext.hpp | 0 .../common}/util/MockExtractionDataPipe.hpp | 0 .../common}/util/MockHandlerProvider.hpp | 0 .../common}/util/MockLedgerFetcher.hpp | 0 .../common}/util/MockLedgerLoader.hpp | 0 .../common}/util/MockLedgerPublisher.hpp | 0 .../common}/util/MockLoadBalancer.hpp | 0 .../util/MockNetworkValidatedLedgers.hpp | 0 .../common}/util/MockOperation.hpp | 0 .../common}/util/MockPrometheus.hpp | 0 .../common}/util/MockRPCEngine.hpp | 0 .../common}/util/MockSource.hpp | 0 .../common}/util/MockStopToken.hpp | 0 .../common}/util/MockStrand.hpp | 0 .../common}/util/MockSubscriptionManager.hpp | 0 .../common}/util/MockWsBase.hpp | 0 .../common}/util/MockXrpLedgerAPIService.hpp | 4 +-- .../common}/util/StringUtils.cpp | 0 .../common}/util/StringUtils.hpp | 0 .../common}/util/TestHttpServer.cpp | 0 .../common}/util/TestHttpServer.hpp | 0 .../common}/util/TestHttpSyncClient.hpp | 0 .../common}/util/TestObject.cpp | 0 .../common}/util/TestObject.hpp | 0 .../common}/util/TestWsServer.cpp | 0 .../common}/util/TestWsServer.hpp | 0 {unittests => tests/common}/util/TmpFile.hpp | 0 tests/integration/CMakeLists.txt | 15 +++++++++ {unittests => tests/integration}/Main.cpp | 4 +-- tests/integration/README.md | 10 ++++++ .../integration}/TestGlobals.cpp | 3 +- .../integration}/TestGlobals.hpp | 0 .../integration}/data/BackendFactoryTests.cpp | 5 +-- .../data/cassandra/BackendTests.cpp | 2 +- .../integration}/data/cassandra/BaseTests.cpp | 2 +- {unittests => tests/unit}/CMakeLists.txt | 17 +++------- {unittests => tests/unit}/ConfigTests.cpp | 0 {unittests => tests/unit}/DOSGuardTests.cpp | 0 {unittests => tests/unit}/JsonUtilTests.cpp | 0 {unittests => tests/unit}/LoggerTests.cpp | 0 tests/unit/Main.cpp | 31 +++++++++++++++++++ {unittests => tests/unit}/Playground.cpp | 0 {unittests => tests/unit}/ProfilerTests.cpp | 0 tests/unit/README.md | 9 ++++++ .../unit}/data/BackendCountersTests.cpp | 0 .../unit}/data/BackendInterfaceTests.cpp | 0 .../data/cassandra/AsyncExecutorTests.cpp | 2 +- .../data/cassandra/ExecutionStrategyTests.cpp | 3 +- .../unit}/data/cassandra/RetryPolicyTests.cpp | 0 .../data/cassandra/SettingsProviderTests.cpp | 0 .../unit}/etl/AmendmentBlockHandlerTests.cpp | 0 .../unit}/etl/CacheLoaderSettingsTests.cpp | 0 .../unit}/etl/CacheLoaderTests.cpp | 2 +- .../unit}/etl/CorruptionDetectorTests.cpp | 0 .../etl/CursorFromAccountProviderTests.cpp | 0 .../unit}/etl/CursorFromDiffProviderTests.cpp | 0 .../etl/CursorFromFixDiffNumProviderTests.cpp | 2 +- .../unit}/etl/ETLStateTests.cpp | 0 .../unit}/etl/ExtractionDataPipeTests.cpp | 0 .../unit}/etl/ExtractorTests.cpp | 0 .../unit}/etl/ForwardingCacheTests.cpp | 0 .../unit}/etl/ForwardingSourceTests.cpp | 0 .../unit}/etl/GrpcSourceTests.cpp | 4 +-- .../unit}/etl/LedgerPublisherTests.cpp | 0 {unittests => tests/unit}/etl/SourceTests.cpp | 0 .../SubscriptionSourceDependenciesTests.cpp | 0 .../unit}/etl/SubscriptionSourceTests.cpp | 0 .../unit}/etl/TransformerTests.cpp | 0 .../unit}/feed/BookChangesFeedTests.cpp | 0 .../unit}/feed/ForwardFeedTests.cpp | 0 .../unit}/feed/LedgerFeedTests.cpp | 0 .../feed/ProposedTransactionFeedTests.cpp | 0 .../unit}/feed/SingleFeedBaseTests.cpp | 0 .../unit}/feed/SubscriptionManagerTests.cpp | 0 .../unit}/feed/TrackableSignalTests.cpp | 0 .../unit}/feed/TransactionFeedTests.cpp | 0 .../unit}/rpc/APIVersionTests.cpp | 0 .../unit}/rpc/AmendmentsTests.cpp | 0 {unittests => tests/unit}/rpc/BaseTests.cpp | 0 .../unit}/rpc/CountersTests.cpp | 0 {unittests => tests/unit}/rpc/ErrorTests.cpp | 0 .../unit}/rpc/ForwardingProxyTests.cpp | 0 .../unit}/rpc/JsonBoolTests.cpp | 0 .../unit}/rpc/RPCHelpersTests.cpp | 0 .../unit}/rpc/WorkQueueTests.cpp | 0 .../unit}/rpc/common/CheckersTests.cpp | 0 .../unit}/rpc/common/SpecsTests.cpp | 0 .../unit}/rpc/common/TypesTests.cpp | 0 .../unit}/rpc/handlers/AMMInfoTests.cpp | 0 .../rpc/handlers/AccountChannelsTests.cpp | 0 .../rpc/handlers/AccountCurrenciesTests.cpp | 0 .../unit}/rpc/handlers/AccountInfoTests.cpp | 0 .../unit}/rpc/handlers/AccountLinesTests.cpp | 0 .../unit}/rpc/handlers/AccountNFTsTests.cpp | 0 .../rpc/handlers/AccountObjectsTests.cpp | 0 .../unit}/rpc/handlers/AccountOffersTests.cpp | 0 .../unit}/rpc/handlers/AccountTxTests.cpp | 0 .../unit}/rpc/handlers/BookChangesTests.cpp | 0 .../unit}/rpc/handlers/BookOffersTests.cpp | 0 .../rpc/handlers/DefaultProcessorTests.cpp | 4 +-- .../rpc/handlers/DepositAuthorizedTests.cpp | 0 .../rpc/handlers/GatewayBalancesTests.cpp | 0 .../rpc/handlers/GetAggregatePriceTests.cpp | 0 .../unit}/rpc/handlers/LedgerDataTests.cpp | 0 .../unit}/rpc/handlers/LedgerEntryTests.cpp | 0 .../unit}/rpc/handlers/LedgerRangeTests.cpp | 0 .../unit}/rpc/handlers/LedgerTests.cpp | 0 .../unit}/rpc/handlers/NFTBuyOffersTests.cpp | 0 .../unit}/rpc/handlers/NFTHistoryTests.cpp | 0 .../unit}/rpc/handlers/NFTInfoTests.cpp | 0 .../unit}/rpc/handlers/NFTSellOffersTests.cpp | 0 .../unit}/rpc/handlers/NFTsByIssuerTest.cpp | 0 .../unit}/rpc/handlers/NoRippleCheckTests.cpp | 0 .../unit}/rpc/handlers/PingTests.cpp | 0 .../unit}/rpc/handlers/RandomTests.cpp | 0 .../unit}/rpc/handlers/ServerInfoTests.cpp | 0 .../unit}/rpc/handlers/SubscribeTests.cpp | 0 .../unit}/rpc/handlers/TestHandlerTests.cpp | 4 +-- .../rpc/handlers/TransactionEntryTests.cpp | 0 .../unit}/rpc/handlers/TxTests.cpp | 0 .../unit}/rpc/handlers/UnsubscribeTests.cpp | 0 .../rpc/handlers/VersionHandlerTests.cpp | 0 .../unit}/util/AssertTests.cpp | 0 .../unit}/util/AtomicTests.cpp | 0 .../unit}/util/BatchingTests.cpp | 0 .../unit}/util/LedgerUtilsTests.cpp | 0 {unittests => tests/unit}/util/RetryTests.cpp | 0 .../unit}/util/SignalsHandlerTests.cpp | 0 .../unit}/util/TxUtilTests.cpp | 0 .../util/async/AnyExecutionContextTests.cpp | 0 .../unit}/util/async/AnyOperationTests.cpp | 0 .../unit}/util/async/AnyStopTokenTests.cpp | 0 .../unit}/util/async/AnyStrandTests.cpp | 0 .../util/async/AsyncExecutionContextTests.cpp | 0 .../unit}/util/prometheus/BoolTests.cpp | 0 .../unit}/util/prometheus/CounterTests.cpp | 0 .../unit}/util/prometheus/GaugeTests.cpp | 0 .../unit}/util/prometheus/HistogramTests.cpp | 0 .../unit}/util/prometheus/HttpTests.cpp | 0 .../unit}/util/prometheus/LabelTests.cpp | 0 .../util/prometheus/MetricBuilderTests.cpp | 0 .../util/prometheus/MetricsFamilyTests.cpp | 0 .../unit}/util/prometheus/OStreamTests.cpp | 0 .../util/requests/RequestBuilderTests.cpp | 0 .../unit}/util/requests/SslContextTests.cpp | 0 .../unit}/util/requests/WsConnectionTests.cpp | 0 .../unit}/web/AdminVerificationTests.cpp | 0 .../unit}/web/RPCServerHandlerTests.cpp | 0 {unittests => tests/unit}/web/ServerTests.cpp | 0 .../unit}/web/SweepHandlerTests.cpp | 4 +-- .../unit}/web/WhitelistHandlerTests.cpp | 0 unittests/README.md | 15 --------- 177 files changed, 168 insertions(+), 106 deletions(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/common/CMakeLists.txt rename {unittests/data/cassandra/impl => tests/common/data/cassandra}/FakesAndMocks.hpp (100%) rename {unittests/etl/impl => tests/common/etl}/FakeDiffProvider.hpp (100%) rename {unittests => tests/common}/feed/FeedTestUtil.hpp (100%) rename {unittests/rpc/handlers/impl => tests/common/rpc}/FakesAndMocks.hpp (98%) rename {unittests => tests/common}/util/FakeAmendmentBlockAction.hpp (100%) rename {unittests => tests/common}/util/FakeFetchResponse.hpp (100%) rename {unittests => tests/common}/util/Fixtures.hpp (100%) rename {unittests => tests/common}/util/MockAmendmentBlockHandler.hpp (100%) rename {unittests => tests/common}/util/MockBackend.hpp (100%) rename {unittests => tests/common}/util/MockCache.hpp (100%) rename {unittests => tests/common}/util/MockCounters.hpp (100%) rename {unittests => tests/common}/util/MockETLService.hpp (100%) rename {unittests => tests/common}/util/MockExecutionContext.hpp (100%) rename {unittests => tests/common}/util/MockExtractionDataPipe.hpp (100%) rename {unittests => tests/common}/util/MockHandlerProvider.hpp (100%) rename {unittests => tests/common}/util/MockLedgerFetcher.hpp (100%) rename {unittests => tests/common}/util/MockLedgerLoader.hpp (100%) rename {unittests => tests/common}/util/MockLedgerPublisher.hpp (100%) rename {unittests => tests/common}/util/MockLoadBalancer.hpp (100%) rename {unittests => tests/common}/util/MockNetworkValidatedLedgers.hpp (100%) rename {unittests => tests/common}/util/MockOperation.hpp (100%) rename {unittests => tests/common}/util/MockPrometheus.hpp (100%) rename {unittests => tests/common}/util/MockRPCEngine.hpp (100%) rename {unittests => tests/common}/util/MockSource.hpp (100%) rename {unittests => tests/common}/util/MockStopToken.hpp (100%) rename {unittests => tests/common}/util/MockStrand.hpp (100%) rename {unittests => tests/common}/util/MockSubscriptionManager.hpp (100%) rename {unittests => tests/common}/util/MockWsBase.hpp (100%) rename {unittests => tests/common}/util/MockXrpLedgerAPIService.hpp (98%) rename {unittests => tests/common}/util/StringUtils.cpp (100%) rename {unittests => tests/common}/util/StringUtils.hpp (100%) rename {unittests => tests/common}/util/TestHttpServer.cpp (100%) rename {unittests => tests/common}/util/TestHttpServer.hpp (100%) rename {unittests => tests/common}/util/TestHttpSyncClient.hpp (100%) rename {unittests => tests/common}/util/TestObject.cpp (100%) rename {unittests => tests/common}/util/TestObject.hpp (100%) rename {unittests => tests/common}/util/TestWsServer.cpp (100%) rename {unittests => tests/common}/util/TestWsServer.hpp (100%) rename {unittests => tests/common}/util/TmpFile.hpp (100%) create mode 100644 tests/integration/CMakeLists.txt rename {unittests => tests/integration}/Main.cpp (95%) create mode 100644 tests/integration/README.md rename {unittests/util => tests/integration}/TestGlobals.cpp (98%) rename {unittests/util => tests/integration}/TestGlobals.hpp (100%) rename {unittests => tests/integration}/data/BackendFactoryTests.cpp (97%) rename {unittests => tests/integration}/data/cassandra/BackendTests.cpp (99%) rename {unittests => tests/integration}/data/cassandra/BaseTests.cpp (99%) rename {unittests => tests/unit}/CMakeLists.txt (94%) rename {unittests => tests/unit}/ConfigTests.cpp (100%) rename {unittests => tests/unit}/DOSGuardTests.cpp (100%) rename {unittests => tests/unit}/JsonUtilTests.cpp (100%) rename {unittests => tests/unit}/LoggerTests.cpp (100%) create mode 100644 tests/unit/Main.cpp rename {unittests => tests/unit}/Playground.cpp (100%) rename {unittests => tests/unit}/ProfilerTests.cpp (100%) create mode 100644 tests/unit/README.md rename {unittests => tests/unit}/data/BackendCountersTests.cpp (100%) rename {unittests => tests/unit}/data/BackendInterfaceTests.cpp (100%) rename {unittests => tests/unit}/data/cassandra/AsyncExecutorTests.cpp (99%) rename {unittests => tests/unit}/data/cassandra/ExecutionStrategyTests.cpp (99%) rename {unittests => tests/unit}/data/cassandra/RetryPolicyTests.cpp (100%) rename {unittests => tests/unit}/data/cassandra/SettingsProviderTests.cpp (100%) rename {unittests => tests/unit}/etl/AmendmentBlockHandlerTests.cpp (100%) rename {unittests => tests/unit}/etl/CacheLoaderSettingsTests.cpp (100%) rename {unittests => tests/unit}/etl/CacheLoaderTests.cpp (99%) rename {unittests => tests/unit}/etl/CorruptionDetectorTests.cpp (100%) rename {unittests => tests/unit}/etl/CursorFromAccountProviderTests.cpp (100%) rename {unittests => tests/unit}/etl/CursorFromDiffProviderTests.cpp (100%) rename {unittests => tests/unit}/etl/CursorFromFixDiffNumProviderTests.cpp (98%) rename {unittests => tests/unit}/etl/ETLStateTests.cpp (100%) rename {unittests => tests/unit}/etl/ExtractionDataPipeTests.cpp (100%) rename {unittests => tests/unit}/etl/ExtractorTests.cpp (100%) rename {unittests => tests/unit}/etl/ForwardingCacheTests.cpp (100%) rename {unittests => tests/unit}/etl/ForwardingSourceTests.cpp (100%) rename {unittests => tests/unit}/etl/GrpcSourceTests.cpp (97%) rename {unittests => tests/unit}/etl/LedgerPublisherTests.cpp (100%) rename {unittests => tests/unit}/etl/SourceTests.cpp (100%) rename {unittests => tests/unit}/etl/SubscriptionSourceDependenciesTests.cpp (100%) rename {unittests => tests/unit}/etl/SubscriptionSourceTests.cpp (100%) rename {unittests => tests/unit}/etl/TransformerTests.cpp (100%) rename {unittests => tests/unit}/feed/BookChangesFeedTests.cpp (100%) rename {unittests => tests/unit}/feed/ForwardFeedTests.cpp (100%) rename {unittests => tests/unit}/feed/LedgerFeedTests.cpp (100%) rename {unittests => tests/unit}/feed/ProposedTransactionFeedTests.cpp (100%) rename {unittests => tests/unit}/feed/SingleFeedBaseTests.cpp (100%) rename {unittests => tests/unit}/feed/SubscriptionManagerTests.cpp (100%) rename {unittests => tests/unit}/feed/TrackableSignalTests.cpp (100%) rename {unittests => tests/unit}/feed/TransactionFeedTests.cpp (100%) rename {unittests => tests/unit}/rpc/APIVersionTests.cpp (100%) rename {unittests => tests/unit}/rpc/AmendmentsTests.cpp (100%) rename {unittests => tests/unit}/rpc/BaseTests.cpp (100%) rename {unittests => tests/unit}/rpc/CountersTests.cpp (100%) rename {unittests => tests/unit}/rpc/ErrorTests.cpp (100%) rename {unittests => tests/unit}/rpc/ForwardingProxyTests.cpp (100%) rename {unittests => tests/unit}/rpc/JsonBoolTests.cpp (100%) rename {unittests => tests/unit}/rpc/RPCHelpersTests.cpp (100%) rename {unittests => tests/unit}/rpc/WorkQueueTests.cpp (100%) rename {unittests => tests/unit}/rpc/common/CheckersTests.cpp (100%) rename {unittests => tests/unit}/rpc/common/SpecsTests.cpp (100%) rename {unittests => tests/unit}/rpc/common/TypesTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/AMMInfoTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/AccountChannelsTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/AccountCurrenciesTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/AccountInfoTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/AccountLinesTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/AccountNFTsTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/AccountObjectsTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/AccountOffersTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/AccountTxTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/BookChangesTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/BookOffersTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/DefaultProcessorTests.cpp (97%) rename {unittests => tests/unit}/rpc/handlers/DepositAuthorizedTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/GatewayBalancesTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/GetAggregatePriceTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/LedgerDataTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/LedgerEntryTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/LedgerRangeTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/LedgerTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/NFTBuyOffersTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/NFTHistoryTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/NFTInfoTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/NFTSellOffersTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/NFTsByIssuerTest.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/NoRippleCheckTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/PingTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/RandomTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/ServerInfoTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/SubscribeTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/TestHandlerTests.cpp (97%) rename {unittests => tests/unit}/rpc/handlers/TransactionEntryTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/TxTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/UnsubscribeTests.cpp (100%) rename {unittests => tests/unit}/rpc/handlers/VersionHandlerTests.cpp (100%) rename {unittests => tests/unit}/util/AssertTests.cpp (100%) rename {unittests => tests/unit}/util/AtomicTests.cpp (100%) rename {unittests => tests/unit}/util/BatchingTests.cpp (100%) rename {unittests => tests/unit}/util/LedgerUtilsTests.cpp (100%) rename {unittests => tests/unit}/util/RetryTests.cpp (100%) rename {unittests => tests/unit}/util/SignalsHandlerTests.cpp (100%) rename {unittests => tests/unit}/util/TxUtilTests.cpp (100%) rename {unittests => tests/unit}/util/async/AnyExecutionContextTests.cpp (100%) rename {unittests => tests/unit}/util/async/AnyOperationTests.cpp (100%) rename {unittests => tests/unit}/util/async/AnyStopTokenTests.cpp (100%) rename {unittests => tests/unit}/util/async/AnyStrandTests.cpp (100%) rename {unittests => tests/unit}/util/async/AsyncExecutionContextTests.cpp (100%) rename {unittests => tests/unit}/util/prometheus/BoolTests.cpp (100%) rename {unittests => tests/unit}/util/prometheus/CounterTests.cpp (100%) rename {unittests => tests/unit}/util/prometheus/GaugeTests.cpp (100%) rename {unittests => tests/unit}/util/prometheus/HistogramTests.cpp (100%) rename {unittests => tests/unit}/util/prometheus/HttpTests.cpp (100%) rename {unittests => tests/unit}/util/prometheus/LabelTests.cpp (100%) rename {unittests => tests/unit}/util/prometheus/MetricBuilderTests.cpp (100%) rename {unittests => tests/unit}/util/prometheus/MetricsFamilyTests.cpp (100%) rename {unittests => tests/unit}/util/prometheus/OStreamTests.cpp (100%) rename {unittests => tests/unit}/util/requests/RequestBuilderTests.cpp (100%) rename {unittests => tests/unit}/util/requests/SslContextTests.cpp (100%) rename {unittests => tests/unit}/util/requests/WsConnectionTests.cpp (100%) rename {unittests => tests/unit}/web/AdminVerificationTests.cpp (100%) rename {unittests => tests/unit}/web/RPCServerHandlerTests.cpp (100%) rename {unittests => tests/unit}/web/ServerTests.cpp (100%) rename {unittests => tests/unit}/web/SweepHandlerTests.cpp (93%) rename {unittests => tests/unit}/web/WhitelistHandlerTests.cpp (100%) delete mode 100644 unittests/README.md diff --git a/.clang-tidy b/.clang-tidy index 62422fc7..830df675 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -144,5 +144,5 @@ CheckOptions: bugprone-unused-return-value.CheckedReturnTypes: ::std::error_code;::std::error_condition;::std::errc misc-include-cleaner.IgnoreHeaders: '.*/(detail|impl)/.*;.*(expected|unexpected).*' -HeaderFilterRegex: '^.*/(src|unittests)/.*\.(h|hpp)$' +HeaderFilterRegex: '^.*/(src|tests)/.*\.(h|hpp)$' WarningsAsErrors: '*' diff --git a/.githooks/check-format b/.githooks/check-format index 5374e8dd..0bc096c5 100755 --- a/.githooks/check-format +++ b/.githooks/check-format @@ -8,7 +8,7 @@ echo "+ Checking code format..." # paths to check and re-format -sources="src unittests" +sources="src tests" formatter="clang-format -i" version=$($formatter --version | grep -o '[0-9\.]*') diff --git a/.github/actions/code_coverage/action.yml b/.github/actions/code_coverage/action.yml index d3c647e2..94dd0fce 100644 --- a/.github/actions/code_coverage/action.yml +++ b/.github/actions/code_coverage/action.yml @@ -6,12 +6,16 @@ runs: - name: Run tests shell: bash run: | - build/clio_tests --backend_host=scylladb + build/clio_tests - name: Run gcovr shell: bash run: | - gcovr -e unittests --xml build/coverage_report.xml -j8 --exclude-throw-branches + gcovr -e tests \ + -e src/data/cassandra \ + -e src/data/CassandraBackend.hpp \ + -e 'src/data/BackendFactory.*' \ + --xml build/coverage_report.xml -j8 --exclude-throw-branches - name: Archive coverage report uses: actions/upload-artifact@v4 diff --git a/.github/actions/generate/action.yml b/.github/actions/generate/action.yml index e5ed866c..1dcfe019 100644 --- a/.github/actions/generate/action.yml +++ b/.github/actions/generate/action.yml @@ -35,7 +35,7 @@ runs: STATIC_OPTION: "${{ inputs.static == 'true' && 'True' || 'False' }}" run: | cd build - conan install .. -of . -b $BUILD_OPTION -s build_type=${{ inputs.build_type }} -o clio:static="${STATIC_OPTION}" -o clio:tests=True -o clio:lint=False -o clio:coverage="${CODE_COVERAGE}" --profile ${{ inputs.conan_profile }} + conan install .. -of . -b $BUILD_OPTION -s build_type=${{ inputs.build_type }} -o clio:static="${STATIC_OPTION}" -o clio:tests=True -o clio:integration_tests=True -o clio:lint=False -o clio:coverage="${CODE_COVERAGE}" --profile ${{ inputs.conan_profile }} - name: Run cmake shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a68ec2d2..0df10927 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -81,15 +81,6 @@ jobs: runs-on: [self-hosted, "${{ matrix.os }}"] container: ${{ matrix.container }} - services: - scylladb: - image: ${{ (matrix.code_coverage) && 'scylladb/scylla' || '' }} - options: >- - --health-cmd "cqlsh -e 'describe cluster'" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - steps: - name: Clean workdir if: ${{ runner.os == 'macOS' }} @@ -143,7 +134,7 @@ jobs: - name: Strip tests if: ${{ !matrix.code_coverage }} - run: strip build/clio_tests + run: strip build/clio_tests && strip build/clio_integration_tests - name: Upload clio_server uses: actions/upload-artifact@v4 @@ -156,7 +147,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: clio_tests_${{ runner.os }}_${{ matrix.build_type }}_${{ steps.conan.outputs.conan_profile }} - path: build/clio_tests + path: build/clio_*tests - name: Save cache uses: ./.github/actions/save_cache @@ -223,4 +214,4 @@ jobs: - name: Run clio_tests run: | chmod +x ./clio_tests - ./clio_tests --gtest_filter="-BackendCassandraBaseTest*:BackendCassandraTest*:BackendCassandraFactoryTestWithDB*" + ./clio_tests diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ccd2d9b7..c1bfa35a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -95,6 +95,15 @@ jobs: runs-on: [self-hosted, "${{ matrix.os }}"] container: ${{ matrix.container }} + services: + scylladb: + image: 'scylladb/scylla' + options: >- + --health-cmd "cqlsh -e 'describe cluster'" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - name: Clean workdir if: ${{ runner.os == 'macOS' }} @@ -107,7 +116,12 @@ jobs: - name: Run clio_tests run: | chmod +x ./clio_tests - ./clio_tests --gtest_filter="-BackendCassandraBaseTest*:BackendCassandraTest*:BackendCassandraFactoryTestWithDB*" + ./clio_tests + + - name: Run clio_integration_tests + run: | + chmod +x ./clio_integration_tests + ./clio_integration_tests --backend_host=scylladb nightly_release: needs: run_tests @@ -129,7 +143,7 @@ jobs: run: | cp ${{ github.workspace }}/.github/workflows/nightly_notes.md "${RUNNER_TEMP}/nightly_notes.md" cd nightly_release - rm -r clio_tests* + rm -r clio_*tests* for d in $(ls); do archive_name=$(ls $d) mv ${d}/${archive_name} ./ diff --git a/CMakeLists.txt b/CMakeLists.txt index d08f5a23..14136cda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,8 @@ project(clio VERSION ${CLIO_VERSION} HOMEPAGE_URL "https://github.com/XRPLF/clio # =========================== Options ====================================== # option(verbose "Verbose build" FALSE) -option(tests "Build tests" FALSE) +option(tests "Build unit tests" FALSE) +option(integration_tests "Build integration tests" FALSE) option(benchmark "Build benchmarks" FALSE) option(docs "Generate doxygen docs" FALSE) option(coverage "Build test coverage report" FALSE) @@ -32,15 +33,6 @@ add_library(clio_options INTERFACE) target_compile_features(clio_options INTERFACE cxx_std_23) # Clio needs c++23 but deps can remain c++20 for now target_include_directories(clio_options INTERFACE ${CMAKE_SOURCE_DIR}/src) -# Set coverage build options -if (coverage) - if (NOT tests) - message(FATAL_ERROR "Coverage requires tests to be enabled") - endif () - include(CodeCoverage) - append_coverage_compiler_flags_to_target(clio_options INTERFACE) -endif () - if (verbose) set(CMAKE_VERBOSE_MAKEFILE TRUE) endif () @@ -65,10 +57,7 @@ include(deps/cassandra) include(deps/libbacktrace) add_subdirectory(src) - -if (tests) - add_subdirectory(unittests) -endif () +add_subdirectory(tests) if (benchmark) add_subdirectory(benchmarks) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7d6820b5..c5f87a67 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ To contribute, please: 2. Create a new branch on which to commit/push your changes. 3. Write and test your code. 4. Ensure that your code compiles with the provided build engine and update the provided build engine as part of your PR where needed and where appropriate. -5. Where applicable, write test cases for your code and include those in `unittests`. +5. Where applicable, write test cases for your code and include those in the relevant subfolder under `tests`. 6. Ensure your code passes automated checks (e.g. clang-format) 7. Squash your commits (i.e. rebase) into as few commits as is reasonable to describe your changes at a high level (typically a single commit for a small change). See below for more details. 8. Open a PR to the main repository onto the _develop_ branch, and follow the provided template. diff --git a/conanfile.py b/conanfile.py index 24e54337..6b9ae04d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,15 +9,16 @@ class Clio(ConanFile): description = 'Clio RPC server' settings = 'os', 'compiler', 'build_type', 'arch' options = { - 'static': [True, False], # static linkage - 'fPIC': [True, False], # unused? + 'static': [True, False], # static linkage + 'fPIC': [True, False], # unused? 'verbose': [True, False], - 'tests': [True, False], # build unit tests; create `clio_tests` binary - 'benchmark': [True, False], # build benchmarks; create `clio_benchmarks` binary - 'docs': [True, False], # doxygen API docs; create custom target 'docs' - 'packaging': [True, False], # create distribution packages - 'coverage': [True, False], # build for test coverage report; create custom target `clio_tests-ccov` - 'lint': [True, False], # run clang-tidy checks during compilation + 'tests': [True, False], # build unit tests; create `clio_tests` binary + 'integration_tests': [True, False], # build integration tests; create `clio_integration_tests` binary + 'benchmark': [True, False], # build benchmarks; create `clio_benchmarks` binary + 'docs': [True, False], # doxygen API docs; create custom target 'docs' + 'packaging': [True, False], # create distribution packages + 'coverage': [True, False], # build for test coverage report; create custom target `clio_tests-ccov` + 'lint': [True, False], # run clang-tidy checks during compilation } requires = [ @@ -36,6 +37,7 @@ class Clio(ConanFile): 'fPIC': True, 'verbose': False, 'tests': False, + 'integration_tests': False, 'benchmark': False, 'packaging': False, 'coverage': False, @@ -62,7 +64,7 @@ class Clio(ConanFile): ) def requirements(self): - if self.options.tests: + if self.options.tests or self.options.integration_tests: self.requires('gtest/1.14.0') if self.options.benchmark: self.requires('benchmark/1.8.3') @@ -83,6 +85,7 @@ class Clio(ConanFile): tc.variables['verbose'] = self.options.verbose tc.variables['static'] = self.options.static tc.variables['tests'] = self.options.tests + tc.variables['integration_tests'] = self.options.integration_tests tc.variables['coverage'] = self.options.coverage tc.variables['lint'] = self.options.lint tc.variables['docs'] = self.options.docs diff --git a/docs/coverage-report.md b/docs/coverage-report.md index 8df749cb..7b8988b7 100644 --- a/docs/coverage-report.md +++ b/docs/coverage-report.md @@ -27,15 +27,6 @@ In case of a spurious failure of unit tests, it is possible to re-run the `cover The default coverage report format is `html-details`, but developers can override it to any of the formats listed in `cmake/CodeCoverage.cmake` by setting `CODE_COVERAGE_REPORT_FORMAT` variable in `cmake`. For example, CI is setting this parameter to `xml` for the [codecov](https://codecov.io) integration. -If some unit tests predictably fail (e.g., due to absence of a Cassandra database), it is possible to set unit tests options in the `CODE_COVERAGE_TESTS_ARGS` cmake variable, as demonstrated below: - -```sh -cd .build -conan install .. --output-folder . --build missing --settings build_type=Debug -o tests=True -o coverage=True -cmake -DCODE_COVERAGE_REPORT_FORMAT=json-details -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE_TESTS_ARGS="--gtest_filter=-BackendCassandra*" -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake .. -cmake --build . --target coverage_report -``` - After the `coverage_report` target is completed, the generated coverage report will be stored inside the build directory as either: - A File named `coverage_report.*`, with a suitable extension for the report format. diff --git a/src/rpc/README.md b/src/rpc/README.md index 80e40b91..bc193a9c 100644 --- a/src/rpc/README.md +++ b/src/rpc/README.md @@ -12,7 +12,7 @@ See the [common](https://github.com/XRPLF/clio/blob/develop/src/rpc/common) subf ## Implementing a handler -See [unittests/rpc](https://github.com/XRPLF/clio/tree/develop/unittests/rpc) for examples. +See [tests/unit/rpc](https://github.com/XRPLF/clio/tree/develop/tests/unit/rpc) for examples. Handlers need to fulfil the requirements specified by the `SomeHandler` concept (see `rpc/common/Concepts.hpp`): diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..9d59469c --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,20 @@ +# Set coverage build options +if (coverage) + if (NOT tests) + message(FATAL_ERROR "Coverage requires tests to be enabled") + endif () + include(CodeCoverage) + append_coverage_compiler_flags_to_target(clio_options INTERFACE) +endif () + +if (tests OR integration_tests) + add_subdirectory(common) +endif () + +if (tests) + add_subdirectory(unit) +endif () + +if (integration_tests) + add_subdirectory(integration) +endif () diff --git a/tests/common/CMakeLists.txt b/tests/common/CMakeLists.txt new file mode 100644 index 00000000..2493fbaf --- /dev/null +++ b/tests/common/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(clio_testing_common) + +target_sources( + clio_testing_common PRIVATE util/StringUtils.cpp util/TestHttpServer.cpp util/TestWsServer.cpp util/TestObject.cpp +) + +include(deps/gtest) + +target_include_directories(clio_testing_common PUBLIC .) +target_link_libraries(clio_testing_common PUBLIC clio gtest::gtest) diff --git a/unittests/data/cassandra/impl/FakesAndMocks.hpp b/tests/common/data/cassandra/FakesAndMocks.hpp similarity index 100% rename from unittests/data/cassandra/impl/FakesAndMocks.hpp rename to tests/common/data/cassandra/FakesAndMocks.hpp diff --git a/unittests/etl/impl/FakeDiffProvider.hpp b/tests/common/etl/FakeDiffProvider.hpp similarity index 100% rename from unittests/etl/impl/FakeDiffProvider.hpp rename to tests/common/etl/FakeDiffProvider.hpp diff --git a/unittests/feed/FeedTestUtil.hpp b/tests/common/feed/FeedTestUtil.hpp similarity index 100% rename from unittests/feed/FeedTestUtil.hpp rename to tests/common/feed/FeedTestUtil.hpp diff --git a/unittests/rpc/handlers/impl/FakesAndMocks.hpp b/tests/common/rpc/FakesAndMocks.hpp similarity index 98% rename from unittests/rpc/handlers/impl/FakesAndMocks.hpp rename to tests/common/rpc/FakesAndMocks.hpp index fbe4b2bc..b2504279 100644 --- a/unittests/rpc/handlers/impl/FakesAndMocks.hpp +++ b/tests/common/rpc/FakesAndMocks.hpp @@ -35,7 +35,7 @@ #include #include -namespace unittests::impl { +namespace tests::common { // input data for the test handlers below struct TestInput { @@ -181,4 +181,4 @@ struct BasicDOSGuardMock : public web::BaseDOSGuard { MOCK_METHOD(void, clear, (), (noexcept, override)); }; -} // namespace unittests::impl +} // namespace tests::common diff --git a/unittests/util/FakeAmendmentBlockAction.hpp b/tests/common/util/FakeAmendmentBlockAction.hpp similarity index 100% rename from unittests/util/FakeAmendmentBlockAction.hpp rename to tests/common/util/FakeAmendmentBlockAction.hpp diff --git a/unittests/util/FakeFetchResponse.hpp b/tests/common/util/FakeFetchResponse.hpp similarity index 100% rename from unittests/util/FakeFetchResponse.hpp rename to tests/common/util/FakeFetchResponse.hpp diff --git a/unittests/util/Fixtures.hpp b/tests/common/util/Fixtures.hpp similarity index 100% rename from unittests/util/Fixtures.hpp rename to tests/common/util/Fixtures.hpp diff --git a/unittests/util/MockAmendmentBlockHandler.hpp b/tests/common/util/MockAmendmentBlockHandler.hpp similarity index 100% rename from unittests/util/MockAmendmentBlockHandler.hpp rename to tests/common/util/MockAmendmentBlockHandler.hpp diff --git a/unittests/util/MockBackend.hpp b/tests/common/util/MockBackend.hpp similarity index 100% rename from unittests/util/MockBackend.hpp rename to tests/common/util/MockBackend.hpp diff --git a/unittests/util/MockCache.hpp b/tests/common/util/MockCache.hpp similarity index 100% rename from unittests/util/MockCache.hpp rename to tests/common/util/MockCache.hpp diff --git a/unittests/util/MockCounters.hpp b/tests/common/util/MockCounters.hpp similarity index 100% rename from unittests/util/MockCounters.hpp rename to tests/common/util/MockCounters.hpp diff --git a/unittests/util/MockETLService.hpp b/tests/common/util/MockETLService.hpp similarity index 100% rename from unittests/util/MockETLService.hpp rename to tests/common/util/MockETLService.hpp diff --git a/unittests/util/MockExecutionContext.hpp b/tests/common/util/MockExecutionContext.hpp similarity index 100% rename from unittests/util/MockExecutionContext.hpp rename to tests/common/util/MockExecutionContext.hpp diff --git a/unittests/util/MockExtractionDataPipe.hpp b/tests/common/util/MockExtractionDataPipe.hpp similarity index 100% rename from unittests/util/MockExtractionDataPipe.hpp rename to tests/common/util/MockExtractionDataPipe.hpp diff --git a/unittests/util/MockHandlerProvider.hpp b/tests/common/util/MockHandlerProvider.hpp similarity index 100% rename from unittests/util/MockHandlerProvider.hpp rename to tests/common/util/MockHandlerProvider.hpp diff --git a/unittests/util/MockLedgerFetcher.hpp b/tests/common/util/MockLedgerFetcher.hpp similarity index 100% rename from unittests/util/MockLedgerFetcher.hpp rename to tests/common/util/MockLedgerFetcher.hpp diff --git a/unittests/util/MockLedgerLoader.hpp b/tests/common/util/MockLedgerLoader.hpp similarity index 100% rename from unittests/util/MockLedgerLoader.hpp rename to tests/common/util/MockLedgerLoader.hpp diff --git a/unittests/util/MockLedgerPublisher.hpp b/tests/common/util/MockLedgerPublisher.hpp similarity index 100% rename from unittests/util/MockLedgerPublisher.hpp rename to tests/common/util/MockLedgerPublisher.hpp diff --git a/unittests/util/MockLoadBalancer.hpp b/tests/common/util/MockLoadBalancer.hpp similarity index 100% rename from unittests/util/MockLoadBalancer.hpp rename to tests/common/util/MockLoadBalancer.hpp diff --git a/unittests/util/MockNetworkValidatedLedgers.hpp b/tests/common/util/MockNetworkValidatedLedgers.hpp similarity index 100% rename from unittests/util/MockNetworkValidatedLedgers.hpp rename to tests/common/util/MockNetworkValidatedLedgers.hpp diff --git a/unittests/util/MockOperation.hpp b/tests/common/util/MockOperation.hpp similarity index 100% rename from unittests/util/MockOperation.hpp rename to tests/common/util/MockOperation.hpp diff --git a/unittests/util/MockPrometheus.hpp b/tests/common/util/MockPrometheus.hpp similarity index 100% rename from unittests/util/MockPrometheus.hpp rename to tests/common/util/MockPrometheus.hpp diff --git a/unittests/util/MockRPCEngine.hpp b/tests/common/util/MockRPCEngine.hpp similarity index 100% rename from unittests/util/MockRPCEngine.hpp rename to tests/common/util/MockRPCEngine.hpp diff --git a/unittests/util/MockSource.hpp b/tests/common/util/MockSource.hpp similarity index 100% rename from unittests/util/MockSource.hpp rename to tests/common/util/MockSource.hpp diff --git a/unittests/util/MockStopToken.hpp b/tests/common/util/MockStopToken.hpp similarity index 100% rename from unittests/util/MockStopToken.hpp rename to tests/common/util/MockStopToken.hpp diff --git a/unittests/util/MockStrand.hpp b/tests/common/util/MockStrand.hpp similarity index 100% rename from unittests/util/MockStrand.hpp rename to tests/common/util/MockStrand.hpp diff --git a/unittests/util/MockSubscriptionManager.hpp b/tests/common/util/MockSubscriptionManager.hpp similarity index 100% rename from unittests/util/MockSubscriptionManager.hpp rename to tests/common/util/MockSubscriptionManager.hpp diff --git a/unittests/util/MockWsBase.hpp b/tests/common/util/MockWsBase.hpp similarity index 100% rename from unittests/util/MockWsBase.hpp rename to tests/common/util/MockWsBase.hpp diff --git a/unittests/util/MockXrpLedgerAPIService.hpp b/tests/common/util/MockXrpLedgerAPIService.hpp similarity index 98% rename from unittests/util/MockXrpLedgerAPIService.hpp rename to tests/common/util/MockXrpLedgerAPIService.hpp index 6b7c75a3..2fd07a50 100644 --- a/unittests/util/MockXrpLedgerAPIService.hpp +++ b/tests/common/util/MockXrpLedgerAPIService.hpp @@ -36,7 +36,7 @@ #include #include -namespace unittests::util { +namespace tests::util { struct MockXrpLedgerAPIService final : public org::xrpl::rpc::v1::XRPLedgerAPIService::Service { ~MockXrpLedgerAPIService() override = default; @@ -101,4 +101,4 @@ private: std::thread serverThread_; }; -} // namespace unittests::util +} // namespace tests::util diff --git a/unittests/util/StringUtils.cpp b/tests/common/util/StringUtils.cpp similarity index 100% rename from unittests/util/StringUtils.cpp rename to tests/common/util/StringUtils.cpp diff --git a/unittests/util/StringUtils.hpp b/tests/common/util/StringUtils.hpp similarity index 100% rename from unittests/util/StringUtils.hpp rename to tests/common/util/StringUtils.hpp diff --git a/unittests/util/TestHttpServer.cpp b/tests/common/util/TestHttpServer.cpp similarity index 100% rename from unittests/util/TestHttpServer.cpp rename to tests/common/util/TestHttpServer.cpp diff --git a/unittests/util/TestHttpServer.hpp b/tests/common/util/TestHttpServer.hpp similarity index 100% rename from unittests/util/TestHttpServer.hpp rename to tests/common/util/TestHttpServer.hpp diff --git a/unittests/util/TestHttpSyncClient.hpp b/tests/common/util/TestHttpSyncClient.hpp similarity index 100% rename from unittests/util/TestHttpSyncClient.hpp rename to tests/common/util/TestHttpSyncClient.hpp diff --git a/unittests/util/TestObject.cpp b/tests/common/util/TestObject.cpp similarity index 100% rename from unittests/util/TestObject.cpp rename to tests/common/util/TestObject.cpp diff --git a/unittests/util/TestObject.hpp b/tests/common/util/TestObject.hpp similarity index 100% rename from unittests/util/TestObject.hpp rename to tests/common/util/TestObject.hpp diff --git a/unittests/util/TestWsServer.cpp b/tests/common/util/TestWsServer.cpp similarity index 100% rename from unittests/util/TestWsServer.cpp rename to tests/common/util/TestWsServer.cpp diff --git a/unittests/util/TestWsServer.hpp b/tests/common/util/TestWsServer.hpp similarity index 100% rename from unittests/util/TestWsServer.hpp rename to tests/common/util/TestWsServer.hpp diff --git a/unittests/util/TmpFile.hpp b/tests/common/util/TmpFile.hpp similarity index 100% rename from unittests/util/TmpFile.hpp rename to tests/common/util/TmpFile.hpp diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt new file mode 100644 index 00000000..6c7e8683 --- /dev/null +++ b/tests/integration/CMakeLists.txt @@ -0,0 +1,15 @@ +add_executable(clio_integration_tests) + +target_sources( + clio_integration_tests + PRIVATE data/BackendFactoryTests.cpp data/cassandra/BackendTests.cpp data/cassandra/BaseTests.cpp + # Test runner + TestGlobals.cpp Main.cpp +) + +# Fix for dwarf5 bug on ci. IS STILL NEEDED??? +target_compile_options(clio_options INTERFACE -gdwarf-4) + +target_include_directories(clio_integration_tests PRIVATE .) +target_link_libraries(clio_integration_tests PUBLIC clio_testing_common) +set_target_properties(clio_integration_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/unittests/Main.cpp b/tests/integration/Main.cpp similarity index 95% rename from unittests/Main.cpp rename to tests/integration/Main.cpp index a99ca734..c6d49d55 100644 --- a/unittests/Main.cpp +++ b/tests/integration/Main.cpp @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ /* This file is part of clio: https://github.com/XRPLF/clio - Copyright (c) 2023, the clio developers. + Copyright (c) 2024, the clio developers. Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -18,8 +18,8 @@ //============================================================================== #include "util/TerminationHandler.hpp" -#include "util/TestGlobals.hpp" +#include #include /* diff --git a/tests/integration/README.md b/tests/integration/README.md new file mode 100644 index 00000000..bf969e1d --- /dev/null +++ b/tests/integration/README.md @@ -0,0 +1,10 @@ +# Integration testing + +Tests that hit the real database are separate from the unit test suite found under `tests/unit`. + +## Requirements +### Cassandra/ScyllaDB cluster +If you wish to test the backend component you will need to have access to a **local (127.0.0.1)** Cassandra cluster, opened at port **9042**. Please ensure that the cluster is successfully running before running these tests. + +## Running +To run the DB tests, first build Clio as normal, then execute `./clio_integration_tests` to run all database tests. diff --git a/unittests/util/TestGlobals.cpp b/tests/integration/TestGlobals.cpp similarity index 98% rename from unittests/util/TestGlobals.cpp rename to tests/integration/TestGlobals.cpp index e892923c..7cd5ac28 100644 --- a/unittests/util/TestGlobals.cpp +++ b/tests/integration/TestGlobals.cpp @@ -17,8 +17,7 @@ */ //============================================================================== -#include "util/TestGlobals.hpp" - +#include #include #include #include diff --git a/unittests/util/TestGlobals.hpp b/tests/integration/TestGlobals.hpp similarity index 100% rename from unittests/util/TestGlobals.hpp rename to tests/integration/TestGlobals.hpp diff --git a/unittests/data/BackendFactoryTests.cpp b/tests/integration/data/BackendFactoryTests.cpp similarity index 97% rename from unittests/data/BackendFactoryTests.cpp rename to tests/integration/data/BackendFactoryTests.cpp index f217d4a5..51914266 100644 --- a/unittests/data/BackendFactoryTests.cpp +++ b/tests/integration/data/BackendFactoryTests.cpp @@ -20,9 +20,10 @@ #include "data/BackendFactory.hpp" #include "data/cassandra/Handle.hpp" #include "util/Fixtures.hpp" -#include "util/TestGlobals.hpp" +#include "util/MockPrometheus.hpp" #include "util/config/Config.hpp" +#include #include #include #include @@ -34,7 +35,7 @@ namespace { constexpr auto keyspace = "factory_test"; } // namespace -class BackendCassandraFactoryTest : public SyncAsioContextTest { +class BackendCassandraFactoryTest : public SyncAsioContextTest, public util::prometheus::WithPrometheus { protected: void SetUp() override diff --git a/unittests/data/cassandra/BackendTests.cpp b/tests/integration/data/cassandra/BackendTests.cpp similarity index 99% rename from unittests/data/cassandra/BackendTests.cpp rename to tests/integration/data/cassandra/BackendTests.cpp index 292d3e00..2e20d03c 100644 --- a/unittests/data/cassandra/BackendTests.cpp +++ b/tests/integration/data/cassandra/BackendTests.cpp @@ -30,9 +30,9 @@ #include "util/MockPrometheus.hpp" #include "util/Random.hpp" #include "util/StringUtils.hpp" -#include "util/TestGlobals.hpp" #include "util/config/Config.hpp" +#include #include #include #include diff --git a/unittests/data/cassandra/BaseTests.cpp b/tests/integration/data/cassandra/BaseTests.cpp similarity index 99% rename from unittests/data/cassandra/BaseTests.cpp rename to tests/integration/data/cassandra/BaseTests.cpp index 049536bc..4b1990ee 100644 --- a/unittests/data/cassandra/BaseTests.cpp +++ b/tests/integration/data/cassandra/BaseTests.cpp @@ -20,8 +20,8 @@ #include "data/cassandra/Handle.hpp" #include "data/cassandra/Types.hpp" #include "util/Fixtures.hpp" -#include "util/TestGlobals.hpp" +#include #include #include #include diff --git a/unittests/CMakeLists.txt b/tests/unit/CMakeLists.txt similarity index 94% rename from unittests/CMakeLists.txt rename to tests/unit/CMakeLists.txt index 19ca3ef1..5afafa01 100644 --- a/unittests/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -5,11 +5,8 @@ target_sources( PRIVATE # Common ConfigTests.cpp data/BackendCountersTests.cpp - data/BackendFactoryTests.cpp data/BackendInterfaceTests.cpp data/cassandra/AsyncExecutorTests.cpp - data/cassandra/BackendTests.cpp - data/cassandra/BaseTests.cpp data/cassandra/ExecutionStrategyTests.cpp data/cassandra/RetryPolicyTests.cpp data/cassandra/SettingsProviderTests.cpp @@ -119,11 +116,6 @@ target_sources( util/requests/WsConnectionTests.cpp util/RetryTests.cpp util/SignalsHandlerTests.cpp - util/StringUtils.cpp - util/TestGlobals.cpp - util/TestHttpServer.cpp - util/TestObject.cpp - util/TestWsServer.cpp util/TxUtilTests.cpp # Webserver web/AdminVerificationTests.cpp @@ -133,8 +125,6 @@ target_sources( web/WhitelistHandlerTests.cpp ) -include(deps/gtest) - # See https://github.com/google/googletest/issues/3475 gtest_discover_tests(clio_tests DISCOVERY_TIMEOUT 90) @@ -143,7 +133,7 @@ target_compile_options(clio_options INTERFACE -gdwarf-4) target_compile_definitions(clio_tests PUBLIC UNITTEST_BUILD) target_include_directories(clio_tests PRIVATE .) -target_link_libraries(clio_tests PUBLIC clio gtest::gtest) +target_link_libraries(clio_tests PUBLIC clio_testing_common) set_target_properties(clio_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) # Generate `coverage_report` target if coverage is enabled @@ -174,7 +164,10 @@ if (coverage) --gtest_brief=1 ${TESTS_ADDITIONAL_ARGS} EXCLUDE - "unittests" + "tests" + "src/data/cassandra" + "src/data/CassandraBackend.hpp" + "src/data/BackendFactory.*" DEPENDENCIES clio_tests ) diff --git a/unittests/ConfigTests.cpp b/tests/unit/ConfigTests.cpp similarity index 100% rename from unittests/ConfigTests.cpp rename to tests/unit/ConfigTests.cpp diff --git a/unittests/DOSGuardTests.cpp b/tests/unit/DOSGuardTests.cpp similarity index 100% rename from unittests/DOSGuardTests.cpp rename to tests/unit/DOSGuardTests.cpp diff --git a/unittests/JsonUtilTests.cpp b/tests/unit/JsonUtilTests.cpp similarity index 100% rename from unittests/JsonUtilTests.cpp rename to tests/unit/JsonUtilTests.cpp diff --git a/unittests/LoggerTests.cpp b/tests/unit/LoggerTests.cpp similarity index 100% rename from unittests/LoggerTests.cpp rename to tests/unit/LoggerTests.cpp diff --git a/tests/unit/Main.cpp b/tests/unit/Main.cpp new file mode 100644 index 00000000..1359dbae --- /dev/null +++ b/tests/unit/Main.cpp @@ -0,0 +1,31 @@ +//------------------------------------------------------------------------------ +/* + This file is part of clio: https://github.com/XRPLF/clio + Copyright (c) 2023, the clio developers. + + Permission to use, copy, modify, and distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#include "util/TerminationHandler.hpp" + +#include + +int +main(int argc, char* argv[]) +{ + util::setTerminationHandler(); + testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} diff --git a/unittests/Playground.cpp b/tests/unit/Playground.cpp similarity index 100% rename from unittests/Playground.cpp rename to tests/unit/Playground.cpp diff --git a/unittests/ProfilerTests.cpp b/tests/unit/ProfilerTests.cpp similarity index 100% rename from unittests/ProfilerTests.cpp rename to tests/unit/ProfilerTests.cpp diff --git a/tests/unit/README.md b/tests/unit/README.md new file mode 100644 index 00000000..ed4bd973 --- /dev/null +++ b/tests/unit/README.md @@ -0,0 +1,9 @@ +# Unit testing + +The correctness of new implementations can be verified via running unit tests. Below are the information on how to run unit tests. + +## Running +To run the unit tests, first build Clio as normal, then execute `./clio_tests` to run all unit tests. + +# Adding Unit Tests +To add unit tests, please create a separate file for the component you are trying to cover (unless it already exists) and use any other existing unit test file as an example. diff --git a/unittests/data/BackendCountersTests.cpp b/tests/unit/data/BackendCountersTests.cpp similarity index 100% rename from unittests/data/BackendCountersTests.cpp rename to tests/unit/data/BackendCountersTests.cpp diff --git a/unittests/data/BackendInterfaceTests.cpp b/tests/unit/data/BackendInterfaceTests.cpp similarity index 100% rename from unittests/data/BackendInterfaceTests.cpp rename to tests/unit/data/BackendInterfaceTests.cpp diff --git a/unittests/data/cassandra/AsyncExecutorTests.cpp b/tests/unit/data/cassandra/AsyncExecutorTests.cpp similarity index 99% rename from unittests/data/cassandra/AsyncExecutorTests.cpp rename to tests/unit/data/cassandra/AsyncExecutorTests.cpp index 83998aef..dfbd1f21 100644 --- a/unittests/data/cassandra/AsyncExecutorTests.cpp +++ b/tests/unit/data/cassandra/AsyncExecutorTests.cpp @@ -18,8 +18,8 @@ //============================================================================== #include "data/cassandra/Error.hpp" +#include "data/cassandra/FakesAndMocks.hpp" #include "data/cassandra/impl/AsyncExecutor.hpp" -#include "data/cassandra/impl/FakesAndMocks.hpp" #include "util/Fixtures.hpp" #include diff --git a/unittests/data/cassandra/ExecutionStrategyTests.cpp b/tests/unit/data/cassandra/ExecutionStrategyTests.cpp similarity index 99% rename from unittests/data/cassandra/ExecutionStrategyTests.cpp rename to tests/unit/data/cassandra/ExecutionStrategyTests.cpp index d4880305..18e7bc6b 100644 --- a/unittests/data/cassandra/ExecutionStrategyTests.cpp +++ b/tests/unit/data/cassandra/ExecutionStrategyTests.cpp @@ -18,10 +18,9 @@ //============================================================================== #include "data/BackendInterface.hpp" -#include "data/cassandra/Error.hpp" +#include "data/cassandra/FakesAndMocks.hpp" #include "data/cassandra/Types.hpp" #include "data/cassandra/impl/ExecutionStrategy.hpp" -#include "data/cassandra/impl/FakesAndMocks.hpp" #include "util/Fixtures.hpp" #include diff --git a/unittests/data/cassandra/RetryPolicyTests.cpp b/tests/unit/data/cassandra/RetryPolicyTests.cpp similarity index 100% rename from unittests/data/cassandra/RetryPolicyTests.cpp rename to tests/unit/data/cassandra/RetryPolicyTests.cpp diff --git a/unittests/data/cassandra/SettingsProviderTests.cpp b/tests/unit/data/cassandra/SettingsProviderTests.cpp similarity index 100% rename from unittests/data/cassandra/SettingsProviderTests.cpp rename to tests/unit/data/cassandra/SettingsProviderTests.cpp diff --git a/unittests/etl/AmendmentBlockHandlerTests.cpp b/tests/unit/etl/AmendmentBlockHandlerTests.cpp similarity index 100% rename from unittests/etl/AmendmentBlockHandlerTests.cpp rename to tests/unit/etl/AmendmentBlockHandlerTests.cpp diff --git a/unittests/etl/CacheLoaderSettingsTests.cpp b/tests/unit/etl/CacheLoaderSettingsTests.cpp similarity index 100% rename from unittests/etl/CacheLoaderSettingsTests.cpp rename to tests/unit/etl/CacheLoaderSettingsTests.cpp diff --git a/unittests/etl/CacheLoaderTests.cpp b/tests/unit/etl/CacheLoaderTests.cpp similarity index 99% rename from unittests/etl/CacheLoaderTests.cpp rename to tests/unit/etl/CacheLoaderTests.cpp index 82e1138d..f8910f1d 100644 --- a/unittests/etl/CacheLoaderTests.cpp +++ b/tests/unit/etl/CacheLoaderTests.cpp @@ -20,8 +20,8 @@ #include "data/Types.hpp" #include "etl/CacheLoader.hpp" #include "etl/CacheLoaderSettings.hpp" +#include "etl/FakeDiffProvider.hpp" #include "etl/impl/CacheLoader.hpp" -#include "etl/impl/FakeDiffProvider.hpp" #include "util/Fixtures.hpp" #include "util/MockCache.hpp" #include "util/MockPrometheus.hpp" diff --git a/unittests/etl/CorruptionDetectorTests.cpp b/tests/unit/etl/CorruptionDetectorTests.cpp similarity index 100% rename from unittests/etl/CorruptionDetectorTests.cpp rename to tests/unit/etl/CorruptionDetectorTests.cpp diff --git a/unittests/etl/CursorFromAccountProviderTests.cpp b/tests/unit/etl/CursorFromAccountProviderTests.cpp similarity index 100% rename from unittests/etl/CursorFromAccountProviderTests.cpp rename to tests/unit/etl/CursorFromAccountProviderTests.cpp diff --git a/unittests/etl/CursorFromDiffProviderTests.cpp b/tests/unit/etl/CursorFromDiffProviderTests.cpp similarity index 100% rename from unittests/etl/CursorFromDiffProviderTests.cpp rename to tests/unit/etl/CursorFromDiffProviderTests.cpp diff --git a/unittests/etl/CursorFromFixDiffNumProviderTests.cpp b/tests/unit/etl/CursorFromFixDiffNumProviderTests.cpp similarity index 98% rename from unittests/etl/CursorFromFixDiffNumProviderTests.cpp rename to tests/unit/etl/CursorFromFixDiffNumProviderTests.cpp index 6dfa6e68..c1b75daa 100644 --- a/unittests/etl/CursorFromFixDiffNumProviderTests.cpp +++ b/tests/unit/etl/CursorFromFixDiffNumProviderTests.cpp @@ -18,8 +18,8 @@ //============================================================================== #include "data/Types.hpp" +#include "etl/FakeDiffProvider.hpp" #include "etl/impl/CursorFromFixDiffNumProvider.hpp" -#include "etl/impl/FakeDiffProvider.hpp" #include "util/Fixtures.hpp" #include "util/MockPrometheus.hpp" diff --git a/unittests/etl/ETLStateTests.cpp b/tests/unit/etl/ETLStateTests.cpp similarity index 100% rename from unittests/etl/ETLStateTests.cpp rename to tests/unit/etl/ETLStateTests.cpp diff --git a/unittests/etl/ExtractionDataPipeTests.cpp b/tests/unit/etl/ExtractionDataPipeTests.cpp similarity index 100% rename from unittests/etl/ExtractionDataPipeTests.cpp rename to tests/unit/etl/ExtractionDataPipeTests.cpp diff --git a/unittests/etl/ExtractorTests.cpp b/tests/unit/etl/ExtractorTests.cpp similarity index 100% rename from unittests/etl/ExtractorTests.cpp rename to tests/unit/etl/ExtractorTests.cpp diff --git a/unittests/etl/ForwardingCacheTests.cpp b/tests/unit/etl/ForwardingCacheTests.cpp similarity index 100% rename from unittests/etl/ForwardingCacheTests.cpp rename to tests/unit/etl/ForwardingCacheTests.cpp diff --git a/unittests/etl/ForwardingSourceTests.cpp b/tests/unit/etl/ForwardingSourceTests.cpp similarity index 100% rename from unittests/etl/ForwardingSourceTests.cpp rename to tests/unit/etl/ForwardingSourceTests.cpp diff --git a/unittests/etl/GrpcSourceTests.cpp b/tests/unit/etl/GrpcSourceTests.cpp similarity index 97% rename from unittests/etl/GrpcSourceTests.cpp rename to tests/unit/etl/GrpcSourceTests.cpp index f2e3c3dd..55f9de78 100644 --- a/unittests/etl/GrpcSourceTests.cpp +++ b/tests/unit/etl/GrpcSourceTests.cpp @@ -40,9 +40,7 @@ using namespace etl::impl; -struct GrpcSourceTests : NoLoggerFixture, - util::prometheus::WithPrometheus, - unittests::util::WithMockXrpLedgerAPIService { +struct GrpcSourceTests : NoLoggerFixture, util::prometheus::WithPrometheus, tests::util::WithMockXrpLedgerAPIService { GrpcSourceTests() : WithMockXrpLedgerAPIService("localhost:55051") , mockBackend_(std::make_shared>(util::Config{})) diff --git a/unittests/etl/LedgerPublisherTests.cpp b/tests/unit/etl/LedgerPublisherTests.cpp similarity index 100% rename from unittests/etl/LedgerPublisherTests.cpp rename to tests/unit/etl/LedgerPublisherTests.cpp diff --git a/unittests/etl/SourceTests.cpp b/tests/unit/etl/SourceTests.cpp similarity index 100% rename from unittests/etl/SourceTests.cpp rename to tests/unit/etl/SourceTests.cpp diff --git a/unittests/etl/SubscriptionSourceDependenciesTests.cpp b/tests/unit/etl/SubscriptionSourceDependenciesTests.cpp similarity index 100% rename from unittests/etl/SubscriptionSourceDependenciesTests.cpp rename to tests/unit/etl/SubscriptionSourceDependenciesTests.cpp diff --git a/unittests/etl/SubscriptionSourceTests.cpp b/tests/unit/etl/SubscriptionSourceTests.cpp similarity index 100% rename from unittests/etl/SubscriptionSourceTests.cpp rename to tests/unit/etl/SubscriptionSourceTests.cpp diff --git a/unittests/etl/TransformerTests.cpp b/tests/unit/etl/TransformerTests.cpp similarity index 100% rename from unittests/etl/TransformerTests.cpp rename to tests/unit/etl/TransformerTests.cpp diff --git a/unittests/feed/BookChangesFeedTests.cpp b/tests/unit/feed/BookChangesFeedTests.cpp similarity index 100% rename from unittests/feed/BookChangesFeedTests.cpp rename to tests/unit/feed/BookChangesFeedTests.cpp diff --git a/unittests/feed/ForwardFeedTests.cpp b/tests/unit/feed/ForwardFeedTests.cpp similarity index 100% rename from unittests/feed/ForwardFeedTests.cpp rename to tests/unit/feed/ForwardFeedTests.cpp diff --git a/unittests/feed/LedgerFeedTests.cpp b/tests/unit/feed/LedgerFeedTests.cpp similarity index 100% rename from unittests/feed/LedgerFeedTests.cpp rename to tests/unit/feed/LedgerFeedTests.cpp diff --git a/unittests/feed/ProposedTransactionFeedTests.cpp b/tests/unit/feed/ProposedTransactionFeedTests.cpp similarity index 100% rename from unittests/feed/ProposedTransactionFeedTests.cpp rename to tests/unit/feed/ProposedTransactionFeedTests.cpp diff --git a/unittests/feed/SingleFeedBaseTests.cpp b/tests/unit/feed/SingleFeedBaseTests.cpp similarity index 100% rename from unittests/feed/SingleFeedBaseTests.cpp rename to tests/unit/feed/SingleFeedBaseTests.cpp diff --git a/unittests/feed/SubscriptionManagerTests.cpp b/tests/unit/feed/SubscriptionManagerTests.cpp similarity index 100% rename from unittests/feed/SubscriptionManagerTests.cpp rename to tests/unit/feed/SubscriptionManagerTests.cpp diff --git a/unittests/feed/TrackableSignalTests.cpp b/tests/unit/feed/TrackableSignalTests.cpp similarity index 100% rename from unittests/feed/TrackableSignalTests.cpp rename to tests/unit/feed/TrackableSignalTests.cpp diff --git a/unittests/feed/TransactionFeedTests.cpp b/tests/unit/feed/TransactionFeedTests.cpp similarity index 100% rename from unittests/feed/TransactionFeedTests.cpp rename to tests/unit/feed/TransactionFeedTests.cpp diff --git a/unittests/rpc/APIVersionTests.cpp b/tests/unit/rpc/APIVersionTests.cpp similarity index 100% rename from unittests/rpc/APIVersionTests.cpp rename to tests/unit/rpc/APIVersionTests.cpp diff --git a/unittests/rpc/AmendmentsTests.cpp b/tests/unit/rpc/AmendmentsTests.cpp similarity index 100% rename from unittests/rpc/AmendmentsTests.cpp rename to tests/unit/rpc/AmendmentsTests.cpp diff --git a/unittests/rpc/BaseTests.cpp b/tests/unit/rpc/BaseTests.cpp similarity index 100% rename from unittests/rpc/BaseTests.cpp rename to tests/unit/rpc/BaseTests.cpp diff --git a/unittests/rpc/CountersTests.cpp b/tests/unit/rpc/CountersTests.cpp similarity index 100% rename from unittests/rpc/CountersTests.cpp rename to tests/unit/rpc/CountersTests.cpp diff --git a/unittests/rpc/ErrorTests.cpp b/tests/unit/rpc/ErrorTests.cpp similarity index 100% rename from unittests/rpc/ErrorTests.cpp rename to tests/unit/rpc/ErrorTests.cpp diff --git a/unittests/rpc/ForwardingProxyTests.cpp b/tests/unit/rpc/ForwardingProxyTests.cpp similarity index 100% rename from unittests/rpc/ForwardingProxyTests.cpp rename to tests/unit/rpc/ForwardingProxyTests.cpp diff --git a/unittests/rpc/JsonBoolTests.cpp b/tests/unit/rpc/JsonBoolTests.cpp similarity index 100% rename from unittests/rpc/JsonBoolTests.cpp rename to tests/unit/rpc/JsonBoolTests.cpp diff --git a/unittests/rpc/RPCHelpersTests.cpp b/tests/unit/rpc/RPCHelpersTests.cpp similarity index 100% rename from unittests/rpc/RPCHelpersTests.cpp rename to tests/unit/rpc/RPCHelpersTests.cpp diff --git a/unittests/rpc/WorkQueueTests.cpp b/tests/unit/rpc/WorkQueueTests.cpp similarity index 100% rename from unittests/rpc/WorkQueueTests.cpp rename to tests/unit/rpc/WorkQueueTests.cpp diff --git a/unittests/rpc/common/CheckersTests.cpp b/tests/unit/rpc/common/CheckersTests.cpp similarity index 100% rename from unittests/rpc/common/CheckersTests.cpp rename to tests/unit/rpc/common/CheckersTests.cpp diff --git a/unittests/rpc/common/SpecsTests.cpp b/tests/unit/rpc/common/SpecsTests.cpp similarity index 100% rename from unittests/rpc/common/SpecsTests.cpp rename to tests/unit/rpc/common/SpecsTests.cpp diff --git a/unittests/rpc/common/TypesTests.cpp b/tests/unit/rpc/common/TypesTests.cpp similarity index 100% rename from unittests/rpc/common/TypesTests.cpp rename to tests/unit/rpc/common/TypesTests.cpp diff --git a/unittests/rpc/handlers/AMMInfoTests.cpp b/tests/unit/rpc/handlers/AMMInfoTests.cpp similarity index 100% rename from unittests/rpc/handlers/AMMInfoTests.cpp rename to tests/unit/rpc/handlers/AMMInfoTests.cpp diff --git a/unittests/rpc/handlers/AccountChannelsTests.cpp b/tests/unit/rpc/handlers/AccountChannelsTests.cpp similarity index 100% rename from unittests/rpc/handlers/AccountChannelsTests.cpp rename to tests/unit/rpc/handlers/AccountChannelsTests.cpp diff --git a/unittests/rpc/handlers/AccountCurrenciesTests.cpp b/tests/unit/rpc/handlers/AccountCurrenciesTests.cpp similarity index 100% rename from unittests/rpc/handlers/AccountCurrenciesTests.cpp rename to tests/unit/rpc/handlers/AccountCurrenciesTests.cpp diff --git a/unittests/rpc/handlers/AccountInfoTests.cpp b/tests/unit/rpc/handlers/AccountInfoTests.cpp similarity index 100% rename from unittests/rpc/handlers/AccountInfoTests.cpp rename to tests/unit/rpc/handlers/AccountInfoTests.cpp diff --git a/unittests/rpc/handlers/AccountLinesTests.cpp b/tests/unit/rpc/handlers/AccountLinesTests.cpp similarity index 100% rename from unittests/rpc/handlers/AccountLinesTests.cpp rename to tests/unit/rpc/handlers/AccountLinesTests.cpp diff --git a/unittests/rpc/handlers/AccountNFTsTests.cpp b/tests/unit/rpc/handlers/AccountNFTsTests.cpp similarity index 100% rename from unittests/rpc/handlers/AccountNFTsTests.cpp rename to tests/unit/rpc/handlers/AccountNFTsTests.cpp diff --git a/unittests/rpc/handlers/AccountObjectsTests.cpp b/tests/unit/rpc/handlers/AccountObjectsTests.cpp similarity index 100% rename from unittests/rpc/handlers/AccountObjectsTests.cpp rename to tests/unit/rpc/handlers/AccountObjectsTests.cpp diff --git a/unittests/rpc/handlers/AccountOffersTests.cpp b/tests/unit/rpc/handlers/AccountOffersTests.cpp similarity index 100% rename from unittests/rpc/handlers/AccountOffersTests.cpp rename to tests/unit/rpc/handlers/AccountOffersTests.cpp diff --git a/unittests/rpc/handlers/AccountTxTests.cpp b/tests/unit/rpc/handlers/AccountTxTests.cpp similarity index 100% rename from unittests/rpc/handlers/AccountTxTests.cpp rename to tests/unit/rpc/handlers/AccountTxTests.cpp diff --git a/unittests/rpc/handlers/BookChangesTests.cpp b/tests/unit/rpc/handlers/BookChangesTests.cpp similarity index 100% rename from unittests/rpc/handlers/BookChangesTests.cpp rename to tests/unit/rpc/handlers/BookChangesTests.cpp diff --git a/unittests/rpc/handlers/BookOffersTests.cpp b/tests/unit/rpc/handlers/BookOffersTests.cpp similarity index 100% rename from unittests/rpc/handlers/BookOffersTests.cpp rename to tests/unit/rpc/handlers/BookOffersTests.cpp diff --git a/unittests/rpc/handlers/DefaultProcessorTests.cpp b/tests/unit/rpc/handlers/DefaultProcessorTests.cpp similarity index 97% rename from unittests/rpc/handlers/DefaultProcessorTests.cpp rename to tests/unit/rpc/handlers/DefaultProcessorTests.cpp index a188ba2f..d6c44651 100644 --- a/unittests/rpc/handlers/DefaultProcessorTests.cpp +++ b/tests/unit/rpc/handlers/DefaultProcessorTests.cpp @@ -17,11 +17,11 @@ */ //============================================================================== +#include "rpc/FakesAndMocks.hpp" #include "rpc/common/Specs.hpp" #include "rpc/common/Types.hpp" #include "rpc/common/Validators.hpp" #include "rpc/common/impl/Processors.hpp" -#include "rpc/handlers/impl/FakesAndMocks.hpp" #include "util/Fixtures.hpp" #include @@ -33,7 +33,7 @@ using namespace std; using namespace rpc; using namespace rpc::validation; -using namespace unittests::impl; +using namespace tests::common; namespace json = boost::json; diff --git a/unittests/rpc/handlers/DepositAuthorizedTests.cpp b/tests/unit/rpc/handlers/DepositAuthorizedTests.cpp similarity index 100% rename from unittests/rpc/handlers/DepositAuthorizedTests.cpp rename to tests/unit/rpc/handlers/DepositAuthorizedTests.cpp diff --git a/unittests/rpc/handlers/GatewayBalancesTests.cpp b/tests/unit/rpc/handlers/GatewayBalancesTests.cpp similarity index 100% rename from unittests/rpc/handlers/GatewayBalancesTests.cpp rename to tests/unit/rpc/handlers/GatewayBalancesTests.cpp diff --git a/unittests/rpc/handlers/GetAggregatePriceTests.cpp b/tests/unit/rpc/handlers/GetAggregatePriceTests.cpp similarity index 100% rename from unittests/rpc/handlers/GetAggregatePriceTests.cpp rename to tests/unit/rpc/handlers/GetAggregatePriceTests.cpp diff --git a/unittests/rpc/handlers/LedgerDataTests.cpp b/tests/unit/rpc/handlers/LedgerDataTests.cpp similarity index 100% rename from unittests/rpc/handlers/LedgerDataTests.cpp rename to tests/unit/rpc/handlers/LedgerDataTests.cpp diff --git a/unittests/rpc/handlers/LedgerEntryTests.cpp b/tests/unit/rpc/handlers/LedgerEntryTests.cpp similarity index 100% rename from unittests/rpc/handlers/LedgerEntryTests.cpp rename to tests/unit/rpc/handlers/LedgerEntryTests.cpp diff --git a/unittests/rpc/handlers/LedgerRangeTests.cpp b/tests/unit/rpc/handlers/LedgerRangeTests.cpp similarity index 100% rename from unittests/rpc/handlers/LedgerRangeTests.cpp rename to tests/unit/rpc/handlers/LedgerRangeTests.cpp diff --git a/unittests/rpc/handlers/LedgerTests.cpp b/tests/unit/rpc/handlers/LedgerTests.cpp similarity index 100% rename from unittests/rpc/handlers/LedgerTests.cpp rename to tests/unit/rpc/handlers/LedgerTests.cpp diff --git a/unittests/rpc/handlers/NFTBuyOffersTests.cpp b/tests/unit/rpc/handlers/NFTBuyOffersTests.cpp similarity index 100% rename from unittests/rpc/handlers/NFTBuyOffersTests.cpp rename to tests/unit/rpc/handlers/NFTBuyOffersTests.cpp diff --git a/unittests/rpc/handlers/NFTHistoryTests.cpp b/tests/unit/rpc/handlers/NFTHistoryTests.cpp similarity index 100% rename from unittests/rpc/handlers/NFTHistoryTests.cpp rename to tests/unit/rpc/handlers/NFTHistoryTests.cpp diff --git a/unittests/rpc/handlers/NFTInfoTests.cpp b/tests/unit/rpc/handlers/NFTInfoTests.cpp similarity index 100% rename from unittests/rpc/handlers/NFTInfoTests.cpp rename to tests/unit/rpc/handlers/NFTInfoTests.cpp diff --git a/unittests/rpc/handlers/NFTSellOffersTests.cpp b/tests/unit/rpc/handlers/NFTSellOffersTests.cpp similarity index 100% rename from unittests/rpc/handlers/NFTSellOffersTests.cpp rename to tests/unit/rpc/handlers/NFTSellOffersTests.cpp diff --git a/unittests/rpc/handlers/NFTsByIssuerTest.cpp b/tests/unit/rpc/handlers/NFTsByIssuerTest.cpp similarity index 100% rename from unittests/rpc/handlers/NFTsByIssuerTest.cpp rename to tests/unit/rpc/handlers/NFTsByIssuerTest.cpp diff --git a/unittests/rpc/handlers/NoRippleCheckTests.cpp b/tests/unit/rpc/handlers/NoRippleCheckTests.cpp similarity index 100% rename from unittests/rpc/handlers/NoRippleCheckTests.cpp rename to tests/unit/rpc/handlers/NoRippleCheckTests.cpp diff --git a/unittests/rpc/handlers/PingTests.cpp b/tests/unit/rpc/handlers/PingTests.cpp similarity index 100% rename from unittests/rpc/handlers/PingTests.cpp rename to tests/unit/rpc/handlers/PingTests.cpp diff --git a/unittests/rpc/handlers/RandomTests.cpp b/tests/unit/rpc/handlers/RandomTests.cpp similarity index 100% rename from unittests/rpc/handlers/RandomTests.cpp rename to tests/unit/rpc/handlers/RandomTests.cpp diff --git a/unittests/rpc/handlers/ServerInfoTests.cpp b/tests/unit/rpc/handlers/ServerInfoTests.cpp similarity index 100% rename from unittests/rpc/handlers/ServerInfoTests.cpp rename to tests/unit/rpc/handlers/ServerInfoTests.cpp diff --git a/unittests/rpc/handlers/SubscribeTests.cpp b/tests/unit/rpc/handlers/SubscribeTests.cpp similarity index 100% rename from unittests/rpc/handlers/SubscribeTests.cpp rename to tests/unit/rpc/handlers/SubscribeTests.cpp diff --git a/unittests/rpc/handlers/TestHandlerTests.cpp b/tests/unit/rpc/handlers/TestHandlerTests.cpp similarity index 97% rename from unittests/rpc/handlers/TestHandlerTests.cpp rename to tests/unit/rpc/handlers/TestHandlerTests.cpp index d005efb7..7534dd4c 100644 --- a/unittests/rpc/handlers/TestHandlerTests.cpp +++ b/tests/unit/rpc/handlers/TestHandlerTests.cpp @@ -18,9 +18,9 @@ //============================================================================== #include "rpc/Errors.hpp" +#include "rpc/FakesAndMocks.hpp" #include "rpc/common/AnyHandler.hpp" #include "rpc/common/Types.hpp" -#include "rpc/handlers/impl/FakesAndMocks.hpp" #include "util/Fixtures.hpp" #include @@ -29,7 +29,7 @@ using namespace std; using namespace rpc; using namespace rpc::validation; -using namespace unittests::impl; +using namespace tests::common; namespace json = boost::json; diff --git a/unittests/rpc/handlers/TransactionEntryTests.cpp b/tests/unit/rpc/handlers/TransactionEntryTests.cpp similarity index 100% rename from unittests/rpc/handlers/TransactionEntryTests.cpp rename to tests/unit/rpc/handlers/TransactionEntryTests.cpp diff --git a/unittests/rpc/handlers/TxTests.cpp b/tests/unit/rpc/handlers/TxTests.cpp similarity index 100% rename from unittests/rpc/handlers/TxTests.cpp rename to tests/unit/rpc/handlers/TxTests.cpp diff --git a/unittests/rpc/handlers/UnsubscribeTests.cpp b/tests/unit/rpc/handlers/UnsubscribeTests.cpp similarity index 100% rename from unittests/rpc/handlers/UnsubscribeTests.cpp rename to tests/unit/rpc/handlers/UnsubscribeTests.cpp diff --git a/unittests/rpc/handlers/VersionHandlerTests.cpp b/tests/unit/rpc/handlers/VersionHandlerTests.cpp similarity index 100% rename from unittests/rpc/handlers/VersionHandlerTests.cpp rename to tests/unit/rpc/handlers/VersionHandlerTests.cpp diff --git a/unittests/util/AssertTests.cpp b/tests/unit/util/AssertTests.cpp similarity index 100% rename from unittests/util/AssertTests.cpp rename to tests/unit/util/AssertTests.cpp diff --git a/unittests/util/AtomicTests.cpp b/tests/unit/util/AtomicTests.cpp similarity index 100% rename from unittests/util/AtomicTests.cpp rename to tests/unit/util/AtomicTests.cpp diff --git a/unittests/util/BatchingTests.cpp b/tests/unit/util/BatchingTests.cpp similarity index 100% rename from unittests/util/BatchingTests.cpp rename to tests/unit/util/BatchingTests.cpp diff --git a/unittests/util/LedgerUtilsTests.cpp b/tests/unit/util/LedgerUtilsTests.cpp similarity index 100% rename from unittests/util/LedgerUtilsTests.cpp rename to tests/unit/util/LedgerUtilsTests.cpp diff --git a/unittests/util/RetryTests.cpp b/tests/unit/util/RetryTests.cpp similarity index 100% rename from unittests/util/RetryTests.cpp rename to tests/unit/util/RetryTests.cpp diff --git a/unittests/util/SignalsHandlerTests.cpp b/tests/unit/util/SignalsHandlerTests.cpp similarity index 100% rename from unittests/util/SignalsHandlerTests.cpp rename to tests/unit/util/SignalsHandlerTests.cpp diff --git a/unittests/util/TxUtilTests.cpp b/tests/unit/util/TxUtilTests.cpp similarity index 100% rename from unittests/util/TxUtilTests.cpp rename to tests/unit/util/TxUtilTests.cpp diff --git a/unittests/util/async/AnyExecutionContextTests.cpp b/tests/unit/util/async/AnyExecutionContextTests.cpp similarity index 100% rename from unittests/util/async/AnyExecutionContextTests.cpp rename to tests/unit/util/async/AnyExecutionContextTests.cpp diff --git a/unittests/util/async/AnyOperationTests.cpp b/tests/unit/util/async/AnyOperationTests.cpp similarity index 100% rename from unittests/util/async/AnyOperationTests.cpp rename to tests/unit/util/async/AnyOperationTests.cpp diff --git a/unittests/util/async/AnyStopTokenTests.cpp b/tests/unit/util/async/AnyStopTokenTests.cpp similarity index 100% rename from unittests/util/async/AnyStopTokenTests.cpp rename to tests/unit/util/async/AnyStopTokenTests.cpp diff --git a/unittests/util/async/AnyStrandTests.cpp b/tests/unit/util/async/AnyStrandTests.cpp similarity index 100% rename from unittests/util/async/AnyStrandTests.cpp rename to tests/unit/util/async/AnyStrandTests.cpp diff --git a/unittests/util/async/AsyncExecutionContextTests.cpp b/tests/unit/util/async/AsyncExecutionContextTests.cpp similarity index 100% rename from unittests/util/async/AsyncExecutionContextTests.cpp rename to tests/unit/util/async/AsyncExecutionContextTests.cpp diff --git a/unittests/util/prometheus/BoolTests.cpp b/tests/unit/util/prometheus/BoolTests.cpp similarity index 100% rename from unittests/util/prometheus/BoolTests.cpp rename to tests/unit/util/prometheus/BoolTests.cpp diff --git a/unittests/util/prometheus/CounterTests.cpp b/tests/unit/util/prometheus/CounterTests.cpp similarity index 100% rename from unittests/util/prometheus/CounterTests.cpp rename to tests/unit/util/prometheus/CounterTests.cpp diff --git a/unittests/util/prometheus/GaugeTests.cpp b/tests/unit/util/prometheus/GaugeTests.cpp similarity index 100% rename from unittests/util/prometheus/GaugeTests.cpp rename to tests/unit/util/prometheus/GaugeTests.cpp diff --git a/unittests/util/prometheus/HistogramTests.cpp b/tests/unit/util/prometheus/HistogramTests.cpp similarity index 100% rename from unittests/util/prometheus/HistogramTests.cpp rename to tests/unit/util/prometheus/HistogramTests.cpp diff --git a/unittests/util/prometheus/HttpTests.cpp b/tests/unit/util/prometheus/HttpTests.cpp similarity index 100% rename from unittests/util/prometheus/HttpTests.cpp rename to tests/unit/util/prometheus/HttpTests.cpp diff --git a/unittests/util/prometheus/LabelTests.cpp b/tests/unit/util/prometheus/LabelTests.cpp similarity index 100% rename from unittests/util/prometheus/LabelTests.cpp rename to tests/unit/util/prometheus/LabelTests.cpp diff --git a/unittests/util/prometheus/MetricBuilderTests.cpp b/tests/unit/util/prometheus/MetricBuilderTests.cpp similarity index 100% rename from unittests/util/prometheus/MetricBuilderTests.cpp rename to tests/unit/util/prometheus/MetricBuilderTests.cpp diff --git a/unittests/util/prometheus/MetricsFamilyTests.cpp b/tests/unit/util/prometheus/MetricsFamilyTests.cpp similarity index 100% rename from unittests/util/prometheus/MetricsFamilyTests.cpp rename to tests/unit/util/prometheus/MetricsFamilyTests.cpp diff --git a/unittests/util/prometheus/OStreamTests.cpp b/tests/unit/util/prometheus/OStreamTests.cpp similarity index 100% rename from unittests/util/prometheus/OStreamTests.cpp rename to tests/unit/util/prometheus/OStreamTests.cpp diff --git a/unittests/util/requests/RequestBuilderTests.cpp b/tests/unit/util/requests/RequestBuilderTests.cpp similarity index 100% rename from unittests/util/requests/RequestBuilderTests.cpp rename to tests/unit/util/requests/RequestBuilderTests.cpp diff --git a/unittests/util/requests/SslContextTests.cpp b/tests/unit/util/requests/SslContextTests.cpp similarity index 100% rename from unittests/util/requests/SslContextTests.cpp rename to tests/unit/util/requests/SslContextTests.cpp diff --git a/unittests/util/requests/WsConnectionTests.cpp b/tests/unit/util/requests/WsConnectionTests.cpp similarity index 100% rename from unittests/util/requests/WsConnectionTests.cpp rename to tests/unit/util/requests/WsConnectionTests.cpp diff --git a/unittests/web/AdminVerificationTests.cpp b/tests/unit/web/AdminVerificationTests.cpp similarity index 100% rename from unittests/web/AdminVerificationTests.cpp rename to tests/unit/web/AdminVerificationTests.cpp diff --git a/unittests/web/RPCServerHandlerTests.cpp b/tests/unit/web/RPCServerHandlerTests.cpp similarity index 100% rename from unittests/web/RPCServerHandlerTests.cpp rename to tests/unit/web/RPCServerHandlerTests.cpp diff --git a/unittests/web/ServerTests.cpp b/tests/unit/web/ServerTests.cpp similarity index 100% rename from unittests/web/ServerTests.cpp rename to tests/unit/web/ServerTests.cpp diff --git a/unittests/web/SweepHandlerTests.cpp b/tests/unit/web/SweepHandlerTests.cpp similarity index 93% rename from unittests/web/SweepHandlerTests.cpp rename to tests/unit/web/SweepHandlerTests.cpp index b0604d79..a950aaf4 100644 --- a/unittests/web/SweepHandlerTests.cpp +++ b/tests/unit/web/SweepHandlerTests.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include "rpc/handlers/impl/FakesAndMocks.hpp" +#include "rpc/FakesAndMocks.hpp" #include "util/Fixtures.hpp" #include "util/config/Config.hpp" #include "web/IntervalSweepHandler.hpp" @@ -47,7 +47,7 @@ class DOSGuardIntervalSweepHandlerTest : public SyncAsioContextTest { protected: Config cfg{boost::json::parse(JSONData)}; IntervalSweepHandler sweepHandler{cfg, ctx}; - unittests::impl::BasicDOSGuardMock guard{sweepHandler}; + tests::common::BasicDOSGuardMock guard{sweepHandler}; }; TEST_F(DOSGuardIntervalSweepHandlerTest, SweepAfterInterval) diff --git a/unittests/web/WhitelistHandlerTests.cpp b/tests/unit/web/WhitelistHandlerTests.cpp similarity index 100% rename from unittests/web/WhitelistHandlerTests.cpp rename to tests/unit/web/WhitelistHandlerTests.cpp diff --git a/unittests/README.md b/unittests/README.md deleted file mode 100644 index 6cf0e053..00000000 --- a/unittests/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Unit testing - -The correctness of new implementations can be verified via running unit tests. Below are the information on how to run unit tests. - -## Requirements -### Cassandra cluster -If you wish to test the backend component you will need to have access to a **local (127.0.0.1)** Cassandra cluster, opened at port **9042**. Please ensure that the cluster is successfully running before running unit tests unless you filter out all `Backend` tests. - -## Running -To run the unit tests, first build Clio as normal, then execute `./clio_tests` to run all unit tests. - -**Note:** If you don't want to test the Cassandra backend code, the relevant tests can be disabled like this: `./clio_tests --gtest_filter="-BackendCassandraBaseTest*:BackendCassandraTest*:BackendCassandraFactoryTestWithDB*"` - -# Adding Unit Tests -To add unit tests, please create a separate file for the component you are trying to cover (unless it already exists) and use any other existing unit test file as an example.