def run_keep_proxy(auth): stop_keep_proxy() if not os.path.exists(TEST_TMPDIR): os.mkdir(TEST_TMPDIR) os.environ["ARVADOS_API_HOST"] = "127.0.0.1:3000" os.environ["ARVADOS_API_HOST_INSECURE"] = "true" os.environ["ARVADOS_API_TOKEN"] = fixture( "api_client_authorizations")[auth]["api_token"] kp0 = subprocess.Popen([ "keepproxy", "-pid={}/keepproxy.pid".format(TEST_TMPDIR), "-listen=:{}".format(25101) ]) authorize_with("admin") api = arvados.api('v1', cache=False) api.keep_services().create( body={ "keep_service": { "service_host": "localhost", "service_port": 25101, "service_type": "proxy" } }).execute() os.environ["ARVADOS_KEEP_PROXY"] = "http://localhost:25101"
def run_keep_proxy(auth): stop_keep_proxy() cwd = os.getcwd() os.chdir(os.path.join(MY_DIRNAME, KEEP_SERVER_DIR)) if os.environ.get('GOPATH') == None: os.environ["GOPATH"] = os.getcwd() else: os.environ["GOPATH"] = os.getcwd() + ":" + os.environ["GOPATH"] subprocess.call(["./go.sh", "install", "arvados.org/keepproxy"]) if not os.path.exists("tmp"): os.mkdir("tmp") os.environ["ARVADOS_API_HOST"] = "127.0.0.1:3001" os.environ["ARVADOS_API_HOST_INSECURE"] = "true" os.environ["ARVADOS_API_TOKEN"] = fixture("api_client_authorizations")[auth]["api_token"] kp0 = subprocess.Popen(["bin/keepproxy", "-pid=tmp/keepproxy.pid", "-listen=:{}".format(25101)]) authorize_with("admin") api = arvados.api('v1', cache=False) api.keep_services().create(body={"keep_service": {"service_host": "localhost", "service_port": 25101, "service_type": "proxy"} }).execute() arvados.config.settings()["ARVADOS_KEEP_PROXY"] = "http://localhost:25101" os.chdir(cwd)
def run_keep(blob_signing_key=None, enforce_permissions=False): stop_keep() if not os.path.exists(TEST_TMPDIR): os.mkdir(TEST_TMPDIR) keep_args = {} if blob_signing_key: with open(os.path.join(TEST_TMPDIR, "keep.blob_signing_key"), "w") as f: keep_args['--permission-key-file'] = f.name f.write(blob_signing_key) if enforce_permissions: keep_args['--enforce-permissions'] = 'true' _start_keep(0, keep_args) _start_keep(1, keep_args) os.environ["ARVADOS_API_HOST"] = "127.0.0.1:3000" os.environ["ARVADOS_API_HOST_INSECURE"] = "true" authorize_with("admin") api = arvados.api('v1', cache=False) for d in api.keep_services().list().execute()['items']: api.keep_services().delete(uuid=d['uuid']).execute() for d in api.keep_disks().list().execute()['items']: api.keep_disks().delete(uuid=d['uuid']).execute() s1 = api.keep_services().create( body={ "keep_service": { "service_host": "localhost", "service_port": 25107, "service_type": "disk" } }).execute() s2 = api.keep_services().create( body={ "keep_service": { "service_host": "localhost", "service_port": 25108, "service_type": "disk" } }).execute() api.keep_disks().create(body={ "keep_disk": { "keep_service_uuid": s1["uuid"] } }).execute() api.keep_disks().create(body={ "keep_disk": { "keep_service_uuid": s2["uuid"] } }).execute()
def run_keep(blob_signing_key=None, enforce_permissions=False): stop_keep() cwd = os.getcwd() os.chdir(os.path.join(MY_DIRNAME, KEEP_SERVER_DIR)) if os.environ.get('GOPATH') == None: os.environ["GOPATH"] = os.getcwd() else: os.environ["GOPATH"] = os.getcwd() + ":" + os.environ["GOPATH"] subprocess.call(["./go.sh", "install", "keep"]) if not os.path.exists("tmp"): os.mkdir("tmp") keep_args = {} if blob_signing_key: with open("tmp/keep.blob_signing_key", "w") as f: f.write(blob_signing_key) keep_args['--permission-key-file'] = 'tmp/keep.blob_signing_key' if enforce_permissions: keep_args['--enforce-permissions'] = 'true' _start_keep(0, keep_args) _start_keep(1, keep_args) os.environ["ARVADOS_API_HOST"] = "127.0.0.1:3001" os.environ["ARVADOS_API_HOST_INSECURE"] = "true" authorize_with("admin") api = arvados.api('v1', cache=False) for d in api.keep_services().list().execute()['items']: api.keep_services().delete(uuid=d['uuid']).execute() for d in api.keep_disks().list().execute()['items']: api.keep_disks().delete(uuid=d['uuid']).execute() s1 = api.keep_services().create(body={"keep_service": {"service_host": "localhost", "service_port": 25107, "service_type": "disk"} }).execute() s2 = api.keep_services().create(body={"keep_service": {"service_host": "localhost", "service_port": 25108, "service_type": "disk"} }).execute() api.keep_disks().create(body={"keep_disk": {"keep_service_uuid": s1["uuid"] } }).execute() api.keep_disks().create(body={"keep_disk": {"keep_service_uuid": s2["uuid"] } }).execute() os.chdir(cwd)