From: Peter Amstutz Date: Mon, 6 Apr 2015 19:23:57 +0000 (-0400) Subject: 4685: run_test_server support for arv-git-httpd. X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/9122bc6b0f68ffe7a429cfeaea58d27523a6de8f 4685: run_test_server support for arv-git-httpd. --- diff --git a/sdk/python/tests/run_test_server.py b/sdk/python/tests/run_test_server.py index b9502f0f8e..99d66ca6c4 100644 --- a/sdk/python/tests/run_test_server.py +++ b/sdk/python/tests/run_test_server.py @@ -351,6 +351,26 @@ def run_keep_proxy(): def stop_keep_proxy(): kill_server_pid(os.path.join(TEST_TMPDIR, "keepproxy.pid"), 0) +def run_arv_git(): + stop_arv_git() + + admin_token = auth_token('admin') + env = os.environ.copy() + env['ARVADOS_API_TOKEN'] = admin_token + shutil.rmtree(os.path.join(ARVADOS_DIR, "services/api/tmp/git"), ignore_errors=True) + os.mkdir(os.path.join(ARVADOS_DIR, "services/api/tmp/git")) + argh = subprocess.Popen( + ["arv-git-httpd", + "-address=:3005", + "-repo-root=%s" % os.path.join(ARVADOS_DIR, "services/api/tmp/git"), + "-pid={}/arv-git-httpd.pid".format(TEST_TMPDIR), + ], + env=env) + +def stop_arv_git(): + kill_server_pid(os.path.join(TEST_TMPDIR, "arv-git-httpd.pid"), 0) + + def fixture(fix): '''load a fixture yaml file''' with open(os.path.join(SERVICES_SRC_DIR, 'api', "test", "fixtures", @@ -391,6 +411,7 @@ class TestCaseWithServers(unittest.TestCase): MAIN_SERVER = None KEEP_SERVER = None KEEP_PROXY_SERVER = None + ARV_GIT_SERVER = None @staticmethod def _restore_dict(src, dest): @@ -409,7 +430,8 @@ class TestCaseWithServers(unittest.TestCase): for server_kwargs, start_func, stop_func in ( (cls.MAIN_SERVER, run, reset), (cls.KEEP_SERVER, run_keep, stop_keep), - (cls.KEEP_PROXY_SERVER, run_keep_proxy, stop_keep_proxy)): + (cls.KEEP_PROXY_SERVER, run_keep_proxy, stop_keep_proxy), + (cls.ARV_GIT_SERVER, run_arv_git, stop_arv_git)): if server_kwargs is not None: start_func(**server_kwargs) cls._cleanup_funcs.append(stop_func) diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml index 1696e2c56e..d6a58f9c08 100644 --- a/services/api/config/application.default.yml +++ b/services/api/config/application.default.yml @@ -45,6 +45,8 @@ test: blob_signing_key: zfhgfenhffzltr9dixws36j1yhksjoll2grmku38mi7yxd66h5j4q9w4jzanezacp8s6q0ro3hxakfye02152hncy6zml2ed0uc user_profile_notification_address: arvados@example.com workbench_address: https://localhost:3001/ + git_repositories_dir: <%= "#{Dir.pwd}/tmp/git" %> + git_host: http://localhost:3005 common: # The prefix used for all database identifiers to identify the record as diff --git a/services/arv-git-httpd/main.go b/services/arv-git-httpd/main.go index 0e92393e29..2b585ffc93 100644 --- a/services/arv-git-httpd/main.go +++ b/services/arv-git-httpd/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "log" "os" ) @@ -10,6 +11,7 @@ type config struct { Addr string GitCommand string Root string + Pidfile string } var theConfig *config @@ -27,6 +29,12 @@ func init() { flag.StringVar(&theConfig.Root, "repo-root", cwd, "Path to git repositories.") + flag.StringVar( + &theConfig.Pidfile, + "pid", + "", + "Path to write pid file") + // MakeArvadosClient returns an error if token is unset (even // though we don't need to do anything requiring // authentication yet). We can't do this in newArvadosClient() @@ -42,7 +50,19 @@ func main() { if err := srv.Start(); err != nil { log.Fatal(err) } + + if theConfig.Pidfile != "" { + f, err := os.Create(theConfig.Pidfile) + if err != nil { + log.Fatalf("Error writing pid file (%s): %s", theConfig.Pidfile, err.Error()) + } + fmt.Fprint(f, os.Getpid()) + f.Close() + defer os.Remove(theConfig.Pidfile) + } + log.Println("Listening at", srv.Addr) + if err := srv.Wait(); err != nil { log.Fatal(err) }