7167: args not avaialble in all tests; hence store keep_existing argument in a variab...
authorradhika <radhika@curoverse.com>
Mon, 5 Oct 2015 13:25:34 +0000 (09:25 -0400)
committerradhika <radhika@curoverse.com>
Mon, 5 Oct 2015 13:25:34 +0000 (09:25 -0400)
sdk/python/tests/run_test_server.py
tools/keep-rsync/keep-rsync.go
tools/keep-rsync/keep-rsync_test.go

index d5d1874749f622757b2330426002cb8075a9e08a..62a2a82349b5a5cd2149d2d266f5834804489e88 100644 (file)
@@ -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)
index eff8b9c47a7873939adaa93424d332149be4aec3..c9fd77a34dd14b2e3178df901cf7df5b9258baa5 100644 (file)
@@ -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
 }
index e2b1f0f0f7343b54282b2da31a162ddd374a9183..c45fbf83bbebc9de4feec40b397400f9c174aa15 100644 (file)
@@ -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")
 }