Use a public key gen function.

This commit is contained in:
yueguoguo 2017-06-23 14:15:16 +08:00
Родитель b584b3c7bb
Коммит 86227b373b
3 изменённых файлов: 115 добавлений и 14 удалений

Просмотреть файл

@ -23,3 +23,27 @@ skip_if_offline <- function(){
testthat::skip("Offline. Skipping test.")
}
}
pubkey_gen <- function() {
# pubkey key extraction.
sys_info <- Sys.info()
priv_key <- paste0(ifelse(sys_info["sysname"] == "Windows",
"C:/Users/zhle/.ssh/",
"~/.ssh/"),
"id_rsa")
file_exist <- file.exists(priv_key)
if (file_exist) {
dsvm_pubkey <- system(paste0("ssh-keygen -y -f ",
priv_key),
intern=TRUE)
} else {
stop("Test aborted because no private key located at ~/.ssh. Please
generate key pair to do test again.")
}
return(dsvm_pubkey)
}

Просмотреть файл

@ -40,20 +40,7 @@ message("Remote execution is via SSH which relies on public key cryptograph.
# pubkey key extraction.
sys_info <- Sys.info()
priv_key <- paste0(ifelse(sys_info["sysname"] == "Windows",
"C:/Users/zhle/.ssh/",
"~/.ssh/"),
"id_rsa")
file_exist <- file.exists(priv_key)
if (file_exist) {
dsvm_pubkey <- system(paste0("ssh-keygen -y -f ",
priv_key),
intern=TRUE)
}
dsvm_pubkey <- pubkey_gen()
# code to execute.

Просмотреть файл

@ -0,0 +1,90 @@
# test deployment of DSVM.
if(interactive()) library("testthat")
library(AzureSMR)
settingsfile <- getOption("AzureSMR.config")
config <- read.AzureSMR.config()
timestamp <- format(Sys.time(), format="%y%m%d%H%M")
context("One box configuration setup for MRS VM")
asc <- createAzureContext()
with(config,
setAzureContext(asc, tenantID=tenantID, clientID=clientID, authKey=authKey)
)
azureAuthenticate(asc)
# create a new resource group.
context(" - create a new resource group")
resourceGroup_name <- paste0("AzureDSVMtest_", timestamp)
location <- "southeastasia"
test_that("Can create resource group", {
skip_if_missing_config(settingsfile)
res <- azureCreateResourceGroup(asc,
location=location,
resourceGroup=resourceGroup_name)
expect_equal(res, TRUE)
AzureSMR:::wait_for_azure(
resourceGroup_name %in% azureListRG(asc)$resourceGroup
)
expect_true(resourceGroup_name %in% azureListRG(asc)$resourceGroup)
})
context(" - Deploy a Microsoft R Server VM")
dsvm_size <- "Standard_D4_v2"
dsvm_os <- "RServer"
dsvm_name <- paste0("dsvm",
paste(sample(letters, 3), collapse=""))
dsvm_pubkey <- pubkey_gen()
dsvm_username <- "dsvmuser"
test_that("Deploy a Microsoft R Server VM", {
skip_if_missing_config(settingsfile)
res <- deployDSVM(asc,
resource.group=resourceGroup_name,
location=location,
hostname=dsvm_name,
username=dsvm_username,
size=dsvm_size,
os=dsvm_os,
authen="Key",
pubkey=dsvm_pubkey,
mode="Sync")
expect_equal(object=res, expected=paste(dsvm_name,
location,
"cloudapp.azure.com",
sep="."))
})
context(" - one-box configuration for the MRS VM.")
test_that("one-box configuration", {
mrsOneBoxConfiguration(asc,
resource.group=resourceGroup_name,
location=location,
hostname=dsvm_name,
username=dsvm_username,
password=dsvm_password)
})
context(" - delete resource group")
test_that("Can delete resource group", {
skip_if_missing_config(settingsfile)
expect_message({
res <- azureDeleteResourceGroup(asc, resourceGroup = resourceGroup_name)
}, "Delete Request Submitted"
)
})