[ARVADOS] updated: 1.1.2-109-gecb7d45

Git user git at public.curoverse.com
Wed Jan 10 12:06:42 EST 2018


Summary of changes:
 build/run-tests.sh                                 |  20 +-
 sdk/R/R/Arvados.R                                  |  15 +-
 sdk/R/tests/testthat/HttpRequestStub.R             |  52 --
 sdk/R/tests/testthat/fakes/FakeHttpParser.R        |  30 +
 sdk/R/tests/testthat/fakes/FakeHttpRequest.R       |  83 +++
 sdk/R/tests/testthat/test-Arvados.R                | 187 +++++-
 sdk/cwl/arvados_cwl/arvworkflow.py                 |   4 +-
 sdk/cwl/tests/arvados-tests.yml                    |   6 +
 .../wf/{runin-wf.cwl => runin-with-ttl-wf.cwl}     |  11 +-
 services/crunch-run/git_mount.go                   |   7 +-
 services/keepproxy/keepproxy_test.go               |  12 +-
 services/keepstore/handler_test.go                 |   2 +-
 tools/arvbox/bin/arvbox                            |   4 +-
 tools/arvbox/lib/arvbox/docker/Dockerfile.base     |  11 +-
 tools/arvbox/lib/arvbox/docker/common.sh           |   7 +-
 tools/arvbox/lib/arvbox/docker/runit/1             |   7 +
 tools/arvbox/lib/arvbox/docker/runit/2             |  10 +
 tools/arvbox/lib/arvbox/docker/runit/3             |  14 +
 tools/arvbox/lib/arvbox/docker/runit/ctrlaltdel    |  13 +
 tools/arvbox/lib/arvbox/docker/service/docker/run  |  10 +-
 .../lib/arvbox/docker/service/ready/run-service    |   3 -
 .../arvbox/lib/arvbox/docker/service/workbench/run |   4 +-
 vendor/vendor.json                                 | 656 +++++++++++----------
 23 files changed, 762 insertions(+), 406 deletions(-)
 delete mode 100644 sdk/R/tests/testthat/HttpRequestStub.R
 create mode 100644 sdk/R/tests/testthat/fakes/FakeHttpParser.R
 create mode 100644 sdk/R/tests/testthat/fakes/FakeHttpRequest.R
 copy sdk/cwl/tests/wf/{runin-wf.cwl => runin-with-ttl-wf.cwl} (91%)
 create mode 100755 tools/arvbox/lib/arvbox/docker/runit/1
 create mode 100755 tools/arvbox/lib/arvbox/docker/runit/2
 create mode 100755 tools/arvbox/lib/arvbox/docker/runit/3
 create mode 100755 tools/arvbox/lib/arvbox/docker/runit/ctrlaltdel

       via  ecb7d4501373a21ae69494beee8252f107ec1b56 (commit)
       via  1ece35a0faae97687c2dd370f6b8a61aaac505c2 (commit)
       via  79309a1e149b8d3e62810a32769de30e71be7688 (commit)
       via  8e4fe3e615430ed48631ce15bd3ba3b0864ab03e (commit)
       via  99bc798d924e267cb71d5176fd6cde1edfe9b344 (commit)
       via  94b8d1c4a4152a0b0f1cd531d396eb49e738d6c7 (commit)
       via  7bfb9fd099ada6b7466ec3531caebbd5ac0970ba (commit)
       via  1c355040b77161f02a2e351fe7ec32b1d1907ee8 (commit)
       via  56a8f4d0f1ccd871de5fdbb6204ef157e0dd455f (commit)
       via  5e8428f48dd64e48b5dcfd13341c0a6bd44e4d74 (commit)
       via  9bb723068bdba79d9bc6272697c353cac5fda40d (commit)
      from  2d3726dd11046146731f7f7391659a5eaf44702b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit ecb7d4501373a21ae69494beee8252f107ec1b56
Merge: 1ece35a 79309a1
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Wed Jan 10 18:06:30 2018 +0100

    Merge branch 'master' of git.curoverse.com:arvados into 11876-r-sdk
    
    Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic at capeannenterprises.com>


commit 1ece35a0faae97687c2dd370f6b8a61aaac505c2
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Wed Jan 10 18:05:05 2018 +0100

    Added a few unit test for Arvados class
    
    Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic at capeannenterprises.com>

