Skip to content

Commit

Permalink
add no cost test
Browse files Browse the repository at this point in the history
  • Loading branch information
lucymcnatt committed Feb 5, 2025
1 parent 5e6f36d commit 1714d0a
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: cacheBetweenWF
testFormat: runtwiceexpectingcallcachingnocost

files {
workflow: cacheBetweenWF/cacheBetweenWF.wdl
options: common_options/cache_read_off_write_on.options
second-options: common_options/cache_read_on_write_on.options
}

metadata {
workflowName: cacheBetweenWF
status: Succeeded
"calls.cacheBetweenWF.getAverage.callCaching.result": "Cache Hit: <<CACHE_HIT_UUID>>:cacheBetweenWF.getAverage:-1"
"calls.cacheBetweenWF.heightProduct.callCaching.result": "Cache Hit: <<CACHE_HIT_UUID>>:cacheBetweenWF.heightProduct:-1"
"outputs.cacheBetweenWF.heightProduct.trapezoidalArea": 406.0
}
11 changes: 11 additions & 0 deletions centaur/src/main/scala/centaur/test/Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1094,4 +1094,15 @@ object Operations extends StrictLogging {
} yield ()
}

def validateNoCost(submittedWorkflow: SubmittedWorkflow): Test[Unit] =
new Test[Unit] {

override def run: IO[Unit] =
for {
actualCost <- CentaurCromwellClient.cost(submittedWorkflow)
_ = if (actualCost.cost != 0) IO.raiseError(new Exception(s"When using call caching, the cost must be 0, not ${actualCost.cost}"))
else IO.unit
} yield ()
}

}
20 changes: 20 additions & 0 deletions centaur/src/main/scala/centaur/test/formulas/TestFormulas.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@ object TestFormulas extends StrictLogging {
_ <- validateDirectoryContentsCounts(workflowDefinition, secondWf, metadata)
} yield SubmitResponse(secondWf)

def runWorkflowTwiceExpectingCachingNoCost(
workflowDefinition: Workflow
)(implicit cromwellTracker: Option[CromwellTracker]): Test[SubmitResponse] =
for {
_ <- checkDescription(workflowDefinition, validityExpectation = Option(true))
_ <- timingVerificationNotSupported(workflowDefinition.maximumAllowedTime)
firstWF <- runSuccessfulWorkflow(workflowDefinition)
secondWf <- runSuccessfulWorkflow(workflowDefinition.secondRun)
_ <- printHashDifferential(firstWF, secondWf)
metadata <- fetchAndValidateNonSubworkflowMetadata(secondWf, workflowDefinition, Option(firstWF.id.id))
_ <- fetchAndValidateJobManagerStyleMetadata(secondWf,
workflowDefinition,
prefetchedOriginalNonSubWorkflowMetadata = None
)
_ = cromwellTracker.track(metadata)
_ <- validateNoCacheMisses(secondWf, metadata, workflowDefinition)
_ <- validateDirectoryContentsCounts(workflowDefinition, secondWf, metadata)
_ <- validateNoCost(secondWf)
} yield SubmitResponse(secondWf)

