Add a test api to test repositories which are currenlty building.
This commit is contained in:
parent
ffc33e454c
commit
684ce83058
6 changed files with 29 additions and 7 deletions
|
@ -2,16 +2,25 @@ import logging
|
|||
|
||||
from app import app as application
|
||||
|
||||
|
||||
logging.basicConfig(**application.config['LOGGING_CONFIG'])
|
||||
|
||||
|
||||
import endpoints.index
|
||||
import endpoints.api
|
||||
import endpoints.web
|
||||
import endpoints.tags
|
||||
import endpoints.registry
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if application.config.get('INCLUDE_TEST_ENDPOINTS', False):
|
||||
logger.debug('Loading test endpoints.')
|
||||
import endpoints.test
|
||||
|
||||
# Remove this for prod config
|
||||
application.debug = True
|
||||
|
||||
logging.basicConfig(**application.config['LOGGING_CONFIG'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
application.run(port=5000, debug=True, host='0.0.0.0')
|
||||
|
|
|
@ -105,6 +105,7 @@ class DebugConfig(FlaskConfig, MailConfig, LocalStorage, SQLiteDB,
|
|||
}
|
||||
SEND_FILE_MAX_AGE_DEFAULT = 0
|
||||
POPULATE_DB_TEST_DATA = True
|
||||
INCLUDE_TEST_ENDPOINTS = True
|
||||
|
||||
|
||||
class LocalHostedConfig(FlaskConfig, MailConfig, S3Storage, RDSMySQL,
|
||||
|
|
|
@ -397,6 +397,8 @@ def get_repo_builds(namespace, repository):
|
|||
'builds': [build_view(build) for build in builds]
|
||||
})
|
||||
|
||||
abort(403) # Permissions denied
|
||||
|
||||
|
||||
def role_view(repo_perm_obj):
|
||||
return {
|
||||
|
|
15
initdb.py
15
initdb.py
|
@ -5,6 +5,7 @@ import os
|
|||
import hashlib
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from flask import url_for
|
||||
|
||||
import storage
|
||||
|
||||
|
@ -95,6 +96,8 @@ def __generate_repository(user, name, description, is_public, permissions,
|
|||
|
||||
create_subtree(repo, structure, None)
|
||||
|
||||
return repo
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
initialize_db()
|
||||
|
@ -141,6 +144,12 @@ if __name__ == '__main__':
|
|||
'Shared repository, another user can write.', False,
|
||||
[(new_user_2, 'write')], (5, [], 'latest'))
|
||||
|
||||
__generate_repository(new_user_1, 'empty',
|
||||
'Empty repository with no images or tags.', False,
|
||||
[], (0, [], None))
|
||||
building = __generate_repository(new_user_1, 'building',
|
||||
'Empty repository which is building.',
|
||||
False, [], (0, [], None))
|
||||
|
||||
build = model.create_repository_build(building, '123-45-6789')
|
||||
build.build_node_id = 1
|
||||
build.phase = 'building'
|
||||
build.status_url = 'http://localhost:5000/test/build/status'
|
||||
build.save()
|
||||
|
|
Binary file not shown.
|
@ -115,12 +115,13 @@ def babysit_builder(request):
|
|||
|
||||
# wait for the job to be complete
|
||||
status_url = start_build.headers['Location']
|
||||
repository_build.phase = 'building'
|
||||
repository_build.status_url = status_url
|
||||
repository_build.save()
|
||||
|
||||
logger.debug('Waiting for job to be complete')
|
||||
status = get_status(status_url)
|
||||
while status != 'error' and status != 'completed':
|
||||
while status != 'error' and status != 'complete':
|
||||
logger.debug('Job status is: %s' % status)
|
||||
time.sleep(5)
|
||||
status = get_status(status_url)
|
||||
|
@ -129,7 +130,7 @@ def babysit_builder(request):
|
|||
if status == 'error':
|
||||
repository_build.phase = 'error'
|
||||
else:
|
||||
repository_build.phase = 'completed'
|
||||
repository_build.phase = 'complete'
|
||||
|
||||
# clean up the DO node
|
||||
logger.debug('Cleaning up DO node.')
|
||||
|
|
Reference in a new issue