-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
b568fac
commit 1a3a68e
Showing
6 changed files
with
176 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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
47 changes: 47 additions & 0 deletions
47
supportedBackends/tes/src/test/scala/cromwell/backend/impl/tes/TesConfigurationSpec.scala
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,47 @@ | ||
package cromwell.backend.impl.tes | ||
|
||
import com.typesafe.config.{Config, ConfigException, ConfigFactory} | ||
import cromwell.backend.BackendConfigurationDescriptor | ||
import cromwell.core.retry.SimpleExponentialBackoff | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
import scala.concurrent.duration._ | ||
import scala.language.postfixOps | ||
|
||
class TesConfigurationSpec extends AnyFlatSpec with Matchers { | ||
|
||
behavior of "TesConfiguration" | ||
|
||
def makeTesConfig(backendConfig: Config) = new TesConfiguration( | ||
BackendConfigurationDescriptor( | ||
backendConfig, | ||
ConfigFactory.empty() | ||
) | ||
) | ||
|
||
def backoffsAreEquivalent(expectedBackoff: SimpleExponentialBackoff, actualBackoff: SimpleExponentialBackoff): Boolean = { | ||
val b1 = expectedBackoff.googleBackoff | ||
val b2 = actualBackoff.googleBackoff | ||
b1.getInitialIntervalMillis == b2.getInitialIntervalMillis && | ||
b1.getMaxIntervalMillis == b2.getMaxIntervalMillis && | ||
b1.getMultiplier == b2.getMultiplier && | ||
b1.getRandomizationFactor == b2.getRandomizationFactor | ||
} | ||
|
||
it should "use default backoffs when no custom config provided" in { | ||
val tesConfig = makeTesConfig(TesTestConfig.backendConfig) | ||
backoffsAreEquivalent(TesConfiguration.defaultPollBackoff, tesConfig.pollBackoff) shouldBe true | ||
backoffsAreEquivalent(TesConfiguration.defaultExecOrRecoverBackoff, tesConfig.executeOrRecoverBackoff) shouldBe true | ||
} | ||
|
||
it should "use configured backoffs if they exist" in { | ||
val tesConfig = makeTesConfig(TesTestConfig.backendConfigWithBackoffs) | ||
backoffsAreEquivalent(SimpleExponentialBackoff(5 seconds, 1 minute, 2.5, .7), tesConfig.pollBackoff) shouldBe true | ||
backoffsAreEquivalent(SimpleExponentialBackoff(3 minutes, 1 hours, 5, .1), tesConfig.executeOrRecoverBackoff) shouldBe true | ||
} | ||
|
||
it should "fail if user defines an invalid backoff" in { | ||
assertThrows[ConfigException.Missing](makeTesConfig(TesTestConfig.backendConfigWithInvalidBackoffs)) | ||
} | ||
} |
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