Check in diffs for the test db. Try to make the test db identifiers predictable.
This commit is contained in:
parent
4514f5a969
commit
3d0b165de9
71 changed files with 434170 additions and 11 deletions
|
@ -24,7 +24,7 @@ class MailConfig(object):
|
|||
|
||||
|
||||
class SQLiteDB(object):
|
||||
DB_NAME = 'test.db'
|
||||
DB_NAME = 'test/data/test.db'
|
||||
DB_CONNECTION_ARGS = {
|
||||
'threadlocals': True
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class S3Storage(object):
|
|||
|
||||
class LocalStorage(object):
|
||||
STORAGE_KIND = 'local'
|
||||
LOCAL_STORAGE_DIR = '/tmp/registry'
|
||||
LOCAL_STORAGE_DIR = 'test/data/registry'
|
||||
|
||||
|
||||
class StripeTestConfig(object):
|
||||
|
|
43
initdb.py
43
initdb.py
|
@ -1,26 +1,42 @@
|
|||
import logging
|
||||
import string
|
||||
import shutil
|
||||
import os
|
||||
import hashlib
|
||||
|
||||
from random import SystemRandom
|
||||
from datetime import datetime
|
||||
|
||||
import storage
|
||||
|
||||
from data.database import initialize_db
|
||||
from data import model
|
||||
from app import app
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
store = storage.load()
|
||||
logging.basicConfig(**app.config['LOGGING_CONFIG'])
|
||||
|
||||
|
||||
def __gen_hex_id(length=64):
|
||||
random = SystemRandom()
|
||||
return ''.join([random.choice('abcdef' + string.digits)
|
||||
for x in range(length)])
|
||||
SAMPLE_DIFFS = [
|
||||
'test/data/sample/diffs/diffs.json',
|
||||
'test/data/sample/diffs/diffs2.json',
|
||||
'test/data/sample/diffs/diffs3.json',
|
||||
]
|
||||
|
||||
|
||||
def __gen_checksum():
|
||||
return 'tarsum+sha256:' + __gen_hex_id(64)
|
||||
def __gen_checksum(image_id):
|
||||
h = hashlib.md5(image_id)
|
||||
return 'tarsum+sha256:' + h.hexdigest()
|
||||
|
||||
|
||||
global_image_num = [0]
|
||||
def __gen_image_id(repo):
|
||||
str_to_hash = "%s/%s/%s" % (repo.namespace, repo.name, global_image_num[0])
|
||||
global_image_num[0] += 1
|
||||
|
||||
h = hashlib.md5(str_to_hash)
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
def create_subtree(repo, structure, parent):
|
||||
|
@ -28,8 +44,9 @@ def create_subtree(repo, structure, parent):
|
|||
|
||||
# create the nodes
|
||||
for i in range(num_nodes):
|
||||
docker_image_id = __gen_hex_id()
|
||||
checksum = __gen_checksum()
|
||||
docker_image_id = __gen_image_id(repo)
|
||||
logger.debug('new docker id: %s' % docker_image_id)
|
||||
checksum = __gen_checksum(docker_image_id)
|
||||
|
||||
new_image = model.create_image(docker_image_id, repo)
|
||||
model.set_image_checksum(docker_image_id, repo, checksum)
|
||||
|
@ -38,6 +55,14 @@ def create_subtree(repo, structure, parent):
|
|||
repo.name, str(datetime.now()),
|
||||
'no comment', parent)
|
||||
|
||||
# Populate the diff file
|
||||
diff_path = store.image_file_diffs_path(repo.namespace, repo.name,
|
||||
docker_image_id)
|
||||
source_diff = SAMPLE_DIFFS[i % len(SAMPLE_DIFFS)]
|
||||
|
||||
with open(source_diff, 'r') as source_file:
|
||||
store.stream_write(diff_path, source_file)
|
||||
|
||||
parent = new_image
|
||||
|
||||
if last_node_tags:
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
5338
test/data/sample/diffs/diffs.json
Normal file
5338
test/data/sample/diffs/diffs.json
Normal file
File diff suppressed because it is too large
Load diff
12887
test/data/sample/diffs/diffs2.json
Normal file
12887
test/data/sample/diffs/diffs2.json
Normal file
File diff suppressed because it is too large
Load diff
16
test/data/sample/diffs/diffs3.json
Normal file
16
test/data/sample/diffs/diffs3.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"removed": [],
|
||||
"added": [
|
||||
"dev/kmsg",
|
||||
"root/.bash_history",
|
||||
"usr/sbin/policy-rc.d"
|
||||
],
|
||||
"changed": [
|
||||
"tmp",
|
||||
"dev",
|
||||
".",
|
||||
"usr",
|
||||
"root",
|
||||
"usr/sbin"
|
||||
]
|
||||
}
|
Binary file not shown.
Reference in a new issue