Skip to content

Commit

Permalink
distage-testkit: Smart memoization group merging. (#1072)
Browse files Browse the repository at this point in the history
* wip

* something works, need to test

* only one shared plan and runtime plan per env, remove memoized groups, producing primary shared plan

* memoiz loaded configs, split test and main loggers, add new tests

* layout

* typo

* adjust logger context

* adjust envs logging
  • Loading branch information
Caparow committed May 22, 2020
1 parent 1df6d47 commit e9354b0
Show file tree
Hide file tree
Showing 5 changed files with 422 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,24 @@ trait IntegrationChecker[F[_]] {

object IntegrationChecker {

class Impl[F[_]]
(
logger: IzLogger,
)(implicit protected val tag: TagK[F]) extends IntegrationChecker[F] {
class Impl[F[_]](
logger: IzLogger
)(implicit protected val tag: TagK[F]
) extends IntegrationChecker[F] {

override def collectFailures(integrationComponents: Set[DIKey], integrationLocator: Locator): F[Either[Seq[ResourceCheck.Failure], Unit]] = {
logger.info(s"Going to check availability of ${integrationComponents.size -> "resources"} ${integrationComponents -> "resourceList"}")
if (integrationComponents.nonEmpty) {
logger.info(s"Going to check availability of ${integrationComponents.size -> "resources"} ${integrationComponents -> "resourceList"}")
}

implicit val F: DIEffect[F] = integrationLocator.get[DIEffect[F]]
implicit val P: DIEffectAsync[F] = integrationLocator.get[DIEffectAsync[F]]

val instances = integrationComponents.toList.map {
ick =>
ick -> integrationLocator.lookupInstance[Any](ick).map(_.asInstanceOf[IntegrationCheck])
}.toSet
val instances = integrationComponents
.toList.map {
ick =>
ick -> integrationLocator.lookupInstance[Any](ick).map(_.asInstanceOf[IntegrationCheck])
}.toSet

val good = instances.collect { case (_, Some(ic)) => ic }
val bad = instances.collect { case (ick, None) => ick }
Expand All @@ -70,10 +73,10 @@ object IntegrationChecker {
logger.debug(s"Checking $resource")
try {
resource.resourcesAvailable() match {
case failure@ResourceCheck.ResourceUnavailable(reason, Some(cause)) =>
case failure @ ResourceCheck.ResourceUnavailable(reason, Some(cause)) =>
logger.debug(s"Integration check failed, $resource unavailable: $reason, $cause")
Left(failure)
case failure@ResourceCheck.ResourceUnavailable(reason, None) =>
case failure @ ResourceCheck.ResourceUnavailable(reason, None) =>
logger.debug(s"Integration check failed, $resource unavailable: $reason")
Left(failure)
case ResourceCheck.Success() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ trait DistageTestEnv {
configBaseName = testConfig.configBaseName,
configOverrides = testConfig.configOverrides,
planningOptions = testConfig.planningOptions,
testRunnerLogLevel = testConfig.testRunnerLogLevel,
logLevel = testConfig.testRunnerLogLevel,
)
}

Expand Down
Loading

0 comments on commit e9354b0

Please sign in to comment.