-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a docker registry integration test with real registry
- Loading branch information
Showing
6 changed files
with
67 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Smallest possible dockerfile, used only for building images to be tested | ||
FROM scratch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from pathlib import Path | ||
import subprocess | ||
import pytest | ||
from repo2docker.__main__ import make_r2d | ||
from repo2docker.utils import get_free_port | ||
import time | ||
import requests | ||
import secrets | ||
|
||
HERE = Path(__file__).parent | ||
|
||
@pytest.fixture | ||
def registry(): | ||
port = get_free_port() | ||
cmd = [ | ||
"docker", "run", "-it", "-p", f"{port}:5000", "registry:3.0.0-rc.3" | ||
] | ||
proc = subprocess.Popen(cmd) | ||
health_url = f'http://localhost:{port}/v2' | ||
# Wait for the registry to actually come up | ||
for i in range(10): | ||
try: | ||
resp = requests.get(health_url) | ||
if resp.status_code in (401, 200): | ||
break | ||
except requests.ConnectionError: | ||
# The service is not up yet | ||
pass | ||
time.sleep(i) | ||
else: | ||
raise TimeoutError("Test registry did not come up in time") | ||
|
||
try: | ||
yield f"localhost:{port}" | ||
finally: | ||
proc.terminate() | ||
proc.wait() | ||
|
||
|
||
def test_registry(registry): | ||
image_name = f"{registry}/{secrets.token_hex(8)}:latest" | ||
r2d = make_r2d([ | ||
"--image", image_name, | ||
"--push", "--no-run", str(HERE) | ||
]) | ||
|
||
r2d.start() | ||
|
||
proc = subprocess.run(["docker", "manifest", "inspect", "--insecure", image_name]) | ||
assert proc.returncode == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters