From: Alex Ainscow Date: Fri, 27 Feb 2026 22:07:22 +0000 (+0000) Subject: Make store_test_fixture create a random dir. X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=110a0160e5d882eae128e264d169cd79662ddcfc;p=ceph.git Make store_test_fixture create a random dir. Signed-off-by: Alex Ainscow --- diff --git a/src/test/objectstore/store_test_fixture.cc b/src/test/objectstore/store_test_fixture.cc index 62a199ceaeb9..fc43148621c0 100644 --- a/src/test/objectstore/store_test_fixture.cc +++ b/src/test/objectstore/store_test_fixture.cc @@ -34,13 +34,16 @@ static void rm_r(const string& path) void StoreTestFixture::SetUp() { - - int r = ::mkdir(data_dir.c_str(), 0777); - if (r < 0) { - r = -errno; - cerr << __func__ << ": unable to create " << data_dir << ": " << cpp_strerror(r) << std::endl; + // Create a unique temporary directory for this fixture instance so that + // tests can safely run in parallel without colliding on the same path. + std::string tmpl = type + ".test_temp_dir.XXXXXX"; + char* tmp = ::mkdtemp(tmpl.data()); + if (!tmp) { + int r = -errno; + cerr << __func__ << ": mkdtemp(" << tmpl << ") failed: " << cpp_strerror(r) << std::endl; + ASSERT_TRUE(tmp); } - ASSERT_EQ(0, r); + data_dir = tmp; store.reset(nullptr); store = ObjectStore::create(g_ceph_context, type, diff --git a/src/test/objectstore/store_test_fixture.h b/src/test/objectstore/store_test_fixture.h index afde3d3ec725..0f28b169ac6c 100644 --- a/src/test/objectstore/store_test_fixture.h +++ b/src/test/objectstore/store_test_fixture.h @@ -13,14 +13,16 @@ class StoreTestFixture : virtual public ::testing::Test { ConfigProxy* conf = nullptr; protected: - const std::string data_dir; + // Unique per-instance temp directory, set in SetUp() via mkdtemp. + // Using a unique directory makes it safe to run tests in parallel. + std::string data_dir; public: std::unique_ptr store; ObjectStore::CollectionHandle ch; explicit StoreTestFixture(const std::string& type) - : type(type), data_dir(type + ".test_temp_dir") + : type(type) {} void SetUp() override;