Skip to content

Commit

Permalink
improve bash script and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
THWiseman committed Oct 31, 2023
1 parent 5b6852c commit f1e9ea7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,39 @@ object TesAsyncBackendJobExecutionActor {
s"""
|### BEGIN ACQUIRE LOCAL SAS TOKEN ###
|# Install dependencies
|apt-get -y update
|apt-get -y install curl
|apt-get -y install jq
|
|# Function to check if a command exists
|command_exists() {
| command -v "$$1" > /dev/null 2>&1
|}
|
|# Check if curl exists; install if not
|if ! command_exists curl; then
| if command_exists apt-get; then
| apt-get -y update && apt-get -y install curl
| if [ $$? -ne 0 ]; then
| echo "Error: Failed to install curl via apt-get."
| exit 1
| fi
| else
| echo "Error: apt-get is not available, and curl is not installed."
| exit 1
| fi
|fi
|
|# Check if jq exists; install if not
|if ! command_exists jq; then
| if command_exists apt-get; then
| apt-get -y update && apt-get -y install jq
| if [ $$? -ne 0 ]; then
| echo "Error: Failed to install jq via apt-get."
| exit 1
| fi
| else
| echo "Error: apt-get is not available, and jq is not installed."
| exit 1
| fi
|fi
|
|# Acquire bearer token, relying on the User Assigned Managed Identity of this VM.
|echo Acquiring Bearer Token using User Assigned Managed Identity...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ class TesRuntimeAttributesSpec extends AnyWordSpecLike with CromwellTimeoutSpec
}

"validate a valid sasEnvironmentVariable entry" in {
val runtimeAttributes = Map("docker" -> WomString("ubuntu:latest"), "sasEnvironmentVariable" -> WomString("THIS_IS_VALID"))
val runtimeAttributes = Map("docker" -> WomString("ubuntu:latest"), TesRuntimeAttributes.LocalizedSasKey -> WomString("THIS_IS_VALID"))
val expectedRuntimeAttributes = expectedDefaultsPlusUbuntuDocker.copy(localizedSasEnvVar = Some("THIS_IS_VALID"))
assertSuccess(runtimeAttributes, expectedRuntimeAttributes)
}

"fail to validate an invalid sasEnvironmentVariable entry" in {
val runtimeAttributes = Map("docker" -> WomString("ubuntu:latest"), "sasEnvironmentVariable" -> WomString("THIS IS INVALID"))
val runtimeAttributes = Map("docker" -> WomString("ubuntu:latest"), TesRuntimeAttributes.LocalizedSasKey -> WomString("THIS IS INVALID"))
assertFailure(runtimeAttributes, "Value must be a string containing only letters, numbers, and underscores.")
}

Expand Down

0 comments on commit f1e9ea7

Please sign in to comment.