From 96c3ba289b360999529e9c14ad3b33cbf1bf7fcb Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 13 Jun 2017 18:04:08 -0700 Subject: [PATCH] Added Travis CI (#23) * Create .travis.yml * Added travis to .Rbuildignore * Added r package github installation * Skipping on travis * Added don't run on examples for R travis CI * Warnings are errors --- .Rbuildignore | 1 + .travis.yml | 9 ++++++++ R/autoscale.R | 7 +++++-- R/cluster.R | 16 +++++++------- R/utility.R | 12 +++++++++-- man/generateCredentialsConfig.Rd | 4 +++- man/getJobList.Rd | 2 ++ man/getJobResult.Rd | 7 ++++++- man/makeCluster.Rd | 6 ++++-- man/resizeCluster.Rd | 7 +++++-- man/setCredentials.Rd | 11 ++-------- man/stopCluster.Rd | 2 ++ man/waitForNodesToComplete.Rd | 2 ++ tests/testthat/test-integration.R | 35 ++++++++++++++++++++++++++----- 14 files changed, 90 insertions(+), 31 deletions(-) create mode 100644 .travis.yml diff --git a/.Rbuildignore b/.Rbuildignore index 91114bf2..112ad268 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,2 +1,3 @@ ^.*\.Rproj$ ^\.Rproj\.user$ +^\.travis\.yml$ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..c90c4059 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r + +language: R +sudo: false +cache: packages +warnings_are_errors: false + +r_github_packages: + - Azure/rAzureBatch diff --git a/R/autoscale.R b/R/autoscale.R index 872645d5..fa9e468e 100644 --- a/R/autoscale.R +++ b/R/autoscale.R @@ -60,10 +60,13 @@ getAutoscaleFormula <- function(formulaName, dedicatedMin, dedicatedMax, lowPrio #' @param lowPriorityMin The minimum number of low priority nodes #' @param lowPriorityMax The maximum number of low priority nodes #' @param algorithm Current built-in autoscale formulas: QUEUE, MAX_CPU, WEEKEND, WEEKDAY -#' @param timeInterval +#' @param timeInterval Time interval at which to automatically adjust the pool size according to the autoscale formula #' #' @examples -#' resizeCluster(cluster, dedicatedMin = 2, dedicatedMax = 6, dedicatedMin = 2, dedicatedMax = 6, algorithm = "QUEUE", timeInterval = "PT10M") +#' \dontrun{ +#' resizeCluster(cluster, dedicatedMin = 2, dedicatedMax = 6, +#' dedicatedMin = 2, dedicatedMax = 6, algorithm = "QUEUE", timeInterval = "PT10M") +#' } #' @export resizeCluster <- function(cluster, dedicatedMin, diff --git a/R/cluster.R b/R/cluster.R index adc96b9d..f0ca7489 100644 --- a/R/cluster.R +++ b/R/cluster.R @@ -12,7 +12,9 @@ #' @return The request to the Batch service was successful. #' @examples { #' generateCredentialsConfig("test_config.json") -#' generateCredentialsConfig("test_config.json", batchAccount = "testbatchaccount", batchKey = "test_batch_account_key", batchUrl = "http://testbatchaccount.azure.com", storageAccount = "teststorageaccount", storageKey = "test_storage_account_key") +#' generateCredentialsConfig("test_config.json", batchAccount = "testbatchaccount", +#' batchKey = "test_batch_account_key", batchUrl = "http://testbatchaccount.azure.com", +#' storageAccount = "teststorageaccount", storageKey = "test_storage_account_key") #' } #' @export generateCredentialsConfig <- function(fileName, ...){ @@ -96,14 +98,16 @@ generateClusterConfig <- function(fileName, ...){ #' Creates an Azure cloud-enabled cluster. #' -#' @param fileName Cluster configuration's file name +#' @param clusterSetting Cluster configuration's file name #' @param fullName A boolean flag for checking the file full name #' @param wait A boolean flag to wait for all nodes to boot up #' @param resourceFiles A list of files that Batch will download to the compute node before running the command line #' #' @return The request to the Batch service was successful. #' @examples +#' \dontrun{ #' cluster <- makeCluster("cluster_config.json", fullName = TRUE, wait = TRUE) +#' } #' @export makeCluster <- function(clusterSetting = "cluster_settings.json", fullName = FALSE, wait = TRUE, resourceFiles = list()){ if(fullName){ @@ -166,8 +170,10 @@ makeCluster <- function(clusterSetting = "cluster_settings.json", fullName = FAL #' @param cluster The cluster configuration that was created in \code{makeCluster} #' #' @examples +#' \dontrun{ #' clusterConfiguration <- makeCluster("cluster_settings.json") #' stopCluster(clusterConfiguration) +#' } #' @export stopCluster <- function(cluster){ deletePool(cluster$poolId) @@ -175,14 +181,10 @@ stopCluster <- function(cluster){ print(sprintf("Your %s cluster has been destroyed.", cluster$poolId)) } -#' Deletes the cluster from your Azure account. +#' Set azure credentials to R session. #' #' @param fileName The cluster configuration that was created in \code{makeCluster} #' -#' @return The request to the Batch service was successful. -#' @examples -#' clusterConfiguration <- makeCluster("cluster_settings.json") -#' stopCluster(clusterConfiguration) #' @export setCredentials <- function(fileName = "az_config.json"){ if(file.exists(fileName)){ diff --git a/R/utility.R b/R/utility.R index b335ccf1..0b468e75 100644 --- a/R/utility.R +++ b/R/utility.R @@ -37,7 +37,9 @@ linuxWrapCommands <- function(commands = c()){ #' @param jobIds A character vector of job ids #' #' @examples +#' \dontrun{ #' getJobList(c("job-001", "job-002")) +#' } #' @export getJobList <- function(jobIds = c()){ filter <- "" @@ -80,7 +82,9 @@ getJobList <- function(jobIds = c()){ #' @param timeout Timeout in seconds, default timeout is one day #' #' @examples +#' \dontrun{ #' waitForNodesToComplete(clusterId = "testCluster", timeout = 3600) +#' } #' @export waitForNodesToComplete <- function(clusterId, timeout = 86400){ print("Booting compute nodes. . . ") @@ -147,13 +151,17 @@ waitForNodesToComplete <- function(clusterId, timeout = 86400){ } #' Download the results of the job -#' +#' @param ... Further named parameters +#' \itemize{ +#' \item{"container"}: {The container to download from.} +#' } #' @param jobId The jobId to download from -#' @param container The container to download from #' #' @return The results from the job. #' @examples +#' \dontrun{ #' getJobResult(jobId = "job-001") +#' } #' @export getJobResult <- function(jobId = "", ...){ args <- list(...) diff --git a/man/generateCredentialsConfig.Rd b/man/generateCredentialsConfig.Rd index d972c999..2a2ee615 100644 --- a/man/generateCredentialsConfig.Rd +++ b/man/generateCredentialsConfig.Rd @@ -27,7 +27,9 @@ Creates a credentials file for rAzureBatch package authentication \examples{ { generateCredentialsConfig("test_config.json") -generateCredentialsConfig("test_config.json", batchAccount = "testbatchaccount", batchKey = "test_batch_account_key", batchUrl = "http://testbatchaccount.azure.com", storageAccount = "teststorageaccount", storageKey = "test_storage_account_key") +generateCredentialsConfig("test_config.json", batchAccount = "testbatchaccount", + batchKey = "test_batch_account_key", batchUrl = "http://testbatchaccount.azure.com", + storageAccount = "teststorageaccount", storageKey = "test_storage_account_key") } } diff --git a/man/getJobList.Rd b/man/getJobList.Rd index 8fc4ab06..cd0f0fd3 100644 --- a/man/getJobList.Rd +++ b/man/getJobList.Rd @@ -13,6 +13,8 @@ getJobList(jobIds = c()) Get a list of job statuses from the given job ids } \examples{ +\dontrun{ getJobList(c("job-001", "job-002")) } +} diff --git a/man/getJobResult.Rd b/man/getJobResult.Rd index 4eab746b..d4af12cd 100644 --- a/man/getJobResult.Rd +++ b/man/getJobResult.Rd @@ -9,7 +9,10 @@ getJobResult(jobId = "", ...) \arguments{ \item{jobId}{The jobId to download from} -\item{container}{The container to download from} +\item{...}{Further named parameters +\itemize{ + \item{"container"}: {The container to download from.} +}} } \value{ The results from the job. @@ -18,6 +21,8 @@ The results from the job. Download the results of the job } \examples{ +\dontrun{ getJobResult(jobId = "job-001") } +} diff --git a/man/makeCluster.Rd b/man/makeCluster.Rd index 26ab67f4..c2b44973 100644 --- a/man/makeCluster.Rd +++ b/man/makeCluster.Rd @@ -8,13 +8,13 @@ makeCluster(clusterSetting = "cluster_settings.json", fullName = FALSE, wait = TRUE, resourceFiles = list()) } \arguments{ +\item{clusterSetting}{Cluster configuration's file name} + \item{fullName}{A boolean flag for checking the file full name} \item{wait}{A boolean flag to wait for all nodes to boot up} \item{resourceFiles}{A list of files that Batch will download to the compute node before running the command line} - -\item{fileName}{Cluster configuration's file name} } \value{ The request to the Batch service was successful. @@ -23,6 +23,8 @@ The request to the Batch service was successful. Creates an Azure cloud-enabled cluster. } \examples{ +\dontrun{ cluster <- makeCluster("cluster_config.json", fullName = TRUE, wait = TRUE) } +} diff --git a/man/resizeCluster.Rd b/man/resizeCluster.Rd index 14881596..a2eb915b 100644 --- a/man/resizeCluster.Rd +++ b/man/resizeCluster.Rd @@ -20,12 +20,15 @@ resizeCluster(cluster, dedicatedMin, dedicatedMax, lowPriorityMin, \item{algorithm}{Current built-in autoscale formulas: QUEUE, MAX_CPU, WEEKEND, WEEKDAY} -\item{timeInterval}{} +\item{timeInterval}{Time interval at which to automatically adjust the pool size according to the autoscale formula} } \description{ Resize an Azure cloud-enabled cluster. } \examples{ -resizeCluster(cluster, dedicatedMin = 2, dedicatedMax = 6, dedicatedMin = 2, dedicatedMax = 6, algorithm = "QUEUE", timeInterval = "PT10M") +\dontrun{ +resizeCluster(cluster, dedicatedMin = 2, dedicatedMax = 6, + dedicatedMin = 2, dedicatedMax = 6, algorithm = "QUEUE", timeInterval = "PT10M") +} } diff --git a/man/setCredentials.Rd b/man/setCredentials.Rd index 2535c419..b48bdafa 100644 --- a/man/setCredentials.Rd +++ b/man/setCredentials.Rd @@ -2,21 +2,14 @@ % Please edit documentation in R/cluster.R \name{setCredentials} \alias{setCredentials} -\title{Deletes the cluster from your Azure account.} +\title{Set azure credentials to R session.} \usage{ setCredentials(fileName = "az_config.json") } \arguments{ \item{fileName}{The cluster configuration that was created in \code{makeCluster}} } -\value{ -The request to the Batch service was successful. -} \description{ -Deletes the cluster from your Azure account. -} -\examples{ -clusterConfiguration <- makeCluster("cluster_settings.json") -stopCluster(clusterConfiguration) +Set azure credentials to R session. } diff --git a/man/stopCluster.Rd b/man/stopCluster.Rd index 8700df69..fc867cd7 100644 --- a/man/stopCluster.Rd +++ b/man/stopCluster.Rd @@ -13,7 +13,9 @@ stopCluster(cluster) Deletes the cluster from your Azure account. } \examples{ +\dontrun{ clusterConfiguration <- makeCluster("cluster_settings.json") stopCluster(clusterConfiguration) } +} diff --git a/man/waitForNodesToComplete.Rd b/man/waitForNodesToComplete.Rd index 78e21f8c..75b829fd 100644 --- a/man/waitForNodesToComplete.Rd +++ b/man/waitForNodesToComplete.Rd @@ -15,6 +15,8 @@ waitForNodesToComplete(clusterId, timeout = 86400) Polling method to check status of cluster boot up } \examples{ +\dontrun{ waitForNodesToComplete(clusterId = "testCluster", timeout = 3600) } +} diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index 3e152fa5..1cadbc37 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -1,6 +1,23 @@ context("generate cluster config") -test_that("creating a cluster config file", { +test_that("creating a credentials file", { + skip_on_travis() + + configFileName <- "testthat.json" + + generateCredentialsConfig(configFileName) + config <- jsonlite::fromJSON(configFileName) + + expect_false(is.null(config$batchAccount$name)) + expect_false(is.null(config$batchAccount$key)) + expect_false(is.null(config$batchAccount$url)) + + file.remove(configFileName) +}) + +test_that("creating a cluster file", { + skip_on_travis() + configFileName <- "testthat.json" generateClusterConfig(configFileName) @@ -15,6 +32,8 @@ test_that("creating a cluster config file", { }) test_that("End to end integration simple sum foreach", { + skip_on_travis() + configFileName <- "testthat.json" batchAccountName <- Sys.getenv("AZ_BATCH_ACCOUNT_NAME") @@ -24,7 +43,7 @@ test_that("End to end integration simple sum foreach", { storageAccountName <- Sys.getenv("AZ_STORAGE_ACCOUNT_NAME") storageAccountKey <- Sys.getenv("AZ_STORAGE_ACCOUNT_KEY") - generateClusterConfig(configFileName, + generateCredentialsConfig(configFileName, batchAccount = batchAccountName, batchKey = batchAccountKey, batchUrl = batchAccountUrl, @@ -48,6 +67,8 @@ test_that("End to end integration simple sum foreach", { }) test_that("End to end integration job with wait", { + skip_on_travis() + configFileName <- "testthat.json" batchAccountName <- Sys.getenv("AZ_BATCH_ACCOUNT_NAME") @@ -57,7 +78,7 @@ test_that("End to end integration job with wait", { storageAccountName <- Sys.getenv("AZ_STORAGE_ACCOUNT_NAME") storageAccountKey <- Sys.getenv("AZ_STORAGE_ACCOUNT_KEY") - generateClusterConfig(configFileName, + generateCredentialsConfig(configFileName, batchAccount = batchAccountName, batchKey = batchAccountKey, batchUrl = batchAccountUrl, @@ -96,6 +117,8 @@ test_that("End to end integration job with wait", { }) test_that("End to end integration job with chunks", { + skip_on_travis() + configFileName <- "testthat.json" batchAccountName <- Sys.getenv("AZ_BATCH_ACCOUNT_NAME") @@ -105,14 +128,16 @@ test_that("End to end integration job with chunks", { storageAccountName <- Sys.getenv("AZ_STORAGE_ACCOUNT_NAME") storageAccountKey <- Sys.getenv("AZ_STORAGE_ACCOUNT_KEY") - generateClusterConfig(configFileName, + generateCredentialsConfig(configFileName, batchAccount = batchAccountName, batchKey = batchAccountKey, batchUrl = batchAccountUrl, storageAccount = storageAccountName, storageKey = storageAccountKey) - cluster <- makeCluster(configFileName) + setCredentials("testthat.json") + + cluster <- makeCluster("cluster.json") registerDoAzureParallel(cluster)