From 684ce83058f35bf19b0f2dd6b3df3c45f658398b Mon Sep 17 00:00:00 2001 From: yackob03 Date: Fri, 25 Oct 2013 15:47:34 -0400 Subject: [PATCH] Add a test api to test repositories which are currenlty building. --- application.py | 13 +++++++++++-- config.py | 1 + endpoints/api.py | 2 ++ initdb.py | 15 ++++++++++++--- test/data/test.db | Bin 77824 -> 77824 bytes workers/dockerfilebuild.py | 5 +++-- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/application.py b/application.py index d8d29a177..2244902c1 100644 --- a/application.py +++ b/application.py @@ -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') diff --git a/config.py b/config.py index 1aab5b5fe..a51e2700f 100644 --- a/config.py +++ b/config.py @@ -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, diff --git a/endpoints/api.py b/endpoints/api.py index a8b3c59c9..d56cd12f4 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -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 { diff --git a/initdb.py b/initdb.py index 562a29e16..79519ee7f 100644 --- a/initdb.py +++ b/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)) \ No newline at end of file + 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() diff --git a/test/data/test.db b/test/data/test.db index 48de7babe0ffc6e2660afbbce0d78e75f59a6781..32075f2bdf9f616e443e970241a748215068c41c 100644 GIT binary patch delta 414 zcmZp8z|!!5Wr8%L{6raNM){2iAB{}?@;&p6f`cm@4YC6Cv$70I%G1*_^@>dj^aG0Y za}D!?!YiGeeLT`UbCO-NlOszqLd(4LCZD&Km^{x|(zGNu-^eW^%ET$Dz`w}ZO}{Wy z-!0PL$R{bsG&HHqI6E)U)hNs@&DkW%z$M5dE6df7wG|s1gRCrLa7t=fNn%n?YEo%tPD*B8I+JT|K}n@TQEEYcab`(= zQKdq8MrLw`LT0f7Ov&cYMZ&CX4Ghc;%r`dkRFp7_in0KWLN{si)apVO9$f|oUB*Vn z*G!pAS0_43Z&qkn$;7E4&n~X5&Dg>|`BKw`&Fh;(dDs}4_b@Q;*(}JiiP_JIk)452 znNv2J&CtkL*ThuU%-q5fW_w0SNr9EVeolUJVopYWafy|wfq{X3NosM4K3Iu_i!7M%j%CAB{{)JTePB&D`BnoilU1f>ZO;JwjcbN;AVF{ZsV9 zgN=hi{rubu^L!HBA`6n!oP)xus!~FOC!e>Lm^{x|(ljHz+$Yt&_>C`n8&-u$^pn3b)Wf%yh=^Jbok5@t~b1_mJ(pm`|9ZJt_P$ikz* zz@Wfb!g!AZ;@aAbEsB%xH(lUO$xP2INzBPlPEE{<-@Lv#lxH!E M1jlBU8Goh&0HniiZU6uP diff --git a/workers/dockerfilebuild.py b/workers/dockerfilebuild.py index 4fbc48cac..d04f98ced 100644 --- a/workers/dockerfilebuild.py +++ b/workers/dockerfilebuild.py @@ -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.')