(s3_connection, tmpdir_factory)
| 198 | |
| 199 | @pytest.fixture(scope='session') |
| 200 | def s3_server(s3_connection, tmpdir_factory): |
| 201 | @retry(attempts=5, delay=1, backoff=2) |
| 202 | def minio_server_health_check(address): |
| 203 | resp = urllib.request.urlopen(f"http://{address}/minio/health/live") |
| 204 | assert resp.getcode() == 200 |
| 205 | |
| 206 | tmpdir = tmpdir_factory.getbasetemp() |
| 207 | host, port, access_key, secret_key = s3_connection |
| 208 | |
| 209 | address = f'{host}:{port}' |
| 210 | env = os.environ.copy() |
| 211 | env.update({ |
| 212 | 'MINIO_ACCESS_KEY': access_key, |
| 213 | 'MINIO_SECRET_KEY': secret_key |
| 214 | }) |
| 215 | |
| 216 | args = ['minio', '--compat', 'server', '--quiet', '--address', |
| 217 | address, tmpdir] |
| 218 | proc = None |
| 219 | try: |
| 220 | proc = subprocess.Popen(args, env=env) |
| 221 | except OSError: |
| 222 | pytest.skip('`minio` command cannot be located') |
| 223 | else: |
| 224 | # Wait for the server to startup before yielding |
| 225 | minio_server_health_check(address) |
| 226 | |
| 227 | yield { |
| 228 | 'connection': s3_connection, |
| 229 | 'process': proc, |
| 230 | 'tempdir': tmpdir |
| 231 | } |
| 232 | finally: |
| 233 | if proc is not None: |
| 234 | proc.kill() |
| 235 | proc.wait() |
| 236 | |
| 237 | |
| 238 | @pytest.fixture(scope='session') |
nothing calls this directly
no test coverage detected