This is an automated email from the ASF dual-hosted git repository.
laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new d317baf6c refactor: move SetEncryptionFlags to constructors
d317baf6c is described below
commit d317baf6cbb8223b9057e2814de1e47be8d2cac8
Author: Yingchun Lai <[email protected]>
AuthorDate: Wed Oct 18 23:41:56 2023 +0800
refactor: move SetEncryptionFlags to constructors
SetEncryptionFlags() is a test utility function used
to enable or disable encryption in unit tests. In
some parameterized tests, SetEncryptionFlags() calls
are distributed in many test cases, there is a risk
that missing to call it if add new test cases.
This patch moves the function call to the constructors,
also changes TEST_F to TEST_P for test
LogBlockManagerTest.TestContainerBlockLimitingByMetadataSizeWithCompaction
Change-Id: I67dca5a45f78de87309d0434c3b003a83f28e1a6
Reviewed-on: http://gerrit.cloudera.org:8080/20592
Tested-by: Yingchun Lai <[email protected]>
Reviewed-by: Alexey Serbin <[email protected]>
---
src/kudu/consensus/consensus_meta-test.cc | 59 ++++++++++++++-----------------
src/kudu/fs/log_block_manager-test.cc | 33 ++---------------
src/kudu/util/file_cache-test.cc | 20 +++++++----
3 files changed, 42 insertions(+), 70 deletions(-)
diff --git a/src/kudu/consensus/consensus_meta-test.cc
b/src/kudu/consensus/consensus_meta-test.cc
index 952f5a7d8..0736c81dd 100644
--- a/src/kudu/consensus/consensus_meta-test.cc
+++ b/src/kudu/consensus/consensus_meta-test.cc
@@ -56,19 +56,20 @@ const int64_t kInitialTerm = 3;
class ConsensusMetadataTest : public KuduTest, public
::testing::WithParamInterface<bool> {
public:
- ConsensusMetadataTest()
- : fs_manager_(env_, FsManagerOpts(GetTestPath("fs_root"))) {
+ ConsensusMetadataTest() {
+ SetEncryptionFlags(GetParam());
+ fs_manager_ = std::make_unique<FsManager>(env_,
FsManagerOpts(GetTestPath("fs_root")));
}
void SetUp() override {
KuduTest::SetUp();
- ASSERT_OK(fs_manager_.CreateInitialFileSystemLayout());
- ASSERT_OK(fs_manager_.Open());
+ ASSERT_OK(fs_manager_->CreateInitialFileSystemLayout());
+ ASSERT_OK(fs_manager_->Open());
// Initialize test configuration.
config_.set_opid_index(kInvalidOpIdIndex);
RaftPeerPB* peer = config_.add_peers();
- peer->set_permanent_uuid(fs_manager_.uuid());
+ peer->set_permanent_uuid(fs_manager_->uuid());
peer->set_member_type(RaftPeerPB::VOTER);
}
@@ -78,7 +79,7 @@ class ConsensusMetadataTest : public KuduTest, public
::testing::WithParamInterf
int64_t opid_index, const string& permanant_uuid,
int64_t term);
- FsManager fs_manager_;
+ std::unique_ptr<FsManager> fs_manager_;
RaftConfigPB config_;
};
@@ -99,49 +100,46 @@ INSTANTIATE_TEST_SUITE_P(, ConsensusMetadataTest,
::testing::Values(false, true)
// Test the basic "happy case" of creating and then loading a file.
TEST_P(ConsensusMetadataTest, TestCreateLoad) {
- SetEncryptionFlags(GetParam());
// Create the file.
{
- ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId,
fs_manager_.uuid(),
+ ASSERT_OK(ConsensusMetadata::Create(fs_manager_.get(), kTabletId,
fs_manager_->uuid(),
config_, kInitialTerm));
}
// Load the file.
scoped_refptr<ConsensusMetadata> cmeta;
- ASSERT_OK(ConsensusMetadata::Load(&fs_manager_, kTabletId,
fs_manager_.uuid(), &cmeta));
- NO_FATALS(AssertValuesEqual(cmeta, kInvalidOpIdIndex, fs_manager_.uuid(),
kInitialTerm));
+ ASSERT_OK(ConsensusMetadata::Load(fs_manager_.get(), kTabletId,
fs_manager_->uuid(), &cmeta));
+ NO_FATALS(AssertValuesEqual(cmeta, kInvalidOpIdIndex, fs_manager_->uuid(),
kInitialTerm));
ASSERT_GT(cmeta->on_disk_size(), 0);
}
// Test deferred creation.
TEST_P(ConsensusMetadataTest, TestDeferredCreateLoad) {
- SetEncryptionFlags(GetParam());
// Create the cmeta object, but not the file.
scoped_refptr<ConsensusMetadata> writer;
- ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId,
fs_manager_.uuid(),
+ ASSERT_OK(ConsensusMetadata::Create(fs_manager_.get(), kTabletId,
fs_manager_->uuid(),
config_, kInitialTerm,
ConsensusMetadataCreateMode::NO_FLUSH_ON_CREATE,
&writer));
// Try to load the file: it should not be there.
scoped_refptr<ConsensusMetadata> reader;
- Status s = ConsensusMetadata::Load(&fs_manager_, kTabletId,
fs_manager_.uuid(), &reader);
+ Status s = ConsensusMetadata::Load(fs_manager_.get(), kTabletId,
fs_manager_->uuid(), &reader);
ASSERT_TRUE(s.IsNotFound()) << s.ToString();
// Flush; now the file will be there.
ASSERT_OK(writer->Flush());
- ASSERT_OK(ConsensusMetadata::Load(&fs_manager_, kTabletId,
fs_manager_.uuid(), &reader));
- NO_FATALS(AssertValuesEqual(reader, kInvalidOpIdIndex, fs_manager_.uuid(),
kInitialTerm));
+ ASSERT_OK(ConsensusMetadata::Load(fs_manager_.get(), kTabletId,
fs_manager_->uuid(), &reader));
+ NO_FATALS(AssertValuesEqual(reader, kInvalidOpIdIndex, fs_manager_->uuid(),
kInitialTerm));
}
// Ensure that Create() will not overwrite an existing file.
TEST_P(ConsensusMetadataTest, TestCreateNoOverwrite) {
- SetEncryptionFlags(GetParam());
// Create the consensus metadata file.
- ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId,
fs_manager_.uuid(),
+ ASSERT_OK(ConsensusMetadata::Create(fs_manager_.get(), kTabletId,
fs_manager_->uuid(),
config_, kInitialTerm));
// Try to create it again.
- Status s = ConsensusMetadata::Create(&fs_manager_, kTabletId,
fs_manager_.uuid(),
+ Status s = ConsensusMetadata::Create(fs_manager_.get(), kTabletId,
fs_manager_->uuid(),
config_, kInitialTerm);
ASSERT_TRUE(s.IsAlreadyPresent()) << s.ToString();
ASSERT_STR_MATCHES(s.ToString(), "Unable to write consensus meta
file.*already exists");
@@ -149,18 +147,16 @@ TEST_P(ConsensusMetadataTest, TestCreateNoOverwrite) {
// Ensure that we get an error when loading a file that doesn't exist.
TEST_P(ConsensusMetadataTest, TestFailedLoad) {
- SetEncryptionFlags(GetParam());
- Status s = ConsensusMetadata::Load(&fs_manager_, kTabletId,
fs_manager_.uuid());
+ Status s = ConsensusMetadata::Load(fs_manager_.get(), kTabletId,
fs_manager_->uuid());
ASSERT_TRUE(s.IsNotFound()) << s.ToString();
LOG(INFO) << "Expected failure: " << s.ToString();
}
// Check that changes are not written to disk until Flush() is called.
TEST_P(ConsensusMetadataTest, TestFlush) {
- SetEncryptionFlags(GetParam());
const int64_t kNewTerm = 4;
scoped_refptr<ConsensusMetadata> cmeta;
- ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId,
fs_manager_.uuid(),
+ ASSERT_OK(ConsensusMetadata::Create(fs_manager_.get(), kTabletId,
fs_manager_->uuid(),
config_, kInitialTerm,
ConsensusMetadataCreateMode::FLUSH_ON_CREATE,
&cmeta));
@@ -171,8 +167,9 @@ TEST_P(ConsensusMetadataTest, TestFlush) {
// since it's read-only.
{
scoped_refptr<ConsensusMetadata> cmeta_read;
- ASSERT_OK(ConsensusMetadata::Load(&fs_manager_, kTabletId,
fs_manager_.uuid(), &cmeta_read));
- NO_FATALS(AssertValuesEqual(cmeta_read, kInvalidOpIdIndex,
fs_manager_.uuid(), kInitialTerm));
+ ASSERT_OK(ConsensusMetadata::Load(
+ fs_manager_.get(), kTabletId, fs_manager_->uuid(), &cmeta_read));
+ NO_FATALS(AssertValuesEqual(cmeta_read, kInvalidOpIdIndex,
fs_manager_->uuid(), kInitialTerm));
ASSERT_GT(cmeta->on_disk_size(), 0);
}
@@ -181,8 +178,9 @@ TEST_P(ConsensusMetadataTest, TestFlush) {
{
scoped_refptr<ConsensusMetadata> cmeta_read;
- ASSERT_OK(ConsensusMetadata::Load(&fs_manager_, kTabletId,
fs_manager_.uuid(), &cmeta_read));
- NO_FATALS(AssertValuesEqual(cmeta_read, kInvalidOpIdIndex,
fs_manager_.uuid(), kNewTerm));
+ ASSERT_OK(ConsensusMetadata::Load(
+ fs_manager_.get(), kTabletId, fs_manager_->uuid(), &cmeta_read));
+ NO_FATALS(AssertValuesEqual(cmeta_read, kInvalidOpIdIndex,
fs_manager_->uuid(), kNewTerm));
ASSERT_EQ(cmeta_size, cmeta_read->on_disk_size());
}
}
@@ -201,14 +199,13 @@ RaftConfigPB BuildConfig(const vector<string>& uuids) {
// Test ConsensusMetadata active role calculation.
TEST_P(ConsensusMetadataTest, TestActiveRole) {
- SetEncryptionFlags(GetParam());
vector<string> uuids = { "a", "b", "c", "d" };
string peer_uuid = "e";
RaftConfigPB config1 = BuildConfig(uuids); // We aren't a member of this
config...
config1.set_opid_index(0);
scoped_refptr<ConsensusMetadata> cmeta;
- ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId, peer_uuid,
+ ASSERT_OK(ConsensusMetadata::Create(fs_manager_.get(), kTabletId, peer_uuid,
config1, kInitialTerm,
ConsensusMetadataCreateMode::FLUSH_ON_CREATE,
&cmeta));
@@ -268,14 +265,13 @@ TEST_P(ConsensusMetadataTest, TestActiveRole) {
// Ensure that invocations of ToConsensusStatePB() return the expected state
// in the returned object.
TEST_P(ConsensusMetadataTest, TestToConsensusStatePB) {
- SetEncryptionFlags(GetParam());
vector<string> uuids = { "a", "b", "c", "d" };
string peer_uuid = "e";
RaftConfigPB committed_config = BuildConfig(uuids); // We aren't a member of
this config...
committed_config.set_opid_index(1);
scoped_refptr<ConsensusMetadata> cmeta;
- ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId, peer_uuid,
+ ASSERT_OK(ConsensusMetadata::Create(fs_manager_.get(), kTabletId, peer_uuid,
committed_config, kInitialTerm,
ConsensusMetadataCreateMode::FLUSH_ON_CREATE,
&cmeta));
@@ -328,13 +324,12 @@ static void AssertConsensusMergeExpected(const
scoped_refptr<ConsensusMetadata>&
// Ensure that MergeCommittedConsensusStatePB() works as advertised.
TEST_P(ConsensusMetadataTest, TestMergeCommittedConsensusStatePB) {
- SetEncryptionFlags(GetParam());
vector<string> uuids = { "a", "b", "c", "d" };
RaftConfigPB committed_config = BuildConfig(uuids); // We aren't a member of
this config...
committed_config.set_opid_index(1);
scoped_refptr<ConsensusMetadata> cmeta;
- ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId, "e",
+ ASSERT_OK(ConsensusMetadata::Create(fs_manager_.get(), kTabletId, "e",
committed_config, 1,
ConsensusMetadataCreateMode::FLUSH_ON_CREATE,
&cmeta));
diff --git a/src/kudu/fs/log_block_manager-test.cc
b/src/kudu/fs/log_block_manager-test.cc
index f0c491a52..6fa33c68a 100644
--- a/src/kudu/fs/log_block_manager-test.cc
+++ b/src/kudu/fs/log_block_manager-test.cc
@@ -134,6 +134,7 @@ class LogBlockManagerTest : public KuduTest, public
::testing::WithParamInterfac
//
// Not strictly necessary except for
TestDeleteFromContainerAfterMetadataCompaction.
file_cache_("test_cache", env_, 50, scoped_refptr<MetricEntity>()) {
+ SetEncryptionFlags(GetParam());
CHECK_OK(file_cache_.Init());
error_manager_ = make_scoped_refptr(new FsErrorManager());
bm_ = CreateBlockManager(scoped_refptr<MetricEntity>());
@@ -345,7 +346,6 @@ static void CheckLogMetrics(const
scoped_refptr<MetricEntity>& entity,
INSTANTIATE_TEST_SUITE_P(EncryptionEnabled, LogBlockManagerTest,
::testing::Values(false, true));
TEST_P(LogBlockManagerTest, MetricsTest) {
- SetEncryptionFlags(GetParam());
MetricRegistry registry;
scoped_refptr<MetricEntity> entity =
METRIC_ENTITY_server.Instantiate(®istry, "test");
ASSERT_OK(ReopenBlockManager(entity));
@@ -515,7 +515,6 @@ TEST_P(LogBlockManagerTest, MetricsTest) {
}
TEST_P(LogBlockManagerTest, ContainerPreallocationTest) {
- SetEncryptionFlags(GetParam());
string kTestData = "test data";
// For this test to work properly, the preallocation window has to be at
@@ -560,7 +559,6 @@ TEST_P(LogBlockManagerTest, ContainerPreallocationTest) {
// Test for KUDU-2202 to ensure that once the block manager has been notified
// of a block ID, it will not reuse it.
TEST_P(LogBlockManagerTest, TestBumpBlockIds) {
- SetEncryptionFlags(GetParam());
const int kNumBlocks = 10;
vector<BlockId> block_ids;
unique_ptr<WritableBlock> writer;
@@ -593,7 +591,6 @@ TEST_P(LogBlockManagerTest, TestBumpBlockIds) {
// Regression test for KUDU-1190, a crash at startup when a block ID has been
// reused.
TEST_P(LogBlockManagerTest, TestReuseBlockIds) {
- SetEncryptionFlags(GetParam());
// Typically, the LBM starts with a random block ID when running as a
// gtest. In this test, we want to control the block IDs.
bm_->next_block_id_.Store(1);
@@ -667,7 +664,6 @@ TEST_P(LogBlockManagerTest, TestReuseBlockIds) {
// Note that we rely on filesystem integrity to ensure that we do not lose
// trailing, fsync()ed metadata.
TEST_P(LogBlockManagerTest, TestMetadataTruncation) {
- SetEncryptionFlags(GetParam());
// Create several blocks.
vector<BlockId> created_blocks;
BlockId last_block_id;
@@ -861,7 +857,6 @@ TEST_P(LogBlockManagerTest, TestMetadataTruncation) {
// Regression test for a crash when a container's append offset exceeded its
// preallocation offset.
TEST_P(LogBlockManagerTest, TestAppendExceedsPreallocation) {
- SetEncryptionFlags(GetParam());
FLAGS_log_container_preallocate_bytes = 1;
// Create a container, preallocate it by one byte, and append more than one.
@@ -877,7 +872,6 @@ TEST_P(LogBlockManagerTest, TestAppendExceedsPreallocation)
{
}
TEST_P(LogBlockManagerTest, TestPreallocationAndTruncation) {
- SetEncryptionFlags(GetParam());
// Ensure preallocation window is greater than the container size itself.
FLAGS_log_container_max_size = 1024 * 1024;
FLAGS_log_container_preallocate_bytes = 32 * 1024 * 1024;
@@ -941,7 +935,6 @@ TEST_P(LogBlockManagerTest, TestPreallocationAndTruncation)
{
}
TEST_P(LogBlockManagerTest, TestContainerWithManyHoles) {
- SetEncryptionFlags(GetParam());
// This is a regression test of sorts for KUDU-1508, though it doesn't
// actually fail if the fix is missing; it just corrupts the filesystem.
@@ -999,7 +992,6 @@ TEST_P(LogBlockManagerTest, TestContainerWithManyHoles) {
}
TEST_P(LogBlockManagerTest, TestParseKernelRelease) {
- SetEncryptionFlags(GetParam());
ASSERT_TRUE(LogBlockManager::IsBuggyEl6Kernel("1.7.0.0.el6.x86_64"));
// no el6 infix
@@ -1058,7 +1050,6 @@ TEST_P(LogBlockManagerTest, TestParseKernelRelease) {
// However it still can be used to micro-optimize the startup process.
TEST_P(LogBlockManagerTest, StartupBenchmark) {
SKIP_IF_SLOW_NOT_ALLOWED();
- SetEncryptionFlags(GetParam());
// Disable preflushing since this can slow down our writes. In particular,
// since we write such small blocks in this test, each block will likely
// begin on the same 4KB page as the prior one we wrote, and due to the
@@ -1137,7 +1128,6 @@ TEST_P(LogBlockManagerTest, StartupBenchmark) {
#endif
TEST_P(LogBlockManagerTest, TestFailMultipleTransactionsPerContainer) {
- SetEncryptionFlags(GetParam());
// Create multiple transactions that will share a container.
const int kNumTransactions = 3;
vector<unique_ptr<BlockCreationTransaction>> block_transactions;
@@ -1196,7 +1186,6 @@ TEST_P(LogBlockManagerTest,
TestFailMultipleTransactionsPerContainer) {
}
TEST_P(LogBlockManagerTest, TestLookupBlockLimit) {
- SetEncryptionFlags(GetParam());
int64_t limit_1024 = LogBlockManager::LookupBlockLimit(1024);
int64_t limit_2048 = LogBlockManager::LookupBlockLimit(2048);
int64_t limit_4096 = LogBlockManager::LookupBlockLimit(4096);
@@ -1214,7 +1203,6 @@ TEST_P(LogBlockManagerTest, TestLookupBlockLimit) {
}
TEST_P(LogBlockManagerTest, TestContainerBlockLimitingByBlockNum) {
- SetEncryptionFlags(GetParam());
const int kNumBlocks = 1000;
// Creates 'kNumBlocks' blocks with minimal data.
@@ -1249,7 +1237,6 @@ TEST_P(LogBlockManagerTest,
TestContainerBlockLimitingByBlockNum) {
}
TEST_P(LogBlockManagerTest, TestContainerBlockLimitingByMetadataSize) {
- SetEncryptionFlags(GetParam());
const int kNumBlocks = 1000;
// Creates 'kNumBlocks' blocks with minimal data.
@@ -1285,7 +1272,7 @@ TEST_P(LogBlockManagerTest,
TestContainerBlockLimitingByMetadataSize) {
NO_FATALS(AssertNumContainers(4));
}
-TEST_F(LogBlockManagerTest,
TestContainerBlockLimitingByMetadataSizeWithCompaction) {
+TEST_P(LogBlockManagerTest,
TestContainerBlockLimitingByMetadataSizeWithCompaction) {
const int kNumBlocks = 2000;
const int kNumThreads = 10;
const double kLiveBlockRatio = 0.1;
@@ -1375,7 +1362,6 @@ TEST_F(LogBlockManagerTest,
TestContainerBlockLimitingByMetadataSizeWithCompacti
}
TEST_P(LogBlockManagerTest, TestMisalignedBlocksFuzz) {
- SetEncryptionFlags(GetParam());
FLAGS_log_container_preallocate_bytes = 0;
const int kNumBlocks = 100;
@@ -1477,7 +1463,6 @@ TEST_P(LogBlockManagerTest, TestMisalignedBlocksFuzz) {
}
TEST_P(LogBlockManagerTest, TestRepairPreallocateExcessSpace) {
- SetEncryptionFlags(GetParam());
// Enforce that the container's actual size is strictly upper-bounded by the
// calculated size so we can more easily trigger repairs.
FLAGS_log_container_excess_space_before_cleanup_fraction = 0.0;
@@ -1526,7 +1511,6 @@ TEST_P(LogBlockManagerTest,
TestRepairPreallocateExcessSpace) {
}
TEST_P(LogBlockManagerTest, TestRepairUnpunchedBlocks) {
- SetEncryptionFlags(GetParam());
const int kNumBlocks = 100;
// Enforce that the container's actual size is strictly upper-bounded by the
@@ -1587,7 +1571,6 @@ TEST_P(LogBlockManagerTest, TestRepairUnpunchedBlocks) {
}
TEST_P(LogBlockManagerTest, TestRepairIncompleteContainer) {
- SetEncryptionFlags(GetParam());
const int kNumContainers = 20;
// Create some incomplete containers. The corruptor will select between
@@ -1618,7 +1601,6 @@ TEST_P(LogBlockManagerTest,
TestRepairIncompleteContainer) {
}
TEST_P(LogBlockManagerTest, TestDetectMalformedRecords) {
- SetEncryptionFlags(GetParam());
const int kNumRecords = 50;
// Create one container.
@@ -1651,7 +1633,6 @@ TEST_P(LogBlockManagerTest, TestDetectMalformedRecords) {
}
TEST_P(LogBlockManagerTest, TestDetectMisalignedBlocks) {
- SetEncryptionFlags(GetParam());
const int kNumBlocks = 50;
// Create one container.
@@ -1684,7 +1665,6 @@ TEST_P(LogBlockManagerTest, TestDetectMisalignedBlocks) {
}
TEST_P(LogBlockManagerTest, TestRepairPartialRecords) {
- SetEncryptionFlags(GetParam());
const int kNumContainers = 50;
const int kNumRecords = 10;
@@ -1726,7 +1706,6 @@ TEST_P(LogBlockManagerTest, TestRepairPartialRecords) {
}
TEST_P(LogBlockManagerTest, TestDeleteDeadContainersAtStartup) {
- SetEncryptionFlags(GetParam());
// Force our single container to become full once created.
FLAGS_log_container_max_size = 0;
@@ -1763,7 +1742,6 @@ TEST_P(LogBlockManagerTest,
TestDeleteDeadContainersAtStartup) {
}
TEST_P(LogBlockManagerTest, TestCompactFullContainerMetadataAtStartup) {
- SetEncryptionFlags(GetParam());
// With this ratio, the metadata of a full container comprised of half dead
// blocks will be compacted at startup.
FLAGS_log_container_live_metadata_before_compact_ratio = 0.50;
@@ -1828,7 +1806,6 @@ TEST_P(LogBlockManagerTest,
TestCompactFullContainerMetadataAtStartup) {
// The bug was related to a stale file descriptor left in the file_cache, so
// this test explicitly targets that scenario.
TEST_P(LogBlockManagerTest, TestDeleteFromContainerAfterMetadataCompaction) {
- SetEncryptionFlags(GetParam());
// Compact aggressively.
FLAGS_log_container_live_metadata_before_compact_ratio = 0.99;
// Use a single shard so that we have an accurate max cache capacity
@@ -1890,7 +1867,6 @@ TEST_P(LogBlockManagerTest,
TestDeleteFromContainerAfterMetadataCompaction) {
// will run smoothly. The directory manager will note the failed directories
// and only healthy ones are reported.
TEST_P(LogBlockManagerTest, TestOpenWithFailedDirectories) {
- SetEncryptionFlags(GetParam());
// Initialize a new directory manager with multiple directories.
bm_.reset();
vector<string> test_dirs;
@@ -1941,7 +1917,6 @@ TEST_P(LogBlockManagerTest,
TestOpenWithFailedDirectories) {
// 2) the block cannot be opened/found until close it.
// 3) the same container is not marked as available twice.
TEST_P(LogBlockManagerTest, TestFinalizeBlock) {
- SetEncryptionFlags(GetParam());
// Create 4 blocks.
vector<unique_ptr<WritableBlock>> blocks;
for (int i = 0; i < 4; i++) {
@@ -1966,7 +1941,6 @@ TEST_P(LogBlockManagerTest, TestFinalizeBlock) {
// Test available log container selection is LIFO.
TEST_P(LogBlockManagerTest, TestLIFOContainerSelection) {
- SetEncryptionFlags(GetParam());
// Create 4 blocks and 4 opened containers that are not full.
vector<unique_ptr<WritableBlock>> blocks;
for (int i = 0; i < 4; i++) {
@@ -2019,7 +1993,6 @@ TEST_P(LogBlockManagerTest, TestAbortBlock) {
}
TEST_P(LogBlockManagerTest, TestDeleteDeadContainersByDeletionTransaction) {
- SetEncryptionFlags(GetParam());
const auto TestProcess = [&] (int block_num) {
ASSERT_GT(block_num, 0);
MetricRegistry registry;
@@ -2139,7 +2112,6 @@ TEST_P(LogBlockManagerTest,
TestDeleteDeadContainersByDeletionTransaction) {
// Test for KUDU-2665 to ensure that once the container is full and has no live
// blocks but with a reference by WritableBlock, it will not be deleted.
TEST_P(LogBlockManagerTest, TestDoNotDeleteFakeDeadContainer) {
- SetEncryptionFlags(GetParam());
// Lower the max container size.
FLAGS_log_container_max_size = 64 * 1024;
@@ -2200,7 +2172,6 @@ TEST_P(LogBlockManagerTest,
TestDoNotDeleteFakeDeadContainer) {
}
TEST_P(LogBlockManagerTest, TestHalfPresentContainer) {
- SetEncryptionFlags(GetParam());
BlockId block_id;
string data_file_name;
string metadata_file_name;
diff --git a/src/kudu/util/file_cache-test.cc b/src/kudu/util/file_cache-test.cc
index ccbcf17c0..b202cb2a4 100644
--- a/src/kudu/util/file_cache-test.cc
+++ b/src/kudu/util/file_cache-test.cc
@@ -23,6 +23,7 @@
#include <memory>
#include <string>
#include <thread>
+#include <type_traits>
#include <vector>
#include <gflags/gflags_declare.h>
@@ -52,9 +53,6 @@ using std::unique_ptr;
using std::vector;
using strings::Substitute;
-namespace {
-} // namespace
-
namespace kudu {
template <class FileType>
@@ -349,12 +347,15 @@ TYPED_TEST(FileCacheTest, TestNoRecursiveDeadlock) {
class RandomAccessFileCacheTest :
public FileCacheTest<RandomAccessFile>,
public ::testing::WithParamInterface<bool> {
+ public:
+ RandomAccessFileCacheTest() {
+ SetEncryptionFlags(GetParam());
+ }
};
INSTANTIATE_TEST_SUITE_P(, RandomAccessFileCacheTest, ::testing::Values(false,
true));
TEST_P(RandomAccessFileCacheTest, TestMemoryFootprintDoesNotCrash) {
- SetEncryptionFlags(GetParam());
const string kFile = this->GetTestPath("foo");
ASSERT_OK(this->WriteTestFile(kFile, "test data"));
@@ -369,12 +370,15 @@ TEST_P(RandomAccessFileCacheTest,
TestMemoryFootprintDoesNotCrash) {
class RWFileCacheTest :
public FileCacheTest<RWFile>,
public ::testing::WithParamInterface<bool> {
+ public:
+ RWFileCacheTest() {
+ SetEncryptionFlags(GetParam());
+ }
};
INSTANTIATE_TEST_SUITE_P(, RWFileCacheTest, ::testing::Values(false, true));
TEST_P(RWFileCacheTest, TestOpenMustCreate) {
- SetEncryptionFlags(GetParam());
const string kFile1 = this->GetTestPath("foo");
const string kFile2 = this->GetTestPath("bar");
@@ -404,7 +408,6 @@ TEST_P(RWFileCacheTest, TestOpenMustCreate) {
}
TEST_P(RWFileCacheTest, TestOpenCreateOrOpen) {
- SetEncryptionFlags(GetParam());
const string kFile1 = this->GetTestPath("foo");
const string kFile2 = this->GetTestPath("bar");
@@ -429,12 +432,15 @@ TEST_P(RWFileCacheTest, TestOpenCreateOrOpen) {
class MixedFileCacheTest :
public KuduTest,
public ::testing::WithParamInterface<bool> {
+ public:
+ MixedFileCacheTest() {
+ SetEncryptionFlags(GetParam());
+ }
};
INSTANTIATE_TEST_SUITE_P(, MixedFileCacheTest, ::testing::Values(false, true));
TEST_P(MixedFileCacheTest, TestBothFileTypes) {
- SetEncryptionFlags(GetParam());
const string kFile1 = GetTestPath("foo");
const string kData1 = "test data 1";
const string kFile2 = GetTestPath("foo2");