Update the test db to use unique uuds for images storages.
This commit is contained in:
parent
626d984fb2
commit
8a37d63e35
125 changed files with 238909 additions and 13 deletions
22
initdb.py
22
initdb.py
|
@ -8,6 +8,7 @@ from datetime import datetime, timedelta
|
|||
from email.utils import formatdate
|
||||
from peewee import (SqliteDatabase, create_model_tables, drop_model_tables,
|
||||
savepoint_sqlite)
|
||||
from uuid import UUID
|
||||
|
||||
from data.database import *
|
||||
from data import model
|
||||
|
@ -20,18 +21,6 @@ logger = logging.getLogger(__name__)
|
|||
SAMPLE_DIFFS = ['test/data/sample/diffs/diffs%s.json' % i
|
||||
for i in range(1, 10)]
|
||||
|
||||
IMAGE_UUIDS = ['ab5160d1-8fb4-4022-a135-3c4de7f6ed97',
|
||||
'4259533e-868d-4db3-9a78-fc24ffc03a2b',
|
||||
'c2c6dc6e-24d1-4f15-a616-81c41e3e3629',
|
||||
'8ec59952-8f5a-4fa0-897e-57c3337e1914',
|
||||
'08a8ab1f-4aaa-4337-88ab-5b5c71a8d492',
|
||||
'4a71f3db-cbb1-4c3b-858f-1be032b3e875',
|
||||
'd40d531a-c70c-47f9-bf5b-2a4381db2d60',
|
||||
'6fe6cebb-52b2-4036-892e-b86d6487a56b',
|
||||
'e969ff76-e87d-4ea3-8cb3-0db9b5bcb8d9',
|
||||
'2e3b616b-301f-437c-98ab-37352f444a60',
|
||||
]
|
||||
|
||||
SAMPLE_CMDS = [["/bin/bash"],
|
||||
["/bin/sh", "-c",
|
||||
"echo \"PasswordAuthentication no\" >> /etc/ssh/sshd_config"],
|
||||
|
@ -57,6 +46,13 @@ def __gen_image_id(repo, image_num):
|
|||
return h.hexdigest() + h.hexdigest()
|
||||
|
||||
|
||||
def __gen_image_uuid(repo, image_num):
|
||||
str_to_hash = "%s/%s/%s" % (repo.namespace_user.username, repo.name, image_num)
|
||||
|
||||
h = hashlib.md5(str_to_hash)
|
||||
return UUID(bytes=h.digest())
|
||||
|
||||
|
||||
global_image_num = [0]
|
||||
def __create_subtree(repo, structure, creator_username, parent):
|
||||
num_nodes, subtrees, last_node_tags = structure
|
||||
|
@ -71,7 +67,7 @@ def __create_subtree(repo, structure, creator_username, parent):
|
|||
|
||||
new_image = model.find_create_or_link_image(docker_image_id, repo, None, {}, 'local_us')
|
||||
new_image_locations = new_image.storage.locations
|
||||
new_image.storage.uuid = IMAGE_UUIDS[image_num % len(IMAGE_UUIDS)]
|
||||
new_image.storage.uuid = __gen_image_uuid(repo, image_num)
|
||||
new_image.storage.uploading = False
|
||||
new_image.storage.checksum = checksum
|
||||
new_image.storage.save()
|
||||
|
|
Reference in a new issue