Skip to content

Commit

Permalink
ARROW-14238: [Python] "could not run mc" error in test_fs.py
Browse files Browse the repository at this point in the history
The error appears to be due to an older version of mc.  This PR adds a minimum version check to ensure that we are working with a recent version of mc.  If we are not it will skip the test.

Closes #11408 from westonpace/bugfix/ARROW-14238--check-mc-version-in-test

Authored-by: Weston Pace <[email protected]>
Signed-off-by: David Li <[email protected]>
  • Loading branch information
westonpace authored and lidavidm committed Nov 16, 2021
1 parent f1fcc4f commit 690e364
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions python/pyarrow/tests/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import pathlib
import pickle
import re
import subprocess
import sys
import time
Expand Down Expand Up @@ -287,6 +288,22 @@ def _wait_for_minio_startup(mcdir, address, access_key, secret_key):
raise Exception("mc command could not connect to local minio")


def _ensure_minio_component_version(component, minimum_year):
full_args = [component, '--version']
proc = subprocess.Popen(full_args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, encoding='utf-8')
if proc.wait(10) != 0:
return False
stdout = proc.stdout.read()
pattern = component + r' version RELEASE\.(\d+)-.*'
version_match = re.search(pattern, stdout)
if version_match:
version_year = version_match.group(1)
return int(version_year) >= minimum_year
else:
return False


def _configure_limited_user(tmpdir, address, access_key, secret_key):
"""
Attempts to use the mc command to configure the minio server
Expand All @@ -298,6 +315,12 @@ def _configure_limited_user(tmpdir, address, access_key, secret_key):
(e.g. see ARROW-13685)
"""
try:
if not _ensure_minio_component_version('mc', 2021):
# mc version is too old for the capabilities we need
return False
if not _ensure_minio_component_version('minio', 2021):
# minio version is too old for the capabilities we need
return False
mcdir = os.path.join(tmpdir, 'mc')
os.mkdir(mcdir)
policy_path = os.path.join(tmpdir, 'limited-buckets-policy.json')
Expand Down

0 comments on commit 690e364

Please sign in to comment.