Skip to content

Commit f35ab8f

Browse files
authored
[AN-142] Adding cost centaur test (#7685)
Also removes old mysql test for versions < 8.0
1 parent 305765f commit f35ab8f

27 files changed

+295
-49
lines changed

.github/workflows/integration_tests.yml

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,52 +32,40 @@ jobs:
3232
matrix:
3333
# Batch test fixes to land later
3434
include:
35-
- build_type: centaurPapiV2beta
36-
build_mysql: 5.6
37-
friendly_name: Life Sciences, MySQL 5.6 (current Terra production)
38-
- build_type: centaurPapiV2beta
39-
build_mysql: 5.7
40-
friendly_name: Life Sciences, MySQL 5.7
4135
- build_type: centaurPapiV2beta
4236
build_mysql: 8.0
43-
friendly_name: Life Sciences, MySQL 8.0 (required Terra production)
37+
friendly_name: Life Sciences, MySQL 8.0
4438
- build_type: centaurPapiV2beta
4539
build_mysql: 8.4
46-
friendly_name: Life Sciences, MySQL 8.4 (aspirational Terra production)
47-
- build_type: centaurGcpBatch
48-
build_mysql: 5.6
49-
friendly_name: GCP Batch, MySQL 5.6
50-
- build_type: centaurGcpBatch
51-
build_mysql: 5.7
52-
friendly_name: GCP Batch, MySQL 5.7
40+
friendly_name: Life Sciences, MySQL 8.4 (current Terra production)
5341
- build_type: centaurGcpBatch
5442
build_mysql: 8.0
5543
friendly_name: GCP Batch, MySQL 8.0
5644
- build_type: centaurGcpBatch
5745
build_mysql: 8.4
5846
friendly_name: GCP Batch, MySQL 8.4
5947
- build_type: centaurPapiV2betaRestart
60-
build_mysql: 5.7
48+
build_mysql: 8.4
6149
friendly_name: Centaur Papi V2 Beta (restart)
6250
- build_type: dbms
6351
friendly_name: DBMS
6452
- build_type: centaurTes
65-
build_mysql: 5.7
66-
friendly_name: Centaur TES with MySQL 5.7
53+
build_mysql: 8.4
54+
friendly_name: Centaur TES with MySQL 8.4
6755
- build_type: centaurLocal
68-
build_mysql: 5.7
69-
friendly_name: Centaur Local with MySQL 5.7
56+
build_mysql: 8.4
57+
friendly_name: Centaur Local with MySQL 8.4
7058
- build_type: checkPublish
7159
friendly_name: Check Publish
7260
- build_type: centaurAws
73-
build_mysql: 5.7
74-
friendly_name: Centaur AWS with MySQL 5.7
61+
build_mysql: 8.4
62+
friendly_name: Centaur AWS with MySQL 8.4
7563
- build_type: centaurDummy
76-
build_mysql: 5.7
77-
friendly_name: Centaur Dummy with MySQL 5.7
64+
build_mysql: 8.4
65+
friendly_name: Centaur Dummy with MySQL 8.4
7866
- build_type: centaurHoricromtalPapiV2beta
79-
build_mysql: 5.7
80-
friendly_name: Centaur Horicromtal PapiV2 Beta with MySQL 5.7
67+
build_mysql: 8.4
68+
friendly_name: Centaur Horicromtal PapiV2 Beta with MySQL 8.4
8169
- build_type: horicromtalDeadlock
8270
friendly_name: Horicromtal Deadlock
8371
- build_type: singleWorkflowRunner
@@ -89,15 +77,15 @@ jobs:
8977
build_postgresql: 11.3
9078
friendly_name: Centaur Local with PostgreSQL 11.3
9179
- build_type: centaurEngineUpgradeLocal
92-
build_mysql: 5.7
93-
friendly_name: Centaur Engine Upgrade Local with MySQL 5.7
80+
build_mysql: 8.4
81+
friendly_name: Centaur Engine Upgrade Local with MySQL 8.4
9482
- build_type: referenceDiskManifestBuilderApp
9583
friendly_name: Reference Disk Manifest Builder App
9684
- build_type: centaurSlurm
97-
build_mysql: 5.7
98-
friendly_name: "Centaur Slurm with MySQL 5.7"
85+
build_mysql: 8.4
86+
friendly_name: "Centaur Slurm with MySQL 8.4"
9987
- build_type: centaurBlob
100-
build_mysql: 5.7
88+
build_mysql: 8.4
10189
friendly_name: Centaur Blob
10290
name: ${{ matrix.friendly_name }}
10391
env:
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
task one {
2+
Int vertAxis
3+
command {
4+
echo ${vertAxis/2}
5+
}
6+
output {
7+
Float semiVertAxis = read_int(stdout())
8+
}
9+
runtime {
10+
docker: "gcr.io/gcp-runtimes/ubuntu_16_0_4@sha256:53a002b59dfcd43b4d15e97c1acbeae035ddd1b31a106659a312e9fe65f00afa"
11+
}
12+
}
13+
14+
task two {
15+
Int horAxis
16+
command {
17+
echo ${horAxis/2}
18+
}
19+
output {
20+
Float semiHorAxis = read_int(stdout())
21+
}
22+
runtime {
23+
docker: "gcr.io/gcp-runtimes/ubuntu_16_0_4@sha256:53a002b59dfcd43b4d15e97c1acbeae035ddd1b31a106659a312e9fe65f00afa"
24+
}
25+
}
26+
27+
task area{
28+
Float semiVertAxis
29+
Float semiHorAxis
30+
Float pi = 3.14159
31+
32+
command {
33+
echo ${semiHorAxis*semiVertAxis*pi}
34+
}
35+
output {
36+
Float ellipseArea = read_float(stdout())
37+
}
38+
runtime {
39+
docker: "ubuntu@sha256:71cd81252a3563a03ad8daee81047b62ab5d892ebbfbf71cf53415f29c130950"
40+
}
41+
}
42+
43+
workflow cacheBetweenWFNoCost {
44+
call one {
45+
input: vertAxis = 5
46+
}
47+
call two {
48+
input: horAxis = 6
49+
}
50+
call area {
51+
input: semiVertAxis = one.semiVertAxis, semiHorAxis = two.semiHorAxis
52+
}
53+
output {
54+
area.ellipseArea
55+
}
56+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: cacheBetweenWFNoCost
2+
testFormat: runtwiceexpectingcallcachingnocost
3+
backends: [Papi, GCPBATCH]
4+
5+
files {
6+
workflow: cacheBetweenWF/cacheBetweenWFNoCost.wdl
7+
options: common_options/cache_read_off_write_on.options
8+
second-options: common_options/cache_read_on_write_on.options
9+
}
10+
11+
metadata {
12+
workflowName: cacheBetweenWFNoCost
13+
status: Succeeded
14+
"calls.cacheBetweenWFNoCost.one.callCaching.result": "Cache Hit: <<CACHE_HIT_UUID>>:cacheBetweenWFNoCost.one:-1"
15+
"calls.cacheBetweenWFNoCost.two.callCaching.result": "Cache Hit: <<CACHE_HIT_UUID>>:cacheBetweenWFNoCost.two:-1"
16+
"outputs.cacheBetweenWFNoCost.area.ellipseArea": 18.849539999999998
17+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"read_from_cache":false
3+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: recursive_imports_cost_batch
2+
testFormat: workflowsuccessandverifycost
3+
backends: [GCPBATCH]
4+
5+
files {
6+
workflow: recursive_imports/recursive_imports.wdl
7+
imports: [
8+
forkjoin/forkjoin.wdl,
9+
sub_workflow_hello_world/sub_workflow_hello_world.wdl,
10+
sub_workflow_hello_world/sub_workflow_hello_world_import.wdl,
11+
sub_workflow_interactions/sub_workflow_interactions_import.wdl,
12+
sub_workflow_interactions/sub_workflow_interactions.wdl
13+
]
14+
# Adds option to disable call-caching
15+
options: recursive_imports/recursive_imports_cost.options
16+
}
17+
18+
metadata {
19+
workflowName: recursive_imports
20+
status: Succeeded
21+
}
22+
23+
cost: [0.0015, 0.0019]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: recursive_imports_cost_papi
2+
testFormat: workflowsuccessandverifycost
3+
backends: [PapiV2]
4+
5+
files {
6+
workflow: recursive_imports/recursive_imports.wdl
7+
imports: [
8+
forkjoin/forkjoin.wdl,
9+
sub_workflow_hello_world/sub_workflow_hello_world.wdl,
10+
sub_workflow_hello_world/sub_workflow_hello_world_import.wdl,
11+
sub_workflow_interactions/sub_workflow_interactions_import.wdl,
12+
sub_workflow_interactions/sub_workflow_interactions.wdl
13+
]
14+
# Adds option to disable call-caching
15+
options: recursive_imports/recursive_imports_cost.options
16+
}
17+
18+
metadata {
19+
workflowName: recursive_imports
20+
status: Succeeded
21+
}
22+
23+
cost: [0.0035,0.0045]

centaur/src/main/scala/centaur/api/CentaurCromwellClient.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ object CentaurCromwellClient extends StrictLogging {
122122
): IO[WorkflowMetadata] =
123123
sendReceiveFutureCompletion(() => cromwellClient.metadata(id, args))
124124

125+
def cost(workflow: SubmittedWorkflow): IO[WorkflowCost] =
126+
sendReceiveFutureCompletion(() => cromwellClient.cost(workflow.id))
127+
125128
def archiveStatus(id: WorkflowId): IO[String] =
126129
sendReceiveFutureCompletion(() => cromwellClient.query(id)).map(_.results.head.metadataArchiveStatus)
127130

centaur/src/main/scala/centaur/test/Test.scala

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,4 +1060,52 @@ object Operations extends StrictLogging {
10601060
IO.raiseError(CentaurTestException(message, workflow))
10611061
}
10621062
}
1063+
1064+
def getExpectedCost(workflowCost: Option[List[BigDecimal]]): IO[List[BigDecimal]] =
1065+
workflowCost match {
1066+
case Some(cost) if cost(0) > cost(1) =>
1067+
IO.raiseError(
1068+
new Exception(s"Lower bound of expected cost cannot be higher than the upper bound (${cost(0)} - ${cost(1)})")
1069+
)
1070+
case Some(cost) => IO.pure(cost)
1071+
case None =>
1072+
IO.raiseError(new Exception("Expected cost range is required in the test config to validate the workflow cost"))
1073+
}
1074+
1075+
/**
1076+
* Validate that the actual cost is within the expected range
1077+
*/
1078+
def validateCost(actualCost: BigDecimal, expectedCost: List[BigDecimal]): IO[Unit] =
1079+
if (expectedCost(0) > actualCost || actualCost > expectedCost(1)) {
1080+
IO.raiseError(
1081+
new Exception(s"Expected cost within range ${expectedCost(0)} - ${expectedCost(1)} but got $actualCost")
1082+
)
1083+
} else {
1084+
IO.unit
1085+
}
1086+
1087+
def fetchAndValidateCost(workflowSpec: Workflow, submittedWorkflow: SubmittedWorkflow): Test[Unit] =
1088+
new Test[Unit] {
1089+
1090+
override def run: IO[Unit] =
1091+
for {
1092+
actualCost <- CentaurCromwellClient.cost(submittedWorkflow)
1093+
expectedCost <- getExpectedCost(workflowSpec.cost)
1094+
_ <- validateCost(actualCost.cost, expectedCost)
1095+
} yield ()
1096+
}
1097+
1098+
def validateNoCost(submittedWorkflow: SubmittedWorkflow): Test[Unit] =
1099+
new Test[Unit] {
1100+
1101+
override def run: IO[Unit] =
1102+
for {
1103+
actualCost <- CentaurCromwellClient.cost(submittedWorkflow)
1104+
_ =
1105+
if (actualCost.cost != 0)
1106+
IO.raiseError(new Exception(s"When using call caching, the cost must be 0, not ${actualCost.cost}"))
1107+
else IO.unit
1108+
} yield ()
1109+
}
1110+
10631111
}

centaur/src/main/scala/centaur/test/formulas/TestFormulas.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ object TestFormulas extends StrictLogging {
7575
} yield SubmitResponse(submittedWorkflow)
7676

7777
def runSuccessfulWorkflowAndVerifyMetadata(
78-
workflowDefinition: Workflow
78+
workflowDefinition: Workflow,
79+
checkCost: Boolean = false
7980
)(implicit cromwellTracker: Option[CromwellTracker]): Test[SubmitResponse] = for {
8081
_ <- checkDescription(workflowDefinition, validityExpectation = Option(true))
8182
_ <- timingVerificationNotSupported(workflowDefinition.maximumAllowedTime)
@@ -94,6 +95,7 @@ object TestFormulas extends StrictLogging {
9495
_ <- validateLogs(metadata, submittedWorkflow, workflowDefinition)
9596
_ = cromwellTracker.track(metadata)
9697
_ <- validateDirectoryContentsCounts(workflowDefinition, submittedWorkflow, metadata)
98+
_ <- if (checkCost) fetchAndValidateCost(workflowDefinition, submittedWorkflow) else Test.successful(())
9799
} yield SubmitResponse(submittedWorkflow)
98100

99101
def runFailingWorkflowAndVerifyMetadata(
@@ -112,7 +114,8 @@ object TestFormulas extends StrictLogging {
112114
} yield SubmitResponse(submittedWorkflow)
113115

114116
def runWorkflowTwiceExpectingCaching(
115-
workflowDefinition: Workflow
117+
workflowDefinition: Workflow,
118+
checkCost: Boolean = false
116119
)(implicit cromwellTracker: Option[CromwellTracker]): Test[SubmitResponse] =
117120
for {
118121
_ <- checkDescription(workflowDefinition, validityExpectation = Option(true))
@@ -128,6 +131,7 @@ object TestFormulas extends StrictLogging {
128131
_ = cromwellTracker.track(metadata)
129132
_ <- validateNoCacheMisses(secondWf, metadata, workflowDefinition)
130133
_ <- validateDirectoryContentsCounts(workflowDefinition, secondWf, metadata)
134+
_ <- if (checkCost) validateNoCost(secondWf) else Test.successful(())
131135
} yield SubmitResponse(secondWf)
132136

133137
def runWorkflowThriceExpectingCaching(

centaur/src/main/scala/centaur/test/standard/CentaurTestCase.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ case class CentaurTestCase(workflow: Workflow,
2525
def testFunction: Test[SubmitResponse] = this.testFormat match {
2626
case WorkflowSuccessTest => TestFormulas.runSuccessfulWorkflowAndVerifyMetadata(workflow)
2727
case WorkflowSuccessAndTimedOutputsTest => TestFormulas.runSuccessfulWorkflowAndVerifyTimeAndOutputs(workflow)
28+
case WorkflowSuccessAndVerifyCostTest => TestFormulas.runSuccessfulWorkflowAndVerifyMetadata(workflow, true)
2829
case WorkflowFailureTest => TestFormulas.runFailingWorkflowAndVerifyMetadata(workflow)
2930
case RunTwiceExpectingCallCachingTest => TestFormulas.runWorkflowTwiceExpectingCaching(workflow)
31+
case RunTwiceExpectingCallCachingNoCostTest => TestFormulas.runWorkflowTwiceExpectingCaching(workflow, true)
3032
case RunThriceExpectingCallCachingTest => TestFormulas.runWorkflowThriceExpectingCaching(workflow)
3133
case RunTwiceExpectingNoCallCachingTest => TestFormulas.runWorkflowTwiceExpectingNoCaching(workflow)
3234
case RunFailingTwiceExpectingNoCallCachingTest => TestFormulas.runFailingWorkflowTwiceExpectingNoCaching(workflow)

0 commit comments

Comments
 (0)