diff --git a/backend/src/main/scala/cromwell/backend/standard/StandardAsyncExecutionActor.scala b/backend/src/main/scala/cromwell/backend/standard/StandardAsyncExecutionActor.scala index 12cbf7d6cef..59eb7f08269 100644 --- a/backend/src/main/scala/cromwell/backend/standard/StandardAsyncExecutionActor.scala +++ b/backend/src/main/scala/cromwell/backend/standard/StandardAsyncExecutionActor.scala @@ -426,10 +426,12 @@ trait StandardAsyncExecutionActor |find . -type d -exec sh -c '[ -z "$$(ls -A '"'"'{}'"'"')" ] && touch '"'"'{}'"'"'/.file' \\; |)""".stripMargin) + val errorOrPreamble: ErrorOr[String] = scriptPreamble + // The `tee` trickery below is to be able to redirect to known filenames for CWL while also streaming // stdout and stderr for PAPI to periodically upload to cloud storage. // https://stackoverflow.com/questions/692000/how-do-i-write-stderr-to-a-file-while-using-tee-with-a-pipe - (errorOrDirectoryOutputs, errorOrGlobFiles, scriptPreamble).mapN((directoryOutputs, globFiles, preamble) => + (errorOrDirectoryOutputs, errorOrGlobFiles, errorOrPreamble).mapN((directoryOutputs, globFiles, preamble) => s"""|#!$jobShell |DOCKER_OUTPUT_DIR_LINK |cd ${cwd.pathAsString} diff --git a/supportedBackends/tes/src/test/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActorSpec.scala b/supportedBackends/tes/src/test/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActorSpec.scala index f7de7f318a4..eafd059f817 100644 --- a/supportedBackends/tes/src/test/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActorSpec.scala +++ b/supportedBackends/tes/src/test/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActorSpec.scala @@ -2,12 +2,10 @@ package cromwell.backend.impl.tes import common.mock.MockSugar import cromwell.core.logging.JobLogger -import cromwell.core.path import cromwell.filesystems.blob.{BlobFileSystemManager, BlobPath, WSMBlobSasTokenGenerator} +import org.mockito.ArgumentMatchers.any import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers - -import java.nio.file.Path import java.time.Duration import java.time.temporal.ChronoUnit import scala.util.{Failure, Try} @@ -65,30 +63,28 @@ class TesAsyncBackendJobExecutionActorSpec extends AnyFlatSpec with Matchers wit val testWorkspaceId = "e58ed763-928c-4155-0000-fdbaaadc15f3" val testContainerResourceId = "e58ed763-928c-4155-1111-fdbaaadc15f3" + def generateMockWsmTokenGenerator: WSMBlobSasTokenGenerator = { + val mockTokenGenerator = mock[WSMBlobSasTokenGenerator] + val expectedTokenDuration: Duration = Duration.of(24, ChronoUnit.HOURS) + mockTokenGenerator.getWSMSasFetchEndpoint(any[BlobPath], any[Option[Duration]]) returns Try(s"$testWsmEndpoint/api/workspaces/v1/$testWorkspaceId/resources/controlled/azure/storageContainer/$testContainerResourceId/getSasToken?sasExpirationDuration=${expectedTokenDuration.getSeconds.toInt}") + mockTokenGenerator + } + def generateMockFsm: BlobFileSystemManager = { + val mockFsm: BlobFileSystemManager = mock[BlobFileSystemManager] + val mockGenerator: WSMBlobSasTokenGenerator = generateMockWsmTokenGenerator + mockFsm.blobTokenGenerator returns mockGenerator + mockFsm + } //path to a blob file def generateMockBlobPath: BlobPath = { - val mockCromwellPath: cromwell.core.path.Path = mock[cromwell.core.path.Path] - mockCromwellPath.normalize() returns mockCromwellPath - val mockNioPath: path.NioPath = mock[path.NioPath] - val mockJavaPath: Path = mock[java.nio.file.Path] - mockNioPath.toAbsolutePath returns mockJavaPath - mockNioPath.normalize() returns mockNioPath - val mockBlobPath = mock[BlobPath] - mockBlobPath.nioPath returns mockNioPath - mockBlobPath.toAbsolutePath returns mockCromwellPath mockBlobPath.md5 returns "BLOB_MD5" - - val mockTokenGenerator: WSMBlobSasTokenGenerator = mock[WSMBlobSasTokenGenerator] - val mockFsm: BlobFileSystemManager = mock[BlobFileSystemManager] - val expectedTokenDuration: Duration = Duration.of(24, ChronoUnit.HOURS) - mockTokenGenerator.getWSMSasFetchEndpoint(mockBlobPath, Some(expectedTokenDuration)) returns Try(s"$testWsmEndpoint/api/workspaces/v1/$testWorkspaceId/resources/controlled/azure/storageContainer/$testContainerResourceId/getSasToken?sasExpirationDuration=${expectedTokenDuration.getSeconds.toInt}") - mockFsm.blobTokenGenerator returns mockTokenGenerator + val mockFsm = generateMockFsm mockBlobPath.getFilesystemManager returns mockFsm - mockBlobPath } + //Path to a file that isn't a blob file def generateMockDefaultPath: cromwell.core.path.Path = { val mockDefaultPath: cromwell.core.path.Path = mock[cromwell.core.path.Path]