Have registry tests run against both data models (old and new)

This commit is contained in:
Joseph Schorr 2018-11-13 11:49:33 +02:00
parent 849e613386
commit 8985d8f106
3 changed files with 27 additions and 7 deletions

View file

@ -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

View file

@ -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

View file

@ -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()