forked from mtusi2026/mtusi2026lab4
27 lines
1.2 KiB
Python
27 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Verify RustFS outage through the API process and recover the service."""
|
|
import subprocess, time
|
|
from client import Client, arguments, run
|
|
|
|
|
|
def main():
|
|
args=arguments('Lab 4 S3 dependency outage check')
|
|
c=Client(args.base_url,args.ca_file); alice,bob,eve,chat=c.bootstrap()
|
|
subprocess.run(['docker','compose','--env-file','.env','stop','rustfs'],check=True,stdout=subprocess.DEVNULL)
|
|
try:
|
|
probe=subprocess.run(['docker','compose','--env-file','.env','exec','-T','-e','LAB_TEST_TOKEN='+alice['token'],'-e','LAB_TEST_CHAT='+chat['id'],'api','python','tests/s3_failure_probe.py'],check=True,capture_output=True,text=True)
|
|
print(probe.stdout.strip())
|
|
finally:
|
|
subprocess.run(['docker','compose','--env-file','.env','start','rustfs'],check=True,stdout=subprocess.DEVNULL)
|
|
deadline=time.monotonic()+60
|
|
while time.monotonic()<deadline:
|
|
try:
|
|
c.call('GET','/health/ready',200)
|
|
print('PASS: readiness returned 200 after RustFS restart')
|
|
return
|
|
except AssertionError:
|
|
time.sleep(1)
|
|
raise AssertionError('health did not recover after RustFS restart')
|
|
|
|
if __name__=='__main__': run(main)
|