Skip to content

Commit

Permalink
fix(testutils): Apply healthcheck to etcd container fixture too (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Jun 10, 2022
1 parent b8fcfa2 commit 2573ec2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
1 change: 1 addition & 0 deletions changes/460.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Apply health check to the test fixture for creating an etcd container
22 changes: 6 additions & 16 deletions src/ai/backend/testutils/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def etcd_container() -> Iterator[tuple[str, HostPortPair]]:
'docker', 'run', '-d',
'-p', ':2379',
'-p', ':4001',
'--health-cmd', 'etcdctl endpoint health',
'--health-interval', '2s',
'--health-start-period', '1s',
'quay.io/coreos/etcd:v3.5.4',
'/usr/local/bin/etcd',
'-advertise-client-urls', 'http://0.0.0.0:2379',
Expand All @@ -43,13 +46,7 @@ def etcd_container() -> Iterator[tuple[str, HostPortPair]]:
capture_output=True,
)
container_id = proc.stdout.decode().strip()
proc = subprocess.run(
[
'docker', 'inspect', container_id,
],
capture_output=True,
)
container_info = json.loads(proc.stdout)
container_info = wait_health_check(container_id)
host_port = int(container_info[0]['NetworkSettings']['Ports']['2379/tcp'][0]['HostPort'])
yield container_id, HostPortPair('127.0.0.1', host_port)
subprocess.run(
Expand All @@ -68,20 +65,13 @@ def redis_container() -> Iterator[tuple[str, HostPortPair]]:
'docker', 'run', '-d',
'-p', ':6379',
'--health-cmd', 'redis-cli ping',
'--health-interval', '0.3s',
'--health-start-period', '0.2s',
'--health-interval', '1s',
'--health-start-period', '0.3s',
'redis:6.2-alpine',
],
capture_output=True,
)
container_id = proc.stdout.decode().strip()
proc = subprocess.run(
[
'docker', 'inspect', container_id,
],
capture_output=True,
)
container_info = json.loads(proc.stdout)
container_info = wait_health_check(container_id)
host_port = int(container_info[0]['NetworkSettings']['Ports']['6379/tcp'][0]['HostPort'])
yield container_id, HostPortPair('127.0.0.1', host_port)
Expand Down

0 comments on commit 2573ec2

Please sign in to comment.