Skip to content

Commit 1495f2c

Browse files
committed
change: use zot image
1 parent 9ffc317 commit 1495f2c

4 files changed

Lines changed: 70 additions & 49 deletions

File tree

tests/conftest.py

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -600,46 +600,27 @@ def oci_registry_pod_with_minio(
600600
{
601601
"args": request.param.get("args"),
602602
"env": [
603+
{"name": "ZOT_STORAGE_STORAGEDRIVER_NAME", "value": OCIRegistry.Storage.STORAGE_DRIVER},
603604
{
604-
"name": "REGISTRY_STORAGE",
605-
"value": "s3",
605+
"name": "ZOT_STORAGE_STORAGEDRIVER_ROOTDIRECTORY",
606+
"value": OCIRegistry.Storage.STORAGE_DRIVER_ROOT_DIRECTORY,
606607
},
608+
{"name": "ZOT_STORAGE_STORAGEDRIVER_BUCKET", "value": MinIo.Buckets.MODELMESH_EXAMPLE_MODELS},
609+
{"name": "ZOT_STORAGE_STORAGEDRIVER_REGION", "value": OCIRegistry.Storage.STORAGE_DRIVER_REGION},
610+
{"name": "ZOT_STORAGE_STORAGEDRIVER_REGIONENDPOINT", "value": f"http://{minio_endpoint}"},
611+
{"name": "ZOT_STORAGE_STORAGEDRIVER_ACCESSKEY", "value": MinIo.Credentials.ACCESS_KEY_VALUE},
612+
{"name": "ZOT_STORAGE_STORAGEDRIVER_SECRETKEY", "value": MinIo.Credentials.SECRET_KEY_VALUE},
607613
{
608-
"name": "REGISTRY_STORAGE_S3_BUCKET",
609-
"value": MinIo.Buckets.MODELMESH_EXAMPLE_MODELS,
614+
"name": "ZOT_STORAGE_STORAGEDRIVER_SECURE",
615+
"value": OCIRegistry.Storage.STORAGE_STORAGEDRIVER_SECURE,
610616
},
611617
{
612-
"name": "REGISTRY_STORAGE_S3_ACCESSKEY",
613-
"value": MinIo.Credentials.ACCESS_KEY_VALUE,
614-
},
615-
{
616-
"name": "REGISTRY_STORAGE_S3_SECRETKEY",
617-
"value": MinIo.Credentials.SECRET_KEY_VALUE,
618-
},
619-
{
620-
"name": "REGISTRY_STORAGE_S3_REGIONENDPOINT",
621-
"value": f"http://{minio_endpoint}",
622-
},
623-
{
624-
"name": "REGISTRY_STORAGE_S3_FORCEPATHSTYLE",
625-
"value": "true",
626-
},
627-
{
628-
"name": "REGISTRY_STORAGE_S3_SECURE",
629-
"value": "false",
630-
},
631-
{
632-
"name": "REGISTRY_STORAGE_S3_REGION",
633-
"value": "us-east-1",
634-
},
635-
{
636-
"name": "REGISTRY_STORAGE_DELETE_ENABLED",
637-
"value": "true",
638-
},
639-
{
640-
"name": "REGISTRY_VALIDATION_DISABLED",
641-
"value": "true",
618+
"name": "ZOT_STORAGE_STORAGEDRIVER_FORCEPATHSTYLE",
619+
"value": OCIRegistry.Storage.STORAGE_STORAGEDRIVER_FORCEPATHSTYLE,
642620
},
621+
{"name": "ZOT_HTTP_ADDRESS", "value": OCIRegistry.Metadata.DEFAULT_HTTP_ADDRESS},
622+
{"name": "ZOT_HTTP_PORT", "value": str(OCIRegistry.Metadata.DEFAULT_PORT)},
623+
{"name": "ZOT_LOG_LEVEL", "value": "info"},
643624
],
644625
"image": request.param.get("image", OCIRegistry.PodConfig.REGISTRY_IMAGE),
645626
"name": OCIRegistry.Metadata.NAME,
@@ -649,6 +630,18 @@ def oci_registry_pod_with_minio(
649630
"runAsNonRoot": True,
650631
"seccompProfile": {"type": "RuntimeDefault"},
651632
},
633+
"volumeMounts": [
634+
{
635+
"name": "zot-data",
636+
"mountPath": "/var/lib/registry",
637+
}
638+
],
639+
}
640+
],
641+
volumes=[
642+
{
643+
"name": "zot-data",
644+
"emptyDir": {},
652645
}
653646
],
654647
label=pod_labels,

tests/model_registry/async_job/test_basic_oci_registry.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import json
23

34
from ocp_resources.route import Route
45

@@ -26,7 +27,10 @@
2627
)
2728
@pytest.mark.usefixtures("minio_pod", "oci_registry_pod_with_minio", "oci_registry_route")
2829
class TestOciRegistry:
29-
"""Test OCI registry deployment functionality"""
30+
"""
31+
Temporary test for OCI registry deployment functionality using MinIO backend
32+
It will be replaced with a more comprehensive e2e test as part of https://issues.redhat.com/browse/RHOAISTRAT-456
33+
"""
3034

