Skip to content

Commit bdbda3f

Browse files
committed
Skip only arrow-s3fs-tests and arrow-s3fs-module-tests that require minio if minIO is not available but run the rest of the tests that don't require minio
1 parent 1c84deb commit bdbda3f

6 files changed

Lines changed: 40 additions & 18 deletions

File tree

.github/workflows/cpp_extra.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@ jobs:
340340
ARROW_TEST_DATA: ${{ github.workspace }}/testing/data
341341
PARQUET_TEST_DATA: ${{ github.workspace }}/cpp/submodules/parquet-testing/data
342342
run: |
343-
# MinIO is required
344-
exclude_tests="arrow-s3fs-test"
345343
# unstable
346344
exclude_tests="${exclude_tests}|arrow-acero-asof-join-node-test"
347345
exclude_tests="${exclude_tests}|arrow-acero-hash-join-node-test"

ci/scripts/cpp_test.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ fi
5050
if ! type storage-testbench >/dev/null 2>&1; then
5151
exclude_tests+=("arrow-gcsfs-test")
5252
fi
53-
if ! type minio >/dev/null 2>&1; then
54-
exclude_tests+=("arrow-s3fs-test")
55-
fi
5653
case "$(uname)" in
5754
Linux)
5855
n_jobs=$(nproc)

cpp/src/arrow/filesystem/s3_test_util.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,15 @@ void MinioTestEnvironment::SetUp() {
192192
MakeReadaheadGenerator(std::move(impl_->server_generator_), pool->GetCapacity());
193193
}
194194

195+
bool MinioTestEnvironment::IsAvailable() {
196+
if (!checked_) {
197+
::arrow::util::Process process;
198+
available_ = process.SetExecutable(kMinioExecutableName).ok();
199+
checked_ = true;
200+
}
201+
return available_;
202+
}
203+
195204
Result<std::shared_ptr<MinioTestServer>> MinioTestEnvironment::GetOneServer() {
196205
return impl_->server_generator_().result();
197206
}

cpp/src/arrow/filesystem/s3_test_util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ class MinioTestEnvironment : public ::testing::Environment {
7474

7575
Result<std::shared_ptr<MinioTestServer>> GetOneServer();
7676

77+
bool IsAvailable();
78+
79+
private:
80+
bool checked_ = false;
81+
bool available_ = false;
82+
7783
protected:
7884
struct Impl;
7985
std::unique_ptr<Impl> impl_;

cpp/src/arrow/filesystem/s3fs_module_test.cc

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ MinioTestEnvironment* GetMinioEnv() {
5555
return ::arrow::internal::checked_cast<MinioTestEnvironment*>(minio_env);
5656
}
5757

58+
class S3ModuleTest : public ::testing::Test {
59+
protected:
60+
void SetUp() override {
61+
if (!GetMinioEnv()->IsAvailable()) {
62+
GTEST_SKIP() << "Minio executable not found, skipping tests";
63+
}
64+
ASSERT_OK_AND_ASSIGN(minio_, GetMinioEnv()->GetOneServer());
65+
}
66+
std::shared_ptr<MinioTestServer> minio_;
67+
};
68+
5869
class RegistrationTestEnvironment : public ::testing::Environment {
5970
public:
6071
void SetUp() override {
@@ -68,12 +79,10 @@ class RegistrationTestEnvironment : public ::testing::Environment {
6879

6980
auto* lib_env = ::testing::AddGlobalTestEnvironment(new RegistrationTestEnvironment);
7081

71-
TEST(S3Test, FromUri) {
72-
ASSERT_OK_AND_ASSIGN(auto minio, GetMinioEnv()->GetOneServer());
73-
82+
TEST_F(S3ModuleTest, FromUri) {
7483
std::string path;
75-
ASSERT_OK_AND_ASSIGN(auto fs, FileSystemFromUri("s3://" + minio->access_key() + ":" +
76-
minio->secret_key() +
84+
ASSERT_OK_AND_ASSIGN(auto fs, FileSystemFromUri("s3://" + minio_->access_key() + ":" +
85+
minio_->secret_key() +
7786
"@bucket/somedir/subdir/subfile",
7887
&path));
7988

@@ -83,12 +92,11 @@ TEST(S3Test, FromUri) {
8392
"&allow_bucket_creation=0&allow_bucket_deletion=0");
8493
}
8594

86-
TEST(S3Test, FromUriAndOptionsCredentials) {
87-
ASSERT_OK_AND_ASSIGN(auto minio, GetMinioEnv()->GetOneServer());
95+
TEST_F(S3ModuleTest, FromUriAndOptionsCredentials) {
8896
std::string path;
8997
FileSystemFactoryOptions options{
90-
{"access_key", std::string(minio->access_key())},
91-
{"secret_key", std::string(minio->secret_key())},
98+
{"access_key", std::string(minio_->access_key())},
99+
{"secret_key", std::string(minio_->secret_key())},
92100
};
93101
// Credentials supplied via options, NOT in the URI.
94102
ASSERT_OK_AND_ASSIGN(
@@ -111,11 +119,10 @@ class NoopRetryStrategy : public S3RetryStrategy {
111119
};
112120
} // namespace
113121

114-
TEST(S3Test, FromUriAndOptionsRetryStrategy) {
115-
ASSERT_OK_AND_ASSIGN(auto minio, GetMinioEnv()->GetOneServer());
122+
TEST_F(S3ModuleTest, FromUriAndOptionsRetryStrategy) {
116123
FileSystemFactoryOptions options{
117-
{"access_key", std::string(minio->access_key())},
118-
{"secret_key", std::string(minio->secret_key())},
124+
{"access_key", std::string(minio_->access_key())},
125+
{"secret_key", std::string(minio_->secret_key())},
119126
{"retry_strategy",
120127
std::shared_ptr<S3RetryStrategy>(std::make_shared<NoopRetryStrategy>())},
121128
};

cpp/src/arrow/filesystem/s3fs_test.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ class S3TestMixin : public AwsTestMixin {
192192
public:
193193
void SetUp() override {
194194
AwsTestMixin::SetUp();
195+
if (!GetMinioEnv(enable_tls_)->IsAvailable()) {
196+
GTEST_SKIP() << "Minio executable not found, skipping tests";
197+
}
195198

196199
// Starting the server may fail, for example if the generated port number
197200
// was "stolen" by another process. Run a dummy S3 operation to make sure it
@@ -624,6 +627,7 @@ class TestS3FS : public S3TestMixin {
624627
public:
625628
void SetUp() override {
626629
S3TestMixin::SetUp();
630+
if (IsSkipped()) return;
627631
// Most tests will create buckets
628632
options_.allow_bucket_creation = true;
629633
options_.allow_bucket_deletion = true;
@@ -1777,6 +1781,7 @@ class TestS3FSGeneric : public S3TestMixin, public GenericFileSystemTest {
17771781
public:
17781782
void SetUp() override {
17791783
S3TestMixin::SetUp();
1784+
if (IsSkipped()) return;
17801785
// Set up test bucket
17811786
{
17821787
Aws::S3::Model::CreateBucketRequest req;

0 commit comments

Comments
 (0)