From 8985d8f10621d7a962c1960e7a37b19e92bbcfe5 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 13 Nov 2018 11:49:33 +0200 Subject: [PATCH] Have registry tests run against both data models (old and new) --- test/registry/fixtures.py | 13 +++++++++++-- test/registry/protocols.py | 2 +- test/registry/registry_tests.py | 19 +++++++++++++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/test/registry/fixtures.py b/test/registry/fixtures.py index d0167053f..493c8c65a 100644 --- a/test/registry/fixtures.py +++ b/test/registry/fixtures.py @@ -17,6 +17,7 @@ from data.database import (close_db_filter, configure, DerivedStorageForImage, Q TagManifest, TagManifestToManifest, Manifest, ManifestLegacyImage, ManifestBlob) from data import model +from data.registry_model import registry_model from endpoints.csrf import generate_csrf_token from util.log import logfile_path @@ -132,8 +133,16 @@ def registry_server_executor(app): return executor +@pytest.fixture(params=['pre_oci_model', 'oci_model']) +def data_model(request): + return request.param + + @pytest.fixture() -def liveserver_app(app, registry_server_executor, init_db_path): +def liveserver_app(app, registry_server_executor, init_db_path, data_model): + # Change the data model being used. + registry_model.set_for_testing(data_model == 'oci_model') + registry_server_executor.apply_blueprint_to_app(app) if os.environ.get('DEBUG', 'false').lower() == 'true': @@ -150,7 +159,7 @@ def liveserver_app(app, registry_server_executor, init_db_path): @pytest.fixture() -def app_reloader(liveserver, registry_server_executor): +def app_reloader(request, liveserver, registry_server_executor): registry_server_executor.on(liveserver).reload_app(liveserver.url) yield diff --git a/test/registry/protocols.py b/test/registry/protocols.py index 439ec62b0..0dd2f9f45 100644 --- a/test/registry/protocols.py +++ b/test/registry/protocols.py @@ -122,6 +122,6 @@ class RegistryProtocol(object): expected_status = failures.get(expected_failure, expected_status) result = session.request(method, url, params=params, data=data, headers=headers, auth=auth) - msg = "Expected response %s, got %s" % (expected_status, result.status_code) + msg = "Expected response %s, got %s: %s" % (expected_status, result.status_code, result.text) assert result.status_code == expected_status, msg return result diff --git a/test/registry/registry_tests.py b/test/registry/registry_tests.py index a9aaaa4d4..d64f11aff 100644 --- a/test/registry/registry_tests.py +++ b/test/registry/registry_tests.py @@ -75,10 +75,13 @@ def test_overwrite_tag(pusher, puller, basic_images, different_images, liveserve credentials=credentials) -@pytest.mark.skipif(os.getenv('OCI_DATA_MODEL') == 'true', reason="no backfill in new model") def test_no_tag_manifests(pusher, puller, basic_images, liveserver_session, app_reloader, - liveserver, registry_server_executor): + liveserver, registry_server_executor, data_model): """ Test: Basic pull without manifests. """ + if data_model == 'oci_model': + # Skip; OCI model doesn't have tag backfill. + return + credentials = ('devtable', 'password') # Push a new repository. @@ -590,8 +593,12 @@ def test_expiration_label(label_value, expected_expiration, manifest_protocol, l 'application/vnd.docker.distribution.manifest.v2+json', ]) def test_unsupported_manifest_content_type(content_type, manifest_protocol, basic_images, - liveserver_session, app_reloader): + data_model, liveserver_session, app_reloader): """ Test: Attempt to push a manifest with an unsupported media type. """ + if data_model == 'oci_model': + # Skip; OCI requires the new manifest content types. + return + credentials = ('devtable', 'password') options = ProtocolOptions() @@ -611,8 +618,12 @@ def test_unsupported_manifest_content_type(content_type, manifest_protocol, basi [('application/vnd.foo.bar', 1)], ]) def test_unsupported_manifest_accept_headers(accept_mimetypes, manifest_protocol, basic_images, - liveserver_session, app_reloader): + data_model, liveserver_session, app_reloader): """ Test: Attempt to push a manifest with an unsupported accept headers. """ + if data_model == 'oci_model': + # Skip; OCI requires the new manifest content types. + return + credentials = ('devtable', 'password') options = ProtocolOptions()