diff --git a/sdk/R/R/Arvados.R b/sdk/R/R/Arvados.R
index b58b287..7cf75a9 100644
--- a/sdk/R/R/Arvados.R
+++ b/sdk/R/R/Arvados.R
@@ -27,8 +27,9 @@ Arvados <- R6::R6Class(
             token <- Sys.getenv("ARVADOS_API_TOKEN");
 
             if(host == "" | token == "")
-                stop("Please provide host name and authentification token or set
-                     ARVADOS_API_HOST and ARVADOS_API_TOKEN environmental variables.")
+                stop(paste0("Please provide host name and authentification token",
+                            " or set ARVADOS_API_HOST and ARVADOS_API_TOKEN",
+                            " environmental variables."))
 
             version <- "v1"
             host  <- paste0("https://", host, "/arvados/", version, "/")
@@ -37,16 +38,23 @@ Arvados <- R6::R6Class(
             private$httpParser <- HttpParser$new()
             private$token      <- token
             private$host       <- host
+            private$rawHost    <- host_name
         },
 
         getToken    = function() private$token,
         getHostName = function() private$host,
 
+        getHttpClient = function() private$http,
+        setHttpClient = function(newClient) private$http <- newClient,
+
+        getHttpParser = function() private$httpParser,
+        setHttpParser = function(newParser) private$httpParser <- newParser,
+
         getWebDavHostName = function()
         {
             if(is.null(private$webDavHostName))
             {
-                discoveryDocumentURL <- paste0("https://", host,
+                discoveryDocumentURL <- paste0("https://", private$rawHost,
                                                "/discovery/v1/apis/arvados/v1/rest")
 
                 headers <- list(Authorization = paste("OAuth2", private$token))
@@ -277,6 +285,7 @@ Arvados <- R6::R6Class(
 
         token          = NULL,
         host           = NULL,
+        rawHost        = NULL,
         webDavHostName = NULL,
         http           = NULL,
         httpParser     = NULL,
diff --git a/sdk/R/tests/testthat/HttpRequestStub.R b/sdk/R/tests/testthat/HttpRequestStub.R
deleted file mode 100644
index 31f8759..0000000
--- a/sdk/R/tests/testthat/HttpRequestStub.R
+++ /dev/null
@@ -1,52 +0,0 @@
-HttpRequest <- R6::R6Class(
-
-    "HttrRequestStub",
-
-    public = list(
-
-        validContentTypes = NULL,
-
-        content = NULL,
-
-        initialize = function(returnContent) 
-        {
-            self$validContentTypes <- c("text", "raw")
-            self$content <- returnContent
-        },
-
-        GET = function(url, headers = NULL, queryFilters = NULL, limit = NULL, offset = NULL)
-        {
-            return self$content
-        },
-
-        PUT = function(url, headers = NULL, body = NULL,
-                       queryFilters = NULL, limit = NULL, offset = NULL)
-        {
-            return self$content
-        },
-
-        POST = function(url, headers = NULL, body = NULL,
-                        queryFilters = NULL, limit = NULL, offset = NULL)
-        {
-            return self$content
-        },
-
-        DELETE = function(url, headers = NULL, body = NULL,
-                          queryFilters = NULL, limit = NULL, offset = NULL)
-        {
-            return self$content
-        },
-
-        PROPFIND = function(url, headers = NULL)
-        {
-            return self$content
-        },
-
-        MOVE = function(url, headers = NULL)
-        {
-            return self$content
-        }
-    ),
-
-    cloneable = FALSE
-)
diff --git a/sdk/R/tests/testthat/fakes/FakeHttpParser.R b/sdk/R/tests/testthat/fakes/FakeHttpParser.R
new file mode 100644
index 0000000..8252497
--- /dev/null
+++ b/sdk/R/tests/testthat/fakes/FakeHttpParser.R
@@ -0,0 +1,30 @@
+FakeHttpParser <- R6::R6Class(
+
+    "HttrParser",
+
+    public = list(
+
+        parserCallCount = NULL,
+
+        initialize = function() 
+        {
+            self$parserCallCount <- 0
+        },
+
+        parseJSONResponse = function(serverResponse) 
+        {
+            self$parserCallCount <- self$parserCallCount + 1
+            serverResponse
+        },
+
+        parseWebDAVResponse = function(response, uri)
+        {
+            response
+        },
+
+        extractFileSizeFromWebDAVResponse = function(response, uri)    
+        {
+            response
+        }
+    )
+)
diff --git a/sdk/R/tests/testthat/fakes/FakeHttpRequest.R b/sdk/R/tests/testthat/fakes/FakeHttpRequest.R
new file mode 100644
index 0000000..612c80d
--- /dev/null
+++ b/sdk/R/tests/testthat/fakes/FakeHttpRequest.R
@@ -0,0 +1,83 @@
+FakeHttpRequest <- R6::R6Class(
+
+    "FakeHttpRequest",
+
+    public = list(
+
+        content                                 = NULL,
+        expectedURL                             = NULL,
+        URLIsProperlyConfigured                 = NULL,
+        requestHeaderContainsAuthorizationField = NULL,
+
+        numberOfGETRequests = NULL,
+        numberOfDELETERequests = NULL,
+
+        initialize = function(expectedURL = NULL, serverResponse = NULL)
+        {
+            self$content <- serverResponse
+            self$expectedURL <- expectedURL
+            self$requestHeaderContainsAuthorizationField <- FALSE
+            self$URLIsProperlyConfigured <- FALSE
+
+            self$numberOfGETRequests <- 0
+            self$numberOfDELETERequests <- 0
+        },
+
+        GET = function(url, headers = NULL, queryFilters = NULL, limit = NULL, offset = NULL)
+        {
+            private$validateURL(url)
+            private$validateHeaders(headers)
+            self$numberOfGETRequests <- self$numberOfGETRequests + 1
+
+            self$content
+        },
+
+        PUT = function(url, headers = NULL, body = NULL,
+                       queryFilters = NULL, limit = NULL, offset = NULL)
+        {
+            self$content
+        },
+
+        POST = function(url, headers = NULL, body = NULL,
+                        queryFilters = NULL, limit = NULL, offset = NULL)
+        {
+            self$content
+        },
+
+        DELETE = function(url, headers = NULL, body = NULL,
+                          queryFilters = NULL, limit = NULL, offset = NULL)
+        {
+            private$validateURL(url)
+            private$validateHeaders(headers)
+            self$numberOfDELETERequests <- self$numberOfDELETERequests + 1
+            self$content
+        },
+
+        PROPFIND = function(url, headers = NULL)
+        {
+            self$content
+        },
+
+        MOVE = function(url, headers = NULL)
+        {
+            self$content
+        }
+    ),
+
+    private = list(
+
+        validateURL = function(url) 
+        {
+            if(!is.null(self$expectedURL) && url == self$expectedURL)
+                self$URLIsProperlyConfigured <- TRUE
+        },
+
+        validateHeaders = function(headers) 
+        {
+            if(!is.null(headers$Authorization))
+                self$requestHeaderContainsAuthorizationField <- TRUE
+        }
+    ),
+
+    cloneable = FALSE
+)
diff --git a/sdk/R/tests/testthat/test-Arvados.R b/sdk/R/tests/testthat/test-Arvados.R
index 35b4152..16b6798 100644
--- a/sdk/R/tests/testthat/test-Arvados.R
+++ b/sdk/R/tests/testthat/test-Arvados.R
@@ -1,6 +1,9 @@
 context("Arvados API")
 
-test_that("Arvados constructor will use environment variables if no parameters are passed to it", {
+source("fakes/FakeHttpRequest.R")
+source("fakes/FakeHttpParser.R")
+
+test_that("Constructor will use environment variables if no parameters are passed to it", {
 
     Sys.setenv(ARVADOS_API_HOST  = "environment_api_host")
     Sys.setenv(ARVADOS_API_TOKEN = "environment_api_token")
@@ -17,7 +20,7 @@ test_that("Arvados constructor will use environment variables if no parameters a
                 equals(arv$getToken())) 
 }) 
 
-test_that("Arvados constructor preferes constructor fields over environment variables", {
+test_that("Constructor preferes constructor fields over environment variables", {
 
     Sys.setenv(ARVADOS_API_HOST  = "environment_api_host")
     Sys.setenv(ARVADOS_API_TOKEN = "environment_api_token")
@@ -33,3 +36,183 @@ test_that("Arvados constructor preferes constructor fields over environment vari
     expect_that("constructor_api_token",
                 equals(arv$getToken())) 
 }) 
+
+test_that("Constructor raises exception if fields and environment variables are not provided", {
+
+    expect_that(Arvados$new(),
+                throws_error(paste0("Please provide host name and authentification token",
+                                    " or set ARVADOS_API_HOST and ARVADOS_API_TOKEN",
+                                    " environmental variables.")))
+}) 
+
+test_that("getWebDavHostName calls REST service properly", {
+
+    hostName <- "hostName"
+    token    <- "token"
+    arv      <- Arvados$new(token, hostName)
+
+    serverResponse <- list(keepWebServiceUrl = "https://myWebDavServer.com")
+    expectedURL    <- paste0("https://", hostName,
+                             "/discovery/v1/apis/arvados/v1/rest")
+
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+    arv$setHttpClient(httpRequest)
+    arv$setHttpParser(FakeHttpParser$new())
+
+    webDAVHostName <- arv$getWebDavHostName()
+
+    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
+    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
+    expect_that(httpRequest$numberOfGETRequests, equals(1))
+}) 
+
+test_that("getWebDavHostName returns webDAV host name properly", {
+
+    arv <- Arvados$new("token", "hostName")
+
+    serverResponse <- list(keepWebServiceUrl = "https://myWebDavServer.com")
+
+    httpRequest <- FakeHttpRequest$new(expectedURL = NULL, serverResponse)
+    arv$setHttpClient(httpRequest)
+    arv$setHttpParser(FakeHttpParser$new())
+
+    expect_that("https://myWebDavServer.com", equals(arv$getWebDavHostName())) 
+}) 
+
+test_that("getCollection calls REST service properly", {
+
+    arv <- Arvados$new("token", "hostName")
+
+    serverResponse <- NULL
+    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL    <- paste0(arv$getHostName(), "collections/", collectionUUID)
+
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+    arv$setHttpClient(httpRequest)
+    arv$setHttpParser(FakeHttpParser$new())
+
+    arv$getCollection(collectionUUID)
+
+    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
+    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
+    expect_that(httpRequest$numberOfGETRequests, equals(1))
+}) 
+
+test_that("getCollection parses server response", {
+
+    arv <- Arvados$new("token", "hostName")
+
+    httpParser <- FakeHttpParser$new()
+    arv$setHttpParser(httpParser)
+    arv$setHttpClient(FakeHttpRequest$new())
+
+    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    arv$getCollection(collectionUUID)
+
+    expect_that(httpParser$parserCallCount, equals(1))
+}) 
+
+test_that("getCollection raises exception if response contains errors field", {
+
+    arv <- Arvados$new("token", "hostName")
+    
+    serverResponse <- list(errors = 404)
+    arv$setHttpClient(FakeHttpRequest$new(NULL, serverResponse))
+    arv$setHttpParser(FakeHttpParser$new())
+
+    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    
+    expect_that(arv$getCollection(collectionUUID), 
+                throws_error(404))
+}) 
+
+test_that("listCollections calls REST service properly", {
+
+    arv <- Arvados$new("token", "hostName")
+
+    serverResponse <- NULL
+    expectedURL    <- paste0(arv$getHostName(), "collections")
+
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+    arv$setHttpClient(httpRequest)
+    arv$setHttpParser(FakeHttpParser$new())
+
+    arv$listCollections()
+
+    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
+    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
+    expect_that(httpRequest$numberOfGETRequests, equals(1))
+}) 
+
+test_that("listCollections parses server response", {
+
+    arv <- Arvados$new("token", "hostName")
+
+    httpParser <- FakeHttpParser$new()
+    arv$setHttpParser(httpParser)
+    arv$setHttpClient(FakeHttpRequest$new())
+
+    arv$listCollections()
+
+    expect_that(httpParser$parserCallCount, equals(1))
+}) 
+
+test_that("listCollections raises exception if response contains errors field", {
+
+    arv <- Arvados$new("token", "hostName")
+    
+    serverResponse <- list(errors = 404)
+    expectedURL <- NULL
+    arv$setHttpClient(FakeHttpRequest$new(expectedURL, serverResponse))
+    arv$setHttpParser(FakeHttpParser$new())
+
+    expect_that(arv$listCollections(), 
+                throws_error(404))
+}) 
+
+test_that("deleteCollection calls REST service properly", {
+
+    arv <- Arvados$new("token", "hostName")
+
+    serverResponse <- NULL
+    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL    <- paste0(arv$getHostName(), "collections/", collectionUUID)
+
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+    arv$setHttpClient(httpRequest)
+    arv$setHttpParser(FakeHttpParser$new())
+
+    arv$deleteCollection(collectionUUID)
+
+    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
+    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
+    expect_that(httpRequest$numberOfDELETERequests, equals(1))
+}) 
+
+test_that("deleteCollection parses server response", {
+
+    arv <- Arvados$new("token", "hostName")
+
+    httpParser <- FakeHttpParser$new()
+    arv$setHttpParser(httpParser)
+    arv$setHttpClient(FakeHttpRequest$new())
+
+    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    arv$deleteCollection(collectionUUID)
+
+    expect_that(httpParser$parserCallCount, equals(1))
+}) 
+
+test_that("getCollection raises exception if response contains errors field", {
+
+    arv <- Arvados$new("token", "hostName")
+    
+    serverResponse <- list(errors = 404)
+    arv$setHttpClient(FakeHttpRequest$new(NULL, serverResponse))
+    arv$setHttpParser(FakeHttpParser$new())
+
+    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    
+    expect_that(arv$deleteCollection(collectionUUID), 
+                throws_error(404))
+}) 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list