From 6823f2d65a48bc989b819b85b6428c230b223c82 Mon Sep 17 00:00:00 2001 From: radhika Date: Mon, 5 Oct 2015 09:25:34 -0400 Subject: [PATCH] 7167: args not avaialble in all tests; hence store keep_existing argument in a variable rather than accessing it directly from args. --- sdk/python/tests/run_test_server.py | 7 +++-- tools/keep-rsync/keep-rsync.go | 42 ++++++++++++++--------------- tools/keep-rsync/keep-rsync_test.go | 26 +++++++++--------- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/sdk/python/tests/run_test_server.py b/sdk/python/tests/run_test_server.py index d5d1874749..62a2a82349 100644 --- a/sdk/python/tests/run_test_server.py +++ b/sdk/python/tests/run_test_server.py @@ -43,6 +43,7 @@ if not os.path.exists(TEST_TMPDIR): my_api_host = None _cached_config = {} +keep_existing = None def find_server_pid(PID_PATH, wait=10): now = time.time() @@ -324,7 +325,7 @@ def _start_keep(n, keep_args): return port def run_keep(blob_signing_key=None, enforce_permissions=False): - if args.keep_existing is None: + if keep_existing is None: stop_keep() keep_args = {} @@ -352,7 +353,7 @@ def run_keep(blob_signing_key=None, enforce_permissions=False): api.keep_disks().delete(uuid=d['uuid']).execute() start_index = 0 - if args.keep_existing is not None: + if keep_existing is not None: start_index = 2 for d in range(start_index, start_index+2): port = _start_keep(d, keep_args) @@ -606,6 +607,8 @@ if __name__ == "__main__": parser.add_argument('--keep_existing', type=str, help="Used to add additional keep servers, without terminating existing servers") args = parser.parse_args() + keep_existing = args.keep_existing + if args.action not in actions: print("Unrecognized action '{}'. Actions are: {}.".format(args.action, actions), file=sys.stderr) sys.exit(1) diff --git a/tools/keep-rsync/keep-rsync.go b/tools/keep-rsync/keep-rsync.go index eff8b9c47a..c9fd77a34d 100644 --- a/tools/keep-rsync/keep-rsync.go +++ b/tools/keep-rsync/keep-rsync.go @@ -11,17 +11,17 @@ import ( // keep-rsync arguments var ( - srcConfig map[string]string - destConfig map[string]string - srcKeepServicesJSON string - destKeepServicesJSON string - replications int - prefix string + srcConfig map[string]string + dstConfig map[string]string + srcKeepServicesJSON string + dstKeepServicesJSON string + replications int + prefix string ) func main() { var srcConfigFile string - var destConfigFile string + var dstConfigFile string flag.StringVar( &srcConfigFile, @@ -32,8 +32,8 @@ func main() { "ARVADOS_API_HOST, ARVADOS_API_HOST_INSECURE, and ARVADOS_BLOB_SIGNING_KEY.") flag.StringVar( - &destConfigFile, - "dest-config-file", + &dstConfigFile, + "dst-config-file", "", "Destination configuration filename with full path that contains "+ "an ARVADOS_API_TOKEN which is a valid datamanager token recognized by the destination keep servers, "+ @@ -47,11 +47,11 @@ func main() { "If not provided, this list is obtained from api server configured in src-config-file.") flag.StringVar( - &destKeepServicesJSON, - "dest-keep-services-json", + &dstKeepServicesJSON, + "dst-keep-services-json", "", "An optional list of available destination keepservices. "+ - "If not provided, this list is obtained from api server configured in dest-config-file.") + "If not provided, this list is obtained from api server configured in dst-config-file.") flag.IntVar( &replications, @@ -77,10 +77,10 @@ func main() { log.Fatal("Error reading source configuration: %s", err.Error()) } - if destConfigFile == "" { - log.Fatal("-dest-config-file must be specified.") + if dstConfigFile == "" { + log.Fatal("-dst-config-file must be specified.") } - destConfig, err = readConfigFromFile(destConfigFile) + dstConfig, err = readConfigFromFile(dstConfigFile) if err != nil { log.Fatal("Error reading destination configuration: %s", err.Error()) } @@ -112,10 +112,10 @@ func readConfigFromFile(filename string) (map[string]string, error) { // keep-rsync source and destination clients var ( - arvSrc arvadosclient.ArvadosClient - arvDest arvadosclient.ArvadosClient - kcSrc *keepclient.KeepClient - kcDest *keepclient.KeepClient + arvSrc arvadosclient.ArvadosClient + arvDst arvadosclient.ArvadosClient + kcSrc *keepclient.KeepClient + kcDst *keepclient.KeepClient ) // Initializes keep-rsync using the config provided @@ -125,7 +125,7 @@ func initializeKeepRsync() (err error) { return } - arvDest, err = arvadosclient.MakeArvadosClientWithConfig(destConfig) + arvDst, err = arvadosclient.MakeArvadosClientWithConfig(dstConfig) if err != nil { return } @@ -135,7 +135,7 @@ func initializeKeepRsync() (err error) { return } - kcDest, err = keepclient.MakeKeepClient(&arvDest) + kcDst, err = keepclient.MakeKeepClient(&arvDst) return } diff --git a/tools/keep-rsync/keep-rsync_test.go b/tools/keep-rsync/keep-rsync_test.go index e2b1f0f0f7..c45fbf83bb 100644 --- a/tools/keep-rsync/keep-rsync_test.go +++ b/tools/keep-rsync/keep-rsync_test.go @@ -36,7 +36,7 @@ func (s *ServerRequiredSuite) TearDownSuite(c *C) { arvadostest.StopAPI() } -// Testing keep-rsync needs two sets of keep services: src and dest. +// Testing keep-rsync needs two sets of keep services: src and dst. // The test setup hence tweaks keep-rsync initialzation to achieve this. // First invoke initializeKeepRsync and then invoke StartKeepAdditional // to create the keep servers to be used as destination. @@ -47,11 +47,11 @@ func setupRsync(c *C) { srcConfig["ARVADOS_API_TOKEN"] = os.Getenv("ARVADOS_API_TOKEN") srcConfig["ARVADOS_API_HOST_INSECURE"] = os.Getenv("ARVADOS_API_HOST_INSECURE") - // destConfig - destConfig = make(map[string]string) - destConfig["ARVADOS_API_HOST"] = os.Getenv("ARVADOS_API_HOST") - destConfig["ARVADOS_API_TOKEN"] = os.Getenv("ARVADOS_API_TOKEN") - destConfig["ARVADOS_API_HOST_INSECURE"] = os.Getenv("ARVADOS_API_HOST_INSECURE") + // dstConfig + dstConfig = make(map[string]string) + dstConfig["ARVADOS_API_HOST"] = os.Getenv("ARVADOS_API_HOST") + dstConfig["ARVADOS_API_TOKEN"] = os.Getenv("ARVADOS_API_TOKEN") + dstConfig["ARVADOS_API_HOST_INSECURE"] = os.Getenv("ARVADOS_API_HOST_INSECURE") arvadostest.StartAPI() arvadostest.StartKeep() @@ -63,8 +63,8 @@ func setupRsync(c *C) { // Create two more keep servers to be used as destination arvadostest.StartKeepAdditional(true) - // load kcDest - kcDest, err = keepclient.MakeKeepClient(&arvDest) + // load kcDst + kcDst, err = keepclient.MakeKeepClient(&arvDst) c.Assert(err, Equals, nil) } @@ -90,10 +90,10 @@ func (s *ServerRequiredSuite) TestReadConfigFromFile(c *C) { c.Assert(config["EXTERNAL_CLIENT"], Equals, "") } -// Test keep-rsync initialization, with src and dest keep servers. +// Test keep-rsync initialization, with src and dst keep servers. // Do a Put and Get in src, both of which should succeed. -// Do a Get in dest for the same hash, which should raise block not found error. -func (s *ServerRequiredSuite) TestRsyncPutInSrc_GetFromDestShouldFail(c *C) { +// Do a Get in dst for the same hash, which should raise block not found error. +func (s *ServerRequiredSuite) TestRsyncPutInSrc_GetFromDstShouldFail(c *C) { setupRsync(c) // Put a block in src using kcSrc and Get it @@ -111,7 +111,7 @@ func (s *ServerRequiredSuite) TestRsyncPutInSrc_GetFromDestShouldFail(c *C) { all, err := ioutil.ReadAll(reader) c.Check(all, DeepEquals, data) - // Get using kcDest should fail with NotFound error - _, _, _, err = kcDest.Get(hash) + // Get using kcDst should fail with NotFound error + _, _, _, err = kcDst.Get(hash) c.Assert(err.Error(), Equals, "Block not found") } -- 2.39.5