3135
def test_oci_registry_push_and_pull_operations(
3236
self,
@@ -44,13 +48,19 @@ def test_oci_registry_push_and_pull_operations(
4448

4549
blob_digest = push_blob_to_oci_registry(registry_url=registry_url, data=test_data, repo=test_repo)
4650

47-
manifest = create_manifest(blob_digest=blob_digest, data=test_data)
51+
config_data = {"architecture": "amd64", "os": "linux"}
52+
config_json = json.dumps(config_data, separators=(",", ":")).encode("utf-8")
53+
config_digest = push_blob_to_oci_registry(registry_url=registry_url, data=config_json, repo=test_repo)
54+
55+
manifest = create_manifest(
56+
blob_digest=blob_digest, config_json=config_json, config_digest=config_digest, data=test_data
57+
)
4858

4959
push_manifest_to_oci_registry(registry_url=registry_url, manifest=manifest, repo=test_repo, tag=test_tag)
5060

51-
manifest = pull_manifest_from_oci_registry(registry_url=registry_url, repo=test_repo, tag=test_tag)
61+
manifest_get = pull_manifest_from_oci_registry(registry_url=registry_url, repo=test_repo, tag=test_tag)
5262

53-
assert manifest["schemaVersion"] == 2
54-
assert manifest["config"]["digest"] == blob_digest
55-
assert len(manifest["layers"]) == 1
56-
assert manifest["layers"][0]["digest"] == blob_digest
63+
assert manifest_get["schemaVersion"] == 2
64+
assert manifest_get["config"]["digest"] == config_digest
65+
assert len(manifest_get["layers"]) == 1
66+
assert manifest_get["layers"][0]["digest"] == blob_digest

tests/model_registry/async_job/utils.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88

99

1010
def push_blob_to_oci_registry(registry_url: str, data: bytes, repo: str = "test/simple-artifact") -> str:
11-
"""Push a blob to an OCI registry."""
11+
"""
12+
Push a blob to an OCI registry.
13+
https://specs.opencontainers.org/distribution-spec/?v=v1.0.0#pushing-blobs
14+
POST to /v2/<repo>/blobs/uploads/ in order to initiate the upload
15+
The response will contain a Location header that contains the upload URL
16+
PUT to the Location URL with the data to be uploaded
17+
"""
18+
1219
blob_digest = f"sha256:{hashlib.sha256(data).hexdigest()}"
1320

1421
LOGGER.info(f"Pushing blob with digest: {blob_digest}")
@@ -19,19 +26,24 @@ def push_blob_to_oci_registry(registry_url: str, data: bytes, repo: str = "test/
1926

2027
upload_location = upload_response.headers.get("Location")
2128
LOGGER.info(f"Upload location: {upload_location}")
22-
upload_url = f"{upload_location}&digest={blob_digest}"
29+
base_url = f"{registry_url}{upload_location}"
30+
upload_url = f"{base_url}?digest={blob_digest}"
2331
response = requests.put(url=upload_url, data=data, headers={"Content-Type": "application/octet-stream"}, timeout=10)
24-
LOGGER.info(f"Blob upload completion: {response.status_code}")
2532
assert response.status_code == 201, f"Failed to upload blob: {response.status_code}"
2633
return blob_digest
2734

2835

29-
def create_manifest(blob_digest: str, data: bytes) -> bytes:
36+
def create_manifest(blob_digest: str, config_json: str, config_digest: str, data: bytes) -> bytes:
3037
"""Create a manifest for an OCI registry."""
38+
3139
manifest = {
3240
"schemaVersion": 2,
3341
"mediaType": "application/vnd.oci.image.manifest.v1+json",
34-
"config": {"mediaType": "application/vnd.oci.image.config.v1+json", "size": len(data), "digest": blob_digest},
42+
"config": {
43+
"mediaType": "application/vnd.oci.image.config.v1+json",
44+
"size": len(config_json),
45+
"digest": config_digest,
46+
},
3547
"layers": [{"mediaType": "application/vnd.oci.image.layer.v1.tar", "size": len(data), "digest": blob_digest}],
3648
}
3749

@@ -46,7 +58,6 @@ def push_manifest_to_oci_registry(registry_url: str, manifest: bytes, repo: str,
4658
headers={"Content-Type": "application/vnd.oci.image.manifest.v1+json"},
4759
timeout=10,
4860
)
49-
LOGGER.info(f"Manifest push: {response.status_code}")
5061
assert response.status_code == 201, f"Failed to push manifest: {response.status_code}"
5162

5263

utilities/constants.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,17 +250,24 @@ class OCIRegistry:
250250
class Metadata:
251251
NAME: str = "oci-registry"
252252
DEFAULT_PORT: int = 5000
253-
DEFAULT_ENDPOINT: str = f"{Protocols.HTTP}://{NAME}:{DEFAULT_PORT}"
253+
DEFAULT_HTTP_ADDRESS: str = "0.0.0.0"
254254

255255
class PodConfig:
256-
REGISTRY_IMAGE: str = "docker.io/registry:2"
256+
REGISTRY_IMAGE: str = "ghcr.io/project-zot/zot-linux-amd64:v2.1.7"
257257
REGISTRY_BASE_CONFIG: dict[str, Any] = {
258258
"args": None,
259259
"labels": {
260260
"maistra.io/expose-route": "true",
261261
},
262262
}
263263

264+
class Storage:
265+
STORAGE_DRIVER: str = "s3"
266+
STORAGE_DRIVER_ROOT_DIRECTORY: str = "/registry"
267+
STORAGE_DRIVER_REGION: str = "us-east-1"
268+
STORAGE_STORAGEDRIVER_SECURE: str = "false"
269+
STORAGE_STORAGEDRIVER_FORCEPATHSTYLE: str = "true"
270+
264271

265272
class MinIo:
266273
class Metadata:

0 commit comments

Comments
 (0)