Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cpp/test/reader/aligned_chunk_reader_bulk_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <atomic>
#include <chrono>
#include <cstdio>
#include <cstring>
Expand All @@ -28,6 +29,12 @@
#include <string>
#include <vector>

#ifdef _WIN32
#include <process.h>
#else
#include <unistd.h>
#endif

#include "common/allocator/alloc_base.h"
#include "common/config/config.h"
#include "common/tablet.h"
Expand Down Expand Up @@ -93,6 +100,17 @@ class AlignedBulkCopyTest : public ::testing::Test {
"_" +
std::to_string(
std::chrono::steady_clock::now().time_since_epoch().count()) +
"_" + std::to_string([] {
#ifdef _WIN32
return static_cast<uint64_t>(_getpid());
#else
return static_cast<uint64_t>(getpid());
#endif
}()) +
"_" + std::to_string([] {
static std::atomic<uint64_t> counter{0};
return counter.fetch_add(1);
}()) +
".tsfile";
std::remove(path_.c_str());
{
Expand Down
17 changes: 16 additions & 1 deletion cpp/test/reader/aligned_field_filter_regression_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <atomic>
#include <chrono>
#include <cstdio>
#include <cstring>
Expand All @@ -37,6 +38,12 @@
#include "reader/table_query_executor.h"
#include "writer/tsfile_table_writer.h"

#ifdef _WIN32
#include <process.h>
#else
#include <unistd.h>
#endif

namespace {
using namespace common;
using namespace storage;
Expand Down Expand Up @@ -70,11 +77,19 @@ class AlignedFieldFilterRegressionTest
saved_ = g_config_value_;
g_config_value_.page_writer_max_point_num_ = 3;
g_config_value_.parallel_read_enabled_ = std::get<0>(GetParam());
// Parallel CTest processes can seed from the same clock tick.
#ifdef _WIN32
const auto process_id = static_cast<uint64_t>(_getpid());
#else
const auto process_id = static_cast<uint64_t>(getpid());
#endif
static std::atomic<uint64_t> filename_counter{0};
filename_ =
"aligned_field_filter_regression_" +
std::to_string(
std::chrono::steady_clock::now().time_since_epoch().count()) +
".tsfile";
"_" + std::to_string(process_id) + "_" +
std::to_string(filename_counter.fetch_add(1)) + ".tsfile";
}
void TearDown() override {
std::remove(filename_.c_str());
Expand Down
17 changes: 16 additions & 1 deletion cpp/test/reader/block/masked_bulk_copy_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <atomic>
#include <chrono>
#include <cstdio>
#include <cstring>
Expand All @@ -33,6 +34,12 @@
#include "reader/block/single_device_tsblock_reader.h"
#include "writer/tsfile_table_writer.h"

#ifdef _WIN32
#include <process.h>
#else
#include <unistd.h>
#endif

namespace {
using namespace common;
using namespace storage;
Expand All @@ -47,11 +54,19 @@ class MaskedBulkCopyTest : public ::testing::TestWithParam<bool> {
// Source tuple: time + v + n + s + hidden + empty = 72 bytes/row.
// Each source TsBlock has 137 rows, crossing two bitmap words.
g_config_value_.tsblock_max_memory_ = 72 * 137;
// Parallel CTest processes can seed from the same clock tick.
#ifdef _WIN32
const auto process_id = static_cast<uint64_t>(_getpid());
#else
const auto process_id = static_cast<uint64_t>(getpid());
#endif
static std::atomic<uint64_t> filename_counter{0};
filename_ =
"masked_bulk_copy_" +
std::to_string(
std::chrono::steady_clock::now().time_since_epoch().count()) +
".tsfile";
"_" + std::to_string(process_id) + "_" +
std::to_string(filename_counter.fetch_add(1)) + ".tsfile";
const std::vector<ColumnSchema> columns{
{"v", INT64, UNCOMPRESSED, PLAIN, ColumnCategory::FIELD},
{"n", INT64, UNCOMPRESSED, PLAIN, ColumnCategory::FIELD},
Expand Down
17 changes: 17 additions & 0 deletions cpp/test/reader/chunk_reader_resource_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
#include <string>
#include <vector>

#ifdef _WIN32
#include <process.h>
#else
#include <unistd.h>
#endif

#include "common/allocator/alloc_base.h"
#include "common/config/config.h"
#include "common/tablet.h"
Expand Down Expand Up @@ -180,6 +186,17 @@ class AlignedReaderFailureTest : public ::testing::Test {
"_" +
std::to_string(
std::chrono::steady_clock::now().time_since_epoch().count()) +
"_" + std::to_string([] {
#ifdef _WIN32
return static_cast<uint64_t>(_getpid());
#else
return static_cast<uint64_t>(getpid());
#endif
}()) +
"_" + std::to_string([] {
static std::atomic<uint64_t> counter{0};
return counter.fetch_add(1);
}()) +
".tsfile";
WriteFile file;
int flags = O_WRONLY | O_CREAT | O_TRUNC;
Expand Down
17 changes: 16 additions & 1 deletion cpp/test/reader/table_field_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <gtest/gtest.h>

#include <atomic>
#include <chrono>
#include <cstdio>
#include <functional>
Expand All @@ -36,6 +37,12 @@
#include "reader/table_query_executor.h"
#include "writer/tsfile_table_writer.h"

#ifdef _WIN32
#include <process.h>
#else
#include <unistd.h>
#endif

namespace {
using namespace common;
using namespace storage;
Expand Down Expand Up @@ -164,11 +171,19 @@ class TableFieldFilterTest
saved_ = g_config_value_;
g_config_value_.page_writer_max_point_num_ = 3;
g_config_value_.parallel_read_enabled_ = std::get<0>(GetParam());
// Parallel CTest processes can seed from the same clock tick.
#ifdef _WIN32
const auto process_id = static_cast<uint64_t>(_getpid());
#else
const auto process_id = static_cast<uint64_t>(getpid());
#endif
static std::atomic<uint64_t> filename_counter{0};
filename_ =
"table_field_filter_" +
std::to_string(
std::chrono::steady_clock::now().time_since_epoch().count()) +
".tsfile";
"_" + std::to_string(process_id) + "_" +
std::to_string(filename_counter.fetch_add(1)) + ".tsfile";
WriteFile file;
int flags = O_WRONLY | O_CREAT | O_TRUNC;
#ifdef _WIN32
Expand Down
17 changes: 16 additions & 1 deletion cpp/test/reader/table_read_failure_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <atomic>
#include <chrono>
#include <cstdio>
#include <cstring>
Expand All @@ -42,6 +43,12 @@
#include "utils/injection.h"
#include "writer/tsfile_table_writer.h"

#ifdef _WIN32
#include <process.h>
#else
#include <unistd.h>
#endif

namespace {

class InjectionGuard {
Expand Down Expand Up @@ -106,11 +113,19 @@ class TableReadFailureTest
storage::libtsfile_init();
saved_index_degree_ = common::g_config_value_.max_degree_of_index_node_;
ASSERT_EQ(storage::set_max_degree_of_index_node(2), common::E_OK);
// Parallel CTest processes can seed from the same clock tick.
#ifdef _WIN32
const auto process_id = static_cast<uint64_t>(_getpid());
#else
const auto process_id = static_cast<uint64_t>(getpid());
#endif
static std::atomic<uint64_t> filename_counter{0};
filename_ =
"table_read_failure_" +
std::to_string(
std::chrono::steady_clock::now().time_since_epoch().count()) +
".tsfile";
"_" + std::to_string(process_id) + "_" +
std::to_string(filename_counter.fetch_add(1)) + ".tsfile";
storage::WriteFile file;
int flags = O_WRONLY | O_CREAT | O_TRUNC;
#ifdef _WIN32
Expand Down
17 changes: 17 additions & 0 deletions cpp/test/reader/timeseries_schema_codec_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <gtest/gtest.h>

#include <atomic>
#include <chrono>
#include <cstdio>
#include <random>
Expand All @@ -31,6 +32,12 @@
#include "reader/tsfile_reader.h"
#include "writer/tsfile_writer.h"

#ifdef _WIN32
#include <process.h>
#else
#include <unistd.h>
#endif

namespace storage {

// get_timeseries_schema() reports the encoding and the compressor of every
Expand Down Expand Up @@ -77,6 +84,16 @@ class TimeseriesSchemaCodecTest : public ::testing::Test {
for (int i = 0; i < length; ++i) {
s += chars[static_cast<size_t>(dis(gen))];
}
// CTest runs cases in parallel processes; two can seed from the same
// clock tick and then collide on the file name.
Comment on lines +87 to +88
#ifdef _WIN32
const auto process_id = static_cast<uint64_t>(_getpid());
#else
const auto process_id = static_cast<uint64_t>(getpid());
#endif
static std::atomic<uint64_t> filename_counter{0};
s += "_" + std::to_string(process_id) + "_" +
std::to_string(filename_counter.fetch_add(1));
return s;
}

Expand Down
Loading