diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2020-06-16 07:53:22 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-06-21 12:32:58 +0000 |
commit | 33201c068f9ec37196190be083d61f46dc83d470 (patch) | |
tree | 59a30062c8fd5ece6cecc4702c28d2d5417b5b8c /src/mongo/db/s/shard_server_test_fixture.h | |
parent | 85707dafe1d2894505fdcf74336f93ed7a5f6636 (diff) | |
download | mongo-33201c068f9ec37196190be083d61f46dc83d470.tar.gz |
SERVER-48775 Move all Sharding unit-tests that assume a MongoD to the db/s directory
With this change there are no more references from mongo/s (which is
code common between MongoS and MongoD) and mongo/db/s (which is code
specific for MongoD only).
Diffstat (limited to 'src/mongo/db/s/shard_server_test_fixture.h')
-rw-r--r-- | src/mongo/db/s/shard_server_test_fixture.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/mongo/db/s/shard_server_test_fixture.h b/src/mongo/db/s/shard_server_test_fixture.h new file mode 100644 index 00000000000..deee682e174 --- /dev/null +++ b/src/mongo/db/s/shard_server_test_fixture.h @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2018-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include "mongo/db/s/sharding_mongod_test_fixture.h" + +namespace mongo { + +/** + * Test fixture for shard components, as opposed to config or mongos components. Provides a mock + * network and ephemeral storage engine via ShardingMongodTestFixture. Additionally sets up mock + * dist lock catalog and manager with a real catalog client. + */ +class ShardServerTestFixture : public ShardingMongodTestFixture { +protected: + ShardServerTestFixture(); + ~ShardServerTestFixture(); + + void setUp() override; + void tearDown() override; + + /** + * Returns the mock targeter for the config server. Useful to use like so, + * + * configTargeterMock()->setFindHostReturnValue(HostAndPort); + * configTargeterMock()->setFindHostReturnValue({ErrorCodes::InternalError, "can't target"}) + * + * Remote calls always need to resolve a host with RemoteCommandTargeterMock::findHost, so it + * must be set. + */ + std::shared_ptr<RemoteCommandTargeterMock> configTargeterMock(); + + /** + * Creates a DistLockCatalogMock. + */ + std::unique_ptr<DistLockCatalog> makeDistLockCatalog() override; + + /** + * Creates a DistLockManagerMock. + */ + std::unique_ptr<DistLockManager> makeDistLockManager( + std::unique_ptr<DistLockCatalog> distLockCatalog) override; + + /** + * Creates a real ShardingCatalogClient. + */ + std::unique_ptr<ShardingCatalogClient> makeShardingCatalogClient( + std::unique_ptr<DistLockManager> distLockManager) override; + + static const HostAndPort kConfigHostAndPort; + + const ShardId _myShardName{"myShardName"}; + OID _clusterId; +}; + +} // namespace mongo |