Merge pull request #1502 from coreos-inc/image-replication

Enable storage replication for V2 and add backfill tool
This commit is contained in:
josephschorr 2016-06-02 15:02:53 -04:00
commit cad8746f9d
6 changed files with 93 additions and 12 deletions

View file

@ -12,14 +12,14 @@ import gpgme
import Crypto.Random
from cachetools import lru_cache
from flask import request, jsonify
from flask import request, jsonify, abort
from flask.blueprints import Blueprint
from flask.ext.testing import LiveServerTestCase
from cryptography.x509 import load_pem_x509_certificate
from cryptography.hazmat.backends import default_backend
from app import app, storage
from data.database import close_db_filter, configure, DerivedStorageForImage
from data.database import close_db_filter, configure, DerivedStorageForImage, QueueItem, Image
from data import model
from endpoints.v1 import v1_bp
from endpoints.v2 import v2_bp
@ -75,6 +75,13 @@ def set_fakestorage_directdownload(enabled):
return 'OK'
@testbp.route('/storagerepentry/<image_id>', methods=['GET'])
def get_storage_replication_entry(image_id):
image = Image.get(docker_image_id=image_id)
QueueItem.select().where(QueueItem.queue_name ** ('%' + image.storage.uuid + '%')).get()
return 'OK'
@testbp.route('/feature/<feature_name>', methods=['POST'])
def set_feature(feature_name):
import features
@ -1041,12 +1048,37 @@ class RegistryTestsMixin(object):
self.do_pull('', 'newrepo', 'devtable', 'password')
self.do_pull('library', 'newrepo', 'devtable', 'password')
def test_library_disabled(self):
with TestFeature(self, 'LIBRARY_SUPPORT', False):
self.do_push('library', 'newrepo', 'devtable', 'password')
self.do_pull('library', 'newrepo', 'devtable', 'password')
def test_image_replication(self):
with TestFeature(self, 'STORAGE_REPLICATION', True):
images = [
{
'id': 'baseid',
'contents': 'The base image',
},
{
'id': 'latestid',
'contents': 'The latest image',
'unicode': u'the Pawe\xc5\x82 Kami\xc5\x84ski image',
'parent': 'baseid',
},
]
# Push a new repository.
self.do_push('public', 'newrepo', 'public', 'password', images=images)
# Ensure that we have a storage replication entry for each image pushed.
self.conduct('GET', '/__test/storagerepentry/baseid', expected_code=200)
self.conduct('GET', '/__test/storagerepentry/latestid', expected_code=200)
class V1RegistryTests(V1RegistryPullMixin, V1RegistryPushMixin, RegistryTestsMixin,
RegistryTestCaseMixin, LiveServerTestCase):
""" Tests for V1 registry. """