Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AN-226] Enable submitting workflows to Cromwell's GCP Batch backend #3141

Merged
merged 33 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1c37f55
Add new workspace setting
sam-schu Nov 15, 2024
6adc2cc
Remove unnecessary cases
sam-schu Nov 15, 2024
9f0a1bc
Move tests for consistency
sam-schu Nov 15, 2024
e5c70f3
Fix new setting capitalization
sam-schu Nov 15, 2024
6493663
Update Swagger page
sam-schu Nov 18, 2024
4c21a9d
Merge branch 'develop' into sts_AN-225_batch_api_workspace_setting
sam-schu Nov 18, 2024
0924efb
Add unit tests
sam-schu Nov 19, 2024
fb0bbc7
Refactor test
sam-schu Nov 19, 2024
d065d7f
Minimum viable changes for new backend value
sam-schu Nov 22, 2024
fef634e
Merge branch 'develop' into sts_AN-226_submit_to_batch_backend
sam-schu Nov 25, 2024
bb29484
Update local config template pool versions
sam-schu Nov 26, 2024
60b70c7
Scalafmt
sam-schu Nov 26, 2024
1af1359
Add additional GCS root workflow option key
sam-schu Nov 27, 2024
f33844a
Get GCP Batch backend name from config
sam-schu Dec 2, 2024
5f142a8
Update tests
sam-schu Dec 2, 2024
01b9f48
Merge branch 'develop' into sts_AN-226_submit_to_batch_backend
sam-schu Dec 2, 2024
6f7de22
Add unit tests for switching backend based on setting value
sam-schu Dec 3, 2024
02dddf7
Update out-of-date comment
sam-schu Dec 3, 2024
3187133
Clarify rawls-model dependency update process
sam-schu Dec 4, 2024
25e2c4e
Add troubleshooting notes to README
sam-schu Dec 4, 2024
b8bc763
Add dev DB warning
sam-schu Dec 4, 2024
024e36d
Add comment for new workflow options key
sam-schu Dec 4, 2024
1a4de46
Update comment
sam-schu Dec 4, 2024
d05642c
Update test from PR feedback
sam-schu Dec 4, 2024
4ae9be2
Update comment pt. 2
sam-schu Dec 4, 2024
0697b44
Remove local Rawls workflow submission note
sam-schu Dec 4, 2024
8ee7126
Merge branch 'develop' into sts_AN-226_submit_to_batch_backend
sam-schu Dec 4, 2024
0d90360
Revert "Remove local Rawls workflow submission note"
sam-schu Dec 5, 2024
2d8bf9d
Revert "Add dev DB warning"
sam-schu Dec 5, 2024
9c3b890
Revert "Add troubleshooting notes to README"
sam-schu Dec 5, 2024
d39caae
Add clarifying comment
sam-schu Dec 5, 2024
1129375
Rewrite backend determination code for clarity
sam-schu Dec 6, 2024
c854091
Remove test log message
sam-schu Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ Ticket: <Link to Jira ticket>
- [ ] Include the JIRA issue number in the PR description and title
- [ ] Make sure Swagger is updated if API changes
- [ ] **...and Orchestration's Swagger too!**
- [ ] If you changed anything in `model/`, then you should [publish a new official `rawls-model`](https://github.com/broadinstitute/rawls/blob/develop/README.md#publish-rawls-model) and update `rawls-model` in [Orchestration's dependencies](https://github.com/broadinstitute/firecloud-orchestration/blob/develop/project/Dependencies.scala).
- [ ] If you changed anything in `model/`, then you should publish a new official `rawls-model` and perform the corresponding dependency updates as specified in the [README](https://github.com/broadinstitute/rawls/blob/develop/README.md#publish-rawls-model):
- [ ] in the automation subdirectory
- [ ] in workbench-libs
- [ ] in firecloud-orchestration
- [ ] Get two thumbsworth of PR review
- [ ] Verify all tests go green, including CI tests
- [ ] **Squash commits and merge** to develop (branches are automatically deleted after merging)
Expand Down
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ After satisfying the above requirements, execute the following command from the
./config/docker-rsync-local-rawls.sh
```

By default, this will set up an instance of rawls pointing to the database and Sam in dev.
**Reminder:** You should be on a Broad internal internet connection or VPN every time you want to run Rawls locally!
If you are not, Rawls may start up, but certain functionality may not work as expected.

By default, this command will set up an instance of rawls pointing to the database and Sam in dev.
It will also set up a process that will watch the local files for changes, and restart the service when source files change.

See docker-rsync-local-rawls.sh for more configuration options.
Expand All @@ -99,6 +102,8 @@ BACK_RAWLS=true ./config/docker-rsync-local-rawls.sh
```

**Important**: It is highly recommended that use your own Cloud SQL instance when running an instance of back Rawls by cloning the [dev Rawls DB](https://console.cloud.google.com/sql/instances/terraform-qfarbdq3lrexxck5htofjs5z6m/overview?project=broad-dsde-dev). See note below on database work.
* If you use the dev database itself, your local Rawls instance (with your code changes!) and dev Rawls can interact in
unpredictable ways, affecting both your own local testing and others' testing in the dev environment.

#### Developing Database Schema Changes

Expand Down Expand Up @@ -154,19 +159,25 @@ VAULT_TOKEN=$(cat ~/.vault-token) ARTIFACTORY_USERNAME=dsdejenkins ARTIFACTORY_P
You can view what is in the artifactory here: https://broadinstitute.jfrog.io/broadinstitute/webapp/#/home

After publishing:
* update [model/CHANGELOG.md](model/CHANGELOG.md) properly
* update the rawls-model dependency in the automation subdirectory, and ensure that sbt project is healthy
* update the rawls-model dependency in workbench-libs serviceTest, and ensure that sbt project is healthy
* Update [model/CHANGELOG.md](model/CHANGELOG.md) properly
* Update the rawls-model dependency in the automation subdirectory, and ensure that the sbt project is healthy
* In workbench-libs, update the rawls-model dependency in the project dependencies, update the README and the serviceTest changelog accordingly, and ensure that the sbt project is healthy
* In firecloud-orchestration, update the rawls-model dependency in the project dependencies, and ensure that the sbt project is healthy


## Troubleshooting

If you get the error message `release version 17 not supported`:
* Run `java -version` and verify that you're running 17. If not, you will need to install / update your PATH.

If you have trouble submitting workflows and see errors like `HTTP error calling URI https://cromiam-priv.dsde-dev.broadinstitute.org`:
If you have trouble submitting workflows and see errors like `HTTP error calling URI https://cromiam-priv.dsde-dev.broadinstitute.org`,
or you get unusual errors for other workflows-related functionality (like accessing workflow configurations):
* Connect to the NonSplit VPN and try again
* CromIAM doesn't accept requests from outside the Broad trusted IP space
* CromIAM doesn't accept requests from outside the Broad trusted IP space
* **Note:** Local Rawls instances are currently unable to submit workflows to CromIAM due to an issue with the
`caas-collection-name` label. If you are able to make a workflow submission to your local back Rawls instance and have
it run on Cromwell, check that you did not use the dev database and accidentally allow dev Rawls to pick up your
submission.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I recommend only checking in the content in the Publish rawls-model section.

I think a larger rewrite of the instructions is in order, which I intend to do in AN-297.

In particular, I don't think it makes sense to write instructions on what doesn't work, people want to know what does work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the note from lines 177-180 — I am happy to defer updates related to local workflow submission to your ticket. Did you also think I should revert my other updates other than those related to the Rawls model? I think my additional VPN reminder and additional context about using the dev database based on what we learned will help future developers not make the same mistakes that I did.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please stick to updating the content in the Publish rawls-model section.

We will have horrible merge conflicts otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will definitely pull you in to review that PR so you can confirm I covered everything you ran into.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks! I have reverted the other changes.


When running back Rawls with a DB clone, the app may crash on launch with an error related to `OpenTelemetry`.
* Work around by setting `entityStatisticsCache.enabled = false`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ object Boot extends IOApp with LazyLogging {
CromwellBackend(appConfigManager.conf.getString("executionservice.defaultNetworkBackend"))
val highSecurityNetworkCromwellBackend: CromwellBackend =
CromwellBackend(appConfigManager.conf.getString("executionservice.highSecurityNetworkBackend"))
val gcpBatchBackend: CromwellBackend =
CromwellBackend(appConfigManager.conf.getString("executionservice.gcpBatchBackend"))

val wdlParsingConfig = WDLParserConfig(appConfigManager.conf.getConfig("wdl-parsing"))
def cromwellSwaggerClient = new CromwellSwaggerClient(wdlParsingConfig.serverBasePath)
Expand Down Expand Up @@ -598,6 +600,7 @@ object Boot extends IOApp with LazyLogging {
useWorkflowCollectionLabel,
defaultNetworkCromwellBackend,
highSecurityNetworkCromwellBackend,
gcpBatchBackend,
methodConfigResolver,
bardService,
workspaceSettingRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ object WorkflowSubmissionActor {
useWorkflowCollectionLabel: Boolean,
defaultNetworkCromwellBackend: CromwellBackend,
highSecurityNetworkCromwellBackend: CromwellBackend,
gcpBatchBackend: CromwellBackend,
methodConfigResolver: MethodConfigResolver,
bardService: BardService,
workspaceSettingRepository: WorkspaceSettingRepository
Expand All @@ -69,6 +70,7 @@ object WorkflowSubmissionActor {
useWorkflowCollectionLabel,
defaultNetworkCromwellBackend,
highSecurityNetworkCromwellBackend,
gcpBatchBackend,
methodConfigResolver,
bardService,
workspaceSettingRepository
Expand Down Expand Up @@ -105,6 +107,7 @@ class WorkflowSubmissionActor(val dataSource: SlickDataSource,
val useWorkflowCollectionLabel: Boolean,
val defaultNetworkCromwellBackend: CromwellBackend,
val highSecurityNetworkCromwellBackend: CromwellBackend,
val gcpBatchBackend: CromwellBackend,
val methodConfigResolver: MethodConfigResolver,
val bardService: BardService,
val workspaceSettingRepository: WorkspaceSettingRepository
Expand Down Expand Up @@ -159,6 +162,7 @@ trait WorkflowSubmission extends FutureSupport with LazyLogging with MethodWiths
val useWorkflowCollectionLabel: Boolean
val defaultNetworkCromwellBackend: CromwellBackend
val highSecurityNetworkCromwellBackend: CromwellBackend
val gcpBatchBackend: CromwellBackend
val methodConfigResolver: MethodConfigResolver
val bardService: BardService
val workspaceSettingRepository: WorkspaceSettingRepository
Expand Down Expand Up @@ -301,7 +305,16 @@ trait WorkflowSubmission extends FutureSupport with LazyLogging with MethodWiths
// - final_workflow_outputs_dir = submissions/final-outputs
// - final_workflow_outputs_mode = "copy".

useCromwellGcpBatchBackend: Boolean = currentSettings
.collectFirst { case setting: UseCromwellGcpBatchBackendSetting =>
setting
}
.exists(_.config.enabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be clearer if we did it in a single invocation (further tweaking welcome, this is just an idea):

useCromwellGcpBatchBackend = currentSettings.exists { setting => 
    setting match {
        case backendSetting: UseCromwellGcpBatchBackendSetting => backendSetting.config.enabled
        case _ => false
     }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by a single invocation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean going from a collectFirst followed by a exists, to just an exists. I find it easier to read because I don't have to think about the type coming out of the collectFirst. I also like making it obvious that we are handling two different false cases - the settings exists and is set to false, or the setting doesn't exist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably create a reusable utility method to retrieve a strongly-typed workspace setting from the settings list, a la:

  def findSetting[T](allSettings: List[WorkspaceSetting]): Option[T] = {
    allSettings.collectFirst {
      case found:T => found
    }
  }

if we had that, then this code could be a bit clearer, like:

useBatchSetting: Option[UseCromwellGcpBatchBackendSetting] = somwhereTheUtilityLives
        .findSetting[UseCromwellGcpBatchBackendSetting](currentSettings)

or

useCromwellGcpBatchBackend: Boolean = somwhereTheUtilityLives
        .findSetting[UseCromwellGcpBatchBackendSetting](currentSettings).exists(_.config.enabled)

you could use the same utility to calculate separateSubmissionSetting up at line 293, too.

I'd consider this a stretch goal/out of scope/does not block this PR. I don't want to scope-creep!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! @davidangb I agree that refactoring would be great for clarity and reusability in the future, but I have implemented Janet's suggestion for now.

cromwellSubmissionBackend =
if (useCromwellGcpBatchBackend) gcpBatchBackend else highSecurityNetworkCromwellBackend

executionServiceWorkflowOptions = ExecutionServiceWorkflowOptions(
submission.submissionRoot,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this meant to be duplicated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! David was confused by the same thing. I added a clarifying comment as he suggested!

submission.submissionRoot,
Comment on lines +318 to 319
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a good comment on ExecutionServiceWorkflowOptions that explains why we're passing the same value as the first two arguments … perhaps add a code comment here too? I was awfully confused when I first read this code, until I drilled down into ExecutionServiceWorkflowOptions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a clarifying comment, thanks!

final_workflow_outputs_dir,
final_workflow_outputs_dir_metadata,
Expand All @@ -315,7 +328,7 @@ trait WorkflowSubmission extends FutureSupport with LazyLogging with MethodWiths
deleteIntermediateOutputFiles,
useReferenceDisks,
memoryRetryMultiplier,
highSecurityNetworkCromwellBackend,
cromwellSubmissionBackend,
workflowFailureMode,
google_labels = Map("terra-submission-id" -> s"terra-${submission.id.toString}"),
ignoreEmptyOutputs,
Expand Down Expand Up @@ -467,6 +480,7 @@ trait WorkflowSubmission extends FutureSupport with LazyLogging with MethodWiths
monitoringImageScript = submissionRec.monitoringImageScript
)
} yield {
logger.error("Test workflow options: " + wfOpts.toString);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove or demote below error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my standalone comment below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove this log before merging.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is still here!

val submissionAndWorkspaceLabels =
Map("submission-id" -> submissionRec.id.toString, "workspace-id" -> workspaceRec.id.toString)
val wfLabels = workspaceRec.workflowCollection match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ object BootMonitors extends LazyLogging {
useWorkflowCollectionLabel: Boolean,
defaultNetworkCromwellBackend: CromwellBackend,
highSecurityNetworkCromwellBackend: CromwellBackend,
gcpBatchBackend: CromwellBackend,
methodConfigResolver: MethodConfigResolver,
bardService: BardService,
workspaceSettingRepository: WorkspaceSettingRepository
Expand Down Expand Up @@ -147,6 +148,7 @@ object BootMonitors extends LazyLogging {
useWorkflowCollectionLabel,
defaultNetworkCromwellBackend,
highSecurityNetworkCromwellBackend,
gcpBatchBackend,
methodConfigResolver,
bardService,
workspaceSettingRepository
Expand Down Expand Up @@ -338,6 +340,7 @@ object BootMonitors extends LazyLogging {
useWorkflowCollectionLabel: Boolean,
defaultNetworkCromwellBackend: CromwellBackend,
highSecurityNetworkCromwellBackend: CromwellBackend,
gcpBatchBackend: CromwellBackend,
methodConfigResolver: MethodConfigResolver,
bardService: BardService,
workspaceSettingRepository: WorkspaceSettingRepository
Expand Down Expand Up @@ -366,6 +369,7 @@ object BootMonitors extends LazyLogging {
useWorkflowCollectionLabel,
defaultNetworkCromwellBackend,
highSecurityNetworkCromwellBackend,
gcpBatchBackend,
methodConfigResolver,
bardService,
workspaceSettingRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import org.broadinstitute.dsde.rawls.dataaccess._
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any non-scalafmt or whitespace changes to this file? If not, can you back out these changes? It's better to not have files modified at all if we don't need to change them functionally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty certain that I made the commit to scalafmt this file because it was giving me an error on the scalafmt PR check. I see that that action claims to check only modified files, but maybe that file was being checked because the merge commit from dev modified it. Is there a way to revert the scalafmt changes without failing the check?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, maybe reverse all of the changes so that the diff between this branch and develop includes no change to this file, and see how it feels? It sounds like that might be the state you started in, but worth going back to that so we can try again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was about to revert the commit that scalafmt-ed this file, but I decided to check the diff first and I couldn't see my changes anymore. It turns out that Bria must have been having the same problem, and this PR that was merged yesterday also fixed the formatting. Does it matter now whether or not I revert the commit that made the same changes on my branch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, if the diff looks good you're all set!

import org.broadinstitute.dsde.rawls.dataaccess.slick.{TestDriverComponent, WorkflowRecord}
import org.broadinstitute.dsde.rawls.expressions.{BoundOutputExpression, OutputExpression}
import org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorActor.{ExecutionServiceStatusResponse, StatusCheckComplete}
import org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorActor.{
ExecutionServiceStatusResponse,
StatusCheckComplete
}
import org.broadinstitute.dsde.rawls.metrics.RawlsStatsDTestUtils
import org.broadinstitute.dsde.rawls.mock.{MockSamDAO, RemoteServicesMockServer}
import org.broadinstitute.dsde.rawls.model._
Expand Down Expand Up @@ -39,7 +42,7 @@
* Created by dvoet on 7/1/15.
*/
//noinspection NameBooleanParameters,ScalaUnnecessaryParentheses,TypeAnnotation,ScalaUnusedSymbol
class SubmissionMonitorSpec(_system: ActorSystem)

Check failure on line 45 in core/src/test/scala/org/broadinstitute/dsde/rawls/jobexec/SubmissionMonitorSpec.scala

View workflow job for this annotation

GitHub Actions / Test Report push

SubmissionMonitorSpec.SubmissionMonitor should save workflow error messages

Expected List(AttributeString("a"), AttributeString("b")), but got Vector(AttributeString("b"), AttributeString("a"))
Raw output
org.scalatest.exceptions.TestFailedException: Expected List(AttributeString("a"), AttributeString("b")), but got Vector(AttributeString("b"), AttributeString("a"))
	at org.scalatest.Assertions.newAssertionFailedException(Assertions.scala:472)
	at org.scalatest.Assertions.newAssertionFailedException$(Assertions.scala:471)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.newAssertionFailedException(SubmissionMonitorSpec.scala:45)
	at org.scalatest.Assertions.assertResult(Assertions.scala:867)
	at org.scalatest.Assertions.assertResult$(Assertions.scala:863)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.assertResult(SubmissionMonitorSpec.scala:45)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.$anonfun$new$106(SubmissionMonitorSpec.scala:815)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.$anonfun$new$102(SubmissionMonitorSpec.scala:814)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
	at org.broadinstitute.dsde.rawls.metrics.StatsDTestUtils.withStatsD(StatsDTestUtils.scala:32)
	at org.broadinstitute.dsde.rawls.metrics.StatsDTestUtils.withStatsD$(StatsDTestUtils.scala:22)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.withStatsD(SubmissionMonitorSpec.scala:45)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.$anonfun$new$101(SubmissionMonitorSpec.scala:819)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.$anonfun$new$101$adapted(SubmissionMonitorSpec.scala:794)
	at org.broadinstitute.dsde.rawls.dataaccess.slick.TestDriverComponent.$anonfun$withDefaultTestDatabase$1(TestDriverComponent.scala:2552)
	at org.broadinstitute.dsde.rawls.dataaccess.slick.TestDriverComponent.withCustomTestDatabaseInternal(TestDriverComponent.scala:2579)
	at org.broadinstitute.dsde.rawls.dataaccess.slick.TestDriverComponent.withCustomTestDatabaseInternal$(TestDriverComponent.scala:2575)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.withCustomTestDatabaseInternal(SubmissionMonitorSpec.scala:45)
	at org.broadinstitute.dsde.rawls.dataaccess.slick.TestDriverComponent.withCustomTestDatabaseInternal(TestDriverComponent.scala:2573)
	at org.broadinstitute.dsde.rawls.dataaccess.slick.TestDriverComponent.withCustomTestDatabaseInternal$(TestDriverComponent.scala:2572)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.withCustomTestDatabaseInternal(SubmissionMonitorSpec.scala:45)
	at org.broadinstitute.dsde.rawls.dataaccess.slick.TestDriverComponent.withDefaultTestDatabase(TestDriverComponent.scala:2552)
	at org.broadinstitute.dsde.rawls.dataaccess.slick.TestDriverComponent.withDefaultTestDatabase$(TestDriverComponent.scala:2551)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.withDefaultTestDatabase(SubmissionMonitorSpec.scala:45)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.$anonfun$new$100(SubmissionMonitorSpec.scala:794)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
	at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
	at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
	at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
	at org.scalatest.Transformer.apply(Transformer.scala:22)
	at org.scalatest.Transformer.apply(Transformer.scala:20)
	at org.scalatest.flatspec.AnyFlatSpecLike$$anon$5.apply(AnyFlatSpecLike.scala:1832)
	at org.scalatest.TestSuite.withFixture(TestSuite.scala:196)
	at org.scalatest.TestSuite.withFixture$(TestSuite.scala:195)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.withFixture(SubmissionMonitorSpec.scala:45)
	at org.scalatest.flatspec.AnyFlatSpecLike.invokeWithFixture$1(AnyFlatSpecLike.scala:1830)
	at org.scalatest.flatspec.AnyFlatSpecLike.$anonfun$runTest$1(AnyFlatSpecLike.scala:1842)
	at org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)
	at org.scalatest.flatspec.AnyFlatSpecLike.runTest(AnyFlatSpecLike.scala:1842)
	at org.scalatest.flatspec.AnyFlatSpecLike.runTest$(AnyFlatSpecLike.scala:1824)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.runTest(SubmissionMonitorSpec.scala:45)
	at org.scalatest.flatspec.AnyFlatSpecLike.$anonfun$runTests$1(AnyFlatSpecLike.scala:1900)
	at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:413)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:390)
	at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:427)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:396)
	at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:475)
	at org.scalatest.flatspec.AnyFlatSpecLike.runTests(AnyFlatSpecLike.scala:1900)
	at org.scalatest.flatspec.AnyFlatSpecLike.runTests$(AnyFlatSpecLike.scala:1899)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.runTests(SubmissionMonitorSpec.scala:45)
	at org.scalatest.Suite.run(Suite.scala:1114)
	at org.scalatest.Suite.run$(Suite.scala:1096)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.org$scalatest$flatspec$AnyFlatSpecLike$$super$run(SubmissionMonitorSpec.scala:45)
	at org.scalatest.flatspec.AnyFlatSpecLike.$anonfun$run$1(AnyFlatSpecLike.scala:1945)
	at org.scalatest.SuperEngine.runImpl(Engine.scala:535)
	at org.scalatest.flatspec.AnyFlatSpecLike.run(AnyFlatSpecLike.scala:1945)
	at org.scalatest.flatspec.AnyFlatSpecLike.run$(AnyFlatSpecLike.scala:1943)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.org$scalatest$BeforeAndAfterAll$$super$run(SubmissionMonitorSpec.scala:45)
	at org.scalatest.BeforeAndAfterAll.liftedTree1$1(BeforeAndAfterAll.scala:213)
	at org.scalatest.BeforeAndAfterAll.run(BeforeAndAfterAll.scala:210)
	at org.scalatest.BeforeAndAfterAll.run$(BeforeAndAfterAll.scala:208)
	at org.broadinstitute.dsde.rawls.jobexec.SubmissionMonitorSpec.run(SubmissionMonitorSpec.scala:45)
	at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:321)
	at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:517)
	at sbt.TestRunner.runTest$1(TestFramework.scala:153)
	at sbt.TestRunner.run(TestFramework.scala:168)
	at sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1.$anonfun$apply$1(TestFramework.scala:336)
	at sbt.TestFramework$.sbt$TestFramework$$withContextLoader(TestFramework.scala:296)
	at sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1.apply(TestFramework.scala:336)
	at sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1.apply(TestFramework.scala:336)
	at sbt.TestFunction.apply(TestFramework.scala:348)
	at sbt.Tests$.processRunnable$1(Tests.scala:475)
	at sbt.Tests$.$anonfun$makeSerial$1(Tests.scala:481)
	at sbt.std.Transform$$anon$3.$anonfun$apply$2(Transform.scala:47)
	at sbt.std.Transform$$anon$4.work(Transform.scala:69)
	at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
	at sbt.Execute.work(Execute.scala:292)
	at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
extends TestKit(_system)
with AnyFlatSpecLike
with Matchers
Expand Down Expand Up @@ -1348,22 +1351,33 @@
dataSource: SlickDataSource =>
val cheapWorkflowId = UUID.randomUUID().toString
val expensiveWorkflowId = UUID.randomUUID().toString
val cheapWorkflow = Workflow(Some(cheapWorkflowId), WorkflowStatuses.Submitted, new DateTime(), Some(testData.sample1.toReference), Seq.empty)
val expensiveWorkflow = Workflow(Some(expensiveWorkflowId), WorkflowStatuses.Submitted, new DateTime(), Some(testData.sample2.toReference), Seq.empty)
val submission = testData.submission1.copy(submissionId = UUID.randomUUID().toString, workflows = Seq(cheapWorkflow, expensiveWorkflow))
val cheapWorkflow = Workflow(Some(cheapWorkflowId),
WorkflowStatuses.Submitted,
new DateTime(),
Some(testData.sample1.toReference),
Seq.empty
)
val expensiveWorkflow = Workflow(Some(expensiveWorkflowId),
WorkflowStatuses.Submitted,
new DateTime(),
Some(testData.sample2.toReference),
Seq.empty
)
val submission = testData.submission1.copy(submissionId = UUID.randomUUID().toString,
workflows = Seq(cheapWorkflow, expensiveWorkflow)
)
runAndWait(submissionQuery.create(testData.workspace, submission))
runAndWait(updateWorkflowExecutionServiceKey("unittestdefault"))

class CostCapTestExecutionServiceDAO(status: String) extends SubmissionTestExecutionServiceDAO(status) {
override def getCost(id: String, userInfo: UserInfo): Future[WorkflowCostBreakdown] = {
override def getCost(id: String, userInfo: UserInfo): Future[WorkflowCostBreakdown] =
if (id.equals(cheapWorkflowId)) {
Future.successful(WorkflowCostBreakdown(id, BigDecimal(1), "USD", status, Seq.empty))
} else if (id.equals(expensiveWorkflowId)) {
Future.successful(WorkflowCostBreakdown(id, BigDecimal(11), "USD", status, Seq.empty))
} else {
Future.failed(new Exception("Unexpected workflow ID"))
}
}
}

val monitor = createSubmissionMonitor(
Expand All @@ -1377,7 +1391,8 @@
)

val workflowCosts = await(monitor.queryExecutionServiceForStatus()).statusResponse.collect {
case Success(Some(recordWithOutputs)) => recordWithOutputs._1.externalId.get -> (recordWithOutputs._1.status, recordWithOutputs._1.cost)
case Success(Some(recordWithOutputs)) =>
recordWithOutputs._1.externalId.get -> (recordWithOutputs._1.status, recordWithOutputs._1.cost)
}.toMap

workflowCosts(cheapWorkflowId) shouldEqual (WorkflowStatuses.Running.toString, Option(BigDecimal(1)))
Expand Down
Loading
Loading