def runWorkflowThriceExpectingCaching(
workflowDefinition: Workflow
)(implicit cromwellTracker: Option[CromwellTracker]): Test[SubmitResponse] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sealed abstract class CentaurTestFormat(val name: String) {
case WorkflowSuccessAndVerifyCostTest => "successfully run and verify cost"
case WorkflowFailureTest => "fail during execution"
case RunTwiceExpectingCallCachingTest => "call cache the second run of"
case RunTwiceExpectingCallCachingNoCostTest => "call cache the second run and verify no cost of"
case RunThriceExpectingCallCachingTest => "call cache the third run of"
case RunTwiceExpectingNoCallCachingTest => "NOT call cache the second run of"
case RunFailingTwiceExpectingNoCallCachingTest => "Fail the first run and NOT call cache the second run of"
Expand Down Expand Up @@ -53,6 +54,7 @@ object CentaurTestFormat {
case object WorkflowSuccessAndVerifyCostTest extends CentaurTestFormat("WorkflowSuccessAndVerifyCost")
case object WorkflowFailureTest extends CentaurTestFormat("WorkflowFailure")
case object RunTwiceExpectingCallCachingTest extends CentaurTestFormat("RunTwiceExpectingCallCaching")
case object RunTwiceExpectingCallCachingNoCostTest extends CentaurTestFormat("RunTwiceExpectingCallCachingNoCost")
case object RunThriceExpectingCallCachingTest extends CentaurTestFormat(name = "RunThriceExpectingCallCaching")
case object RunTwiceExpectingNoCallCachingTest extends CentaurTestFormat("RunTwiceExpectingNoCallCaching")
case object RunFailingTwiceExpectingNoCallCachingTest
Expand Down Expand Up @@ -132,6 +134,7 @@ object CentaurTestFormat {
WorkflowSuccessAndVerifyCostTest,
WorkflowFailureTest,
RunTwiceExpectingCallCachingTest,
RunTwiceExpectingCallCachingNoCostTest,
RunThriceExpectingCallCachingTest,
RunTwiceExpectingNoCallCachingTest,
RunFailingTwiceExpectingNoCallCachingTest,
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ services {
GcpCostCatalogService {
class = "cromwell.services.cost.GcpCostCatalogService"
config {
enabled = false
enabled = true
catalogExpirySeconds = 86400
}
}
Expand Down
8 changes: 5 additions & 3 deletions docs/developers/Centaur.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ You can now run the tests from another terminal.
There are two ways to invoke the integration tests:

* `sbt "centaur / IntegrationTest / test"` - compiles Centaur and runs all tests via sbt directly.
Tests are expected to be in the `centaur/src/main/standardTestCases` directory. In order to run a set of specific tests, you can create a new subdirectory that contains the tests you would like to run, then change the path by modifying the centaur `reference.conf`.
* Can also just run `centaur/ IntegrationTest / test` from the sbt terminal.
Tests are expected to be in the `centaur/src/main/standardTestCases` directory. In order to run a set of specific tests, create a new subdirectory that contains the tests to run, then modify the path in the centaur `reference.conf`.

* `src/ci/bin/testCentaurLocal.sh` - runs the same tests using the continuous integration pipeline configuration.

Expand Down Expand Up @@ -95,6 +96,7 @@ The `basePath` field is optional, but if supplied all paths will be resolved fro
The `testFormat` field can be one of the following, case insensitive:
* `workflowsuccess`: The workflow being supplied is expected to successfully complete
* `workflowfailure`: The workflow being supplied is expected to fail
* `workflowsuccessandverifycost`: The workflow being supplied is expected to complete and the expected cost will be verified

The `metadata` is optional. If supplied, Centaur will retrieve the metadata from the successfully completed workflow and compare the values retrieved to those supplied. At the moment the only fields supported are strings, numbers and booleans.

Expand All @@ -109,10 +111,10 @@ In case the absolute path the cromwell root is used (for example: `/home/my_user
* `"calls.hello.hello.exit_code": "<<WORKFLOW_ROOT>>/call-hello/execution/exit_code"`

In case testing of the caching is required `<<CACHE_HIT_UUID>>` can be used.
The testFormat should be `runtwiceexpectingcallcaching`.
The testFormat should be `runtwiceexpectingcallcaching`. To verify that the cost is 0 when using call-caching the testFormat should be `runtwiceexpectingcallcachingnocost`

The cost is optional. If supplied, Centaur will retrieve the cost of the successfully completed workflow and compare it to the cost supplied.
The expected range is within 10% of the estimated cost.
The expected range is within 10% of the estimated cost. If evaluating the cost, the test format must be `WorkflowSuccessAndVerifyCost` and the call-caching option must be disabled for that test (example can be found in the `recursive_imports_cost.test`)


## Centaur Test Types
Expand Down
4 changes: 2 additions & 2 deletions docs/developers/Running.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
In order to run a Cromwell instance locally, there are the prerequisites:
In order to run a Cromwell instance locally, there are the some prerequisites:
- Have docker and IntelliJ installed
- Start a local mysql instance by running the `start_publish_mysql_docker.sh` script

To run the backend locally, set up your preferred run configuration.
More information on backends can be found here: [Backends](Backends.md)
![](select-run-config.png)

If you've created a new config, you may need to edit your run configuration to point to the correct config file or have the correct environment variables.
If you've created a new config, you may need to edit your run configuration to point to the correct config file or edit the environment variables.
Example for batch:
![](edit-run-config.png)

Expand Down

0 comments on commit 1714d0a

Please sign in to comment.