}
// StartKeep is used to start keep servers
-// with keepExisting = false and enforcePermissions = false
+// with needMore = false and enforcePermissions = false
func StartKeep() {
StartKeepWithParams(false, false)
}
// StartKeepWithParams is used to start keep servers while specifying
-// keepExisting and enforcePermissions parameters.
-func StartKeepWithParams(keepExisting bool, enforcePermissions bool) {
+// needMore and enforcePermissions parameters.
+func StartKeepWithParams(needMore bool, enforcePermissions bool) {
cwd, _ := os.Getwd()
defer os.Chdir(cwd)
chdirToPythonTests()
cmdArgs := []string{"run_test_server.py", "start_keep"}
- if keepExisting {
- cmdArgs = append(cmdArgs, "--keep-existing")
+ if needMore {
+ cmdArgs = append(cmdArgs, "--need-more")
}
if enforcePermissions {
cmdArgs = append(cmdArgs, "--keep-enforce-permissions")
my_api_host = None
_cached_config = {}
-keep_existing = False
def find_server_pid(PID_PATH, wait=10):
now = time.time()
return port
-def run_keep(blob_signing_key=None, enforce_permissions=False):
- if not keep_existing:
- stop_keep()
+def run_keep(blob_signing_key=None, enforce_permissions=False, num_keep_servers=2):
+ stop_keep()
keep_args = {}
if not blob_signing_key:
for d in api.keep_disks().list().execute()['items']:
api.keep_disks().delete(uuid=d['uuid']).execute()
- start_index = 0
- end_index = 2
- if keep_existing:
- start_index = 2
- end_index = 3
- for d in range(start_index, end_index):
+ for d in range(0, num_keep_servers):
port = _start_keep(d, keep_args)
svc = api.keep_services().create(body={'keep_service': {
'uuid': 'zzzzz-bi6l4-keepdisk{:07d}'.format(d),
def stop_keep():
_stop_keep(0)
_stop_keep(1)
- # We may have created an additional keep servers when keep_existing is used
+ # We may have created an additional keep server for keep-rsync testing
_stop_keep(2)
def run_keep_proxy():
parser = argparse.ArgumentParser()
parser.add_argument('action', type=str, help="one of {}".format(actions))
parser.add_argument('--auth', type=str, metavar='FIXTURE_NAME', help='Print authorization info for given api_client_authorizations fixture')
- parser.add_argument('--keep-existing', action="store_true", help="Used to add additional keep servers, without terminating existing servers")
+ parser.add_argument('--need-more', action="store_true", help="Used to indicate need one more than the default 2 keep servers")
parser.add_argument('--keep-enforce-permissions', action="store_true", help="Enforce keep permissions")
args = parser.parse_args()
- keep_existing = args.keep_existing
+ num_keep_servers = 2
+ if args.need_more:
+ num_keep_servers = 3
if args.action not in actions:
print("Unrecognized action '{}'. Actions are: {}.".format(args.action, actions), file=sys.stderr)
elif args.action == 'stop':
stop(force=('ARVADOS_TEST_API_HOST' not in os.environ))
elif args.action == 'start_keep':
- run_keep(enforce_permissions=args.keep_enforce_permissions)
+ run_keep(enforce_permissions=args.keep_enforce_permissions, num_keep_servers=num_keep_servers)
elif args.action == 'stop_keep':
stop_keep()
elif args.action == 'start_keep_proxy':
var testKeepServicesJSON = "{ \"kind\":\"arvados#keepServiceList\", \"etag\":\"\", \"self_link\":\"\", \"offset\":null, \"limit\":null, \"items\":[ { \"href\":\"/keep_services/zzzzz-bi6l4-123456789012340\", \"kind\":\"arvados#keepService\", \"etag\":\"641234567890enhj7hzx432e5\", \"uuid\":\"zzzzz-bi6l4-123456789012340\", \"owner_uuid\":\"zzzzz-tpzed-123456789012345\", \"service_host\":\"keep0.zzzzz.arvadosapi.com\", \"service_port\":25107, \"service_ssl_flag\":false, \"service_type\":\"disk\", \"read_only\":false }, { \"href\":\"/keep_services/zzzzz-bi6l4-123456789012341\", \"kind\":\"arvados#keepService\", \"etag\":\"641234567890enhj7hzx432e5\", \"uuid\":\"zzzzz-bi6l4-123456789012341\", \"owner_uuid\":\"zzzzz-tpzed-123456789012345\", \"service_host\":\"keep0.zzzzz.arvadosapi.com\", \"service_port\":25108, \"service_ssl_flag\":false, \"service_type\":\"disk\", \"read_only\":false } ], \"items_available\":2 }"
// Testing keep-rsync needs two sets of keep services: src and dst.
-// The test setup hence tweaks keep-rsync initialization to achieve this.
-// First invoke setupKeepClients and then invoke StartKeepWithParams
-// to create the keep servers to be used as destination.
-func setupRsync(c *C, enforcePermissions, setupDstServers bool, replications int) {
+// The test setup hence creates 3 servers instead of the default 2,
+// and uses the first 2 as src and the 3rd as dst keep servers.
+func setupRsync(c *C, enforcePermissions, updateDstReplications bool, replications int) {
// srcConfig
var srcConfig arvadosclient.APIConfig
srcConfig.APIHost = os.Getenv("ARVADOS_API_HOST")
// Start API and Keep servers
arvadostest.StartAPI()
- arvadostest.StartKeepWithParams(false, enforcePermissions)
+ arvadostest.StartKeepWithParams(true, enforcePermissions)
// setup keepclients
var err error
kcSrc, kcDst, err = setupKeepClients(srcConfig, dstConfig, srcKeepServicesJSON, dstKeepServicesJSON, replications)
c.Check(err, IsNil)
- // Create an additional keep server to be used as destination and reload kcDst
- if setupDstServers {
- arvadostest.StartKeepWithParams(true, enforcePermissions)
- kcDst, err = keepclient.MakeKeepClient(kcDst.Arvados)
- c.Check(err, IsNil)
+ for uuid := range kcSrc.LocalRoots() {
+ if strings.HasSuffix(uuid, "02") {
+ delete(kcSrc.LocalRoots(), uuid)
+ }
+ }
+ for uuid := range kcSrc.GatewayRoots() {
+ if strings.HasSuffix(uuid, "02") {
+ delete(kcSrc.GatewayRoots(), uuid)
+ }
+ }
+ for uuid := range kcSrc.WritableLocalRoots() {
+ if strings.HasSuffix(uuid, "02") {
+ delete(kcSrc.WritableLocalRoots(), uuid)
+ }
+ }
+
+ for uuid := range kcDst.LocalRoots() {
+ if strings.HasSuffix(uuid, "00") || strings.HasSuffix(uuid, "01") {
+ delete(kcDst.LocalRoots(), uuid)
+ }
+ }
+ for uuid := range kcDst.GatewayRoots() {
+ if strings.HasSuffix(uuid, "00") || strings.HasSuffix(uuid, "01") {
+ delete(kcDst.GatewayRoots(), uuid)
+ }
+ }
+ for uuid := range kcDst.WritableLocalRoots() {
+ if strings.HasSuffix(uuid, "00") || strings.HasSuffix(uuid, "01") {
+ delete(kcDst.WritableLocalRoots(), uuid)
+ }
+ }
+
+ if updateDstReplications {
kcDst.Want_replicas = replications
}
}