-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
centaur/src/main/resources/standardTestCases/gcpbatch_google_labels_good.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: gcpbatch_google_labels_good | ||
testFormat: workflowsuccess | ||
backends: [GCPBATCH] | ||
|
||
files { | ||
workflow: google_labels/gcpbatch_google_labels.wdl | ||
options: google_labels/good_options.json | ||
} | ||
|
||
metadata { | ||
workflowName: google_labels | ||
status: Succeeded | ||
|
||
"calls.google_labels.check_labels.labels.wdl-task-name": "check_labels" | ||
|
||
"calls.google_labels.check_labels.backendLabels.custom-label": "custom-value" | ||
} |
57 changes: 57 additions & 0 deletions
57
centaur/src/main/resources/standardTestCases/google_labels/gcpbatch_google_labels.wdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
version 1.0 | ||
|
||
workflow google_labels { | ||
|
||
meta { | ||
description: "Confirms that the google_labels workflow option is propagated correctly to tasks" | ||
} | ||
|
||
input { | ||
Array[Pair[String, String]] expected_kvps = [ ("wdl-task-name", "check_labels") ] | ||
Boolean check_aliases = true | ||
} | ||
|
||
# Build an array of checker lines to confirm the existence of each KVP: | ||
scatter (p in expected_kvps) { | ||
String checker_lines = "echo $INSTANCE_INFO | grep -q '\"~{p.left}\": \"~{p.right}\"' || echo \"Couldn't find correct '~{p.left}' label in instance info: $INSTANCE_INFO\" 1>&2" | ||
} | ||
|
||
call check_labels { input: label_checker_lines = checker_lines } | ||
|
||
if (check_aliases) { | ||
call check_labels as check_label_alias { input: label_checker_lines = [ | ||
"echo $INSTANCE_INFO | grep -q '\"wdl-task-name\": \"check_labels\"' || echo \"Couldn't find correct 'wdl-task-name' label in instance info: $INSTANCE_INFO\" 1>&2", | ||
"echo $INSTANCE_INFO | grep -q '\"wdl-call-alias\": \"check_label_alias\"' || echo \"Couldn't find correct 'wdl-call-alias' label in instance info: $INSTANCE_INFO\" 1>&2" | ||
] } | ||
} | ||
|
||
output { | ||
Boolean done = true | ||
} | ||
|
||
} | ||
|
||
task check_labels { | ||
|
||
input { | ||
Array[String] label_checker_lines | ||
} | ||
|
||
command { | ||
# Check that the task metadata is correct: | ||
INSTANCE=$(curl -s "http://metadata.google.internal/computeMetadata/v1/instance/name" -H "Metadata-Flavor: Google") | ||
TOKEN=$(gcloud auth application-default print-access-token) | ||
INSTANCE_INFO=$(curl -s "https://www.googleapis.com/compute/v1/projects/broad-dsde-cromwell-dev/zones/us-central1-c/instances/$INSTANCE" \ | ||
-H "Authorization: Bearer $TOKEN" \ | ||
-H 'Accept: application/json') | ||
|
||
# Check for the custom label in the instance info: | ||
~{sep="\n" label_checker_lines} | ||
} | ||
runtime { | ||
docker: "gcr.io/google.com/cloudsdktool/cloud-sdk:slim" | ||
# Specify this zone because it's used in the curl commands above. We probably *could* work this out ad-hoc but it's easier to hard-code it here: | ||
zones: ["us-central1-c"] | ||
failOnStderr: true | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
centaur/src/main/resources/standardTestCases/google_labels_good.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters