Skip to content

Commit 82a5496

Browse files
committed
fix
1 parent f030b22 commit 82a5496

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/Core/ServerUUID.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,9 @@ UUID loadServerUUID(const fs::path & server_uuid_file, Poco::Logger * log)
6868
}
6969
}
7070

71+
void ServerUUID::setRandomForUnitTests()
72+
{
73+
server_uuid = UUIDHelpers::generateV4();
74+
}
75+
7176
}

src/Core/ServerUUID.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class ServerUUID
1919

2020
/// Loads server UUID from file or creates new one. Should be called on daemon startup.
2121
static void load(const fs::path & server_uuid_file, Poco::Logger * log);
22+
23+
static void setRandomForUnitTests();
2224
};
2325

2426
UUID loadServerUUID(const fs::path & server_uuid_file, Poco::Logger * log);

src/Interpreters/tests/gtest_filecache.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <numeric>
99
#include <thread>
1010

11+
#include <Core/ServerUUID.h>
1112
#include <Common/iota.h>
1213
#include <Common/randomSeed.h>
1314
#include <DataTypes/DataTypesNumber.h>
@@ -333,6 +334,7 @@ class FileCacheTest : public ::testing::Test
333334

334335
TEST_F(FileCacheTest, LRUPolicy)
335336
{
337+
ServerUUID::setRandomForUnitTests();
336338
DB::ThreadStatus thread_status;
337339

338340
/// To work with cache need query_id and query context.
@@ -807,6 +809,7 @@ TEST_F(FileCacheTest, LRUPolicy)
807809

808810
TEST_F(FileCacheTest, writeBuffer)
809811
{
812+
ServerUUID::setRandomForUnitTests();
810813
FileCacheSettings settings;
811814
settings.max_size = 100;
812815
settings.max_elements = 5;
@@ -938,6 +941,7 @@ static size_t readAllTemporaryData(TemporaryFileStream & stream)
938941

939942
TEST_F(FileCacheTest, temporaryData)
940943
{
944+
ServerUUID::setRandomForUnitTests();
941945
DB::FileCacheSettings settings;
942946
settings.max_size = 10_KiB;
943947
settings.max_file_segment_size = 1_KiB;
@@ -1044,6 +1048,7 @@ TEST_F(FileCacheTest, temporaryData)
10441048

10451049
TEST_F(FileCacheTest, CachedReadBuffer)
10461050
{
1051+
ServerUUID::setRandomForUnitTests();
10471052
DB::ThreadStatus thread_status;
10481053

10491054
/// To work with cache need query_id and query context.
@@ -1120,6 +1125,7 @@ TEST_F(FileCacheTest, CachedReadBuffer)
11201125

11211126
TEST_F(FileCacheTest, TemporaryDataReadBufferSize)
11221127
{
1128+
ServerUUID::setRandomForUnitTests();
11231129
/// Temporary data stored in cache
11241130
{
11251131
DB::FileCacheSettings settings;
@@ -1167,6 +1173,7 @@ TEST_F(FileCacheTest, TemporaryDataReadBufferSize)
11671173

11681174
TEST_F(FileCacheTest, SLRUPolicy)
11691175
{
1176+
ServerUUID::setRandomForUnitTests();
11701177
DB::ThreadStatus thread_status;
11711178
std::string query_id = "query_id"; /// To work with cache need query_id and query context.
11721179

0 commit comments

Comments
 (0)