Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
omnipresent07 committed Jan 6, 2020
1 parent e71ea3d commit dc675ed
Show file tree
Hide file tree
Showing 10 changed files with 884 additions and 886 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ lazy val slickDeps = Seq(slick, slickHikaryCP, postgres, h2)

lazy val dockerSettings = Seq(
Docker / maintainer := "Hmda-Ops",
dockerBaseImage := "openjdk:11",
dockerBaseImage := "openjdk:11-jre-slim",
dockerRepository := Some("hmda")
)

Expand Down
2 changes: 1 addition & 1 deletion commercial-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ lazy val slickDeps = Seq(slick, slickHikaryCP, postgres, h2)

lazy val dockerSettings = Seq(
Docker / maintainer := "Hmda-Ops",
dockerBaseImage := "openjdk:11",
dockerBaseImage := "openjdk:11-jre-slim",
dockerRepository := Some("hmda")
)

Expand Down
145 changes: 74 additions & 71 deletions hmda/src/main/resources/application-kubernetes.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ akka {
diagnostics {
starvation-detector {
check-interval = 1s
// initial-delay = 8s TODO: bump it up before master
initial-delay = 30s
max-delay-warning-threshold = 100 ms
warning-interval = 10 seconds
}
Expand Down Expand Up @@ -108,73 +108,76 @@ akka {
}
}

cinnamon.application = "hmda-platform"

cinnamon.akka {
// monitor all actors
// see https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka/akka.html
actors {
"/user/*" {
report-by = class
metrics {
mailbox-size {
sampling-period = 100ms
}
stash-size {
sampling-period = 100ms
}
}
}
}

// monitor the named-example stream that we have explicitly instrumented
// see https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka-streams/akka-streams.html
streams {
"hmda.persistence.submission.*" {
report-by = name
}
}

persistence.entities {
"*" {
report-by = class
command-type = on
}
}

// https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka/akka.html#actor-remote-metrics
remote.serialization-timing = on
remote.failure-detector-metrics = on

// https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka/akka.html#cluster-events
cluster.domain-events = on
cluster.member-events = on
cluster.shard-region-info = on




// monitor akka http paths
// see https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka-http/akka-http-configuration.html#example-configuration-1
http {
servers {
"*:*" {
paths {
"*" {
metrics = on
}
}
}
}
}
}
// expose the HTTP metrics server that Prometheus will scrape to gather metrics
cinnamon.prometheus {
http-server {
port = 9001
daemon = false
}

// runs on port 9001
exporters += http-server
}
//Cinnamon is commented out until issues around long[] staying in memory are resolved.

//
//cinnamon.application = "hmda-platform"
//
//cinnamon.akka {
// // monitor all actors
// // see https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka/akka.html
// actors {
// "/user/*" {
// report-by = class
// metrics {
// mailbox-size {
// sampling-period = 100ms
// }
// stash-size {
// sampling-period = 100ms
// }
// }
// }
// }
//
// // monitor the named-example stream that we have explicitly instrumented
// // see https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka-streams/akka-streams.html
// streams {
// "hmda.persistence.submission.*" {
// report-by = name
// }
// }
//
// persistence.entities {
// "*" {
// report-by = class
// command-type = on
// }
// }
//
// // https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka/akka.html#actor-remote-metrics
// remote.serialization-timing = on
// remote.failure-detector-metrics = on
//
//// https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka/akka.html#cluster-events
// cluster.domain-events = on
// cluster.member-events = on
// cluster.shard-region-info = on
//
//
//
//
// // monitor akka http paths
// // see https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka-http/akka-http-configuration.html#example-configuration-1
// http {
// servers {
// "*:*" {
// paths {
// "*" {
// metrics = on
// }
// }
// }
// }
// }
//}
//// expose the HTTP metrics server that Prometheus will scrape to gather metrics
//cinnamon.prometheus {
// http-server {
// port = 9001
// daemon = false
// }
//
// // runs on port 9001
// exporters += http-server
//}
2 changes: 1 addition & 1 deletion hmda/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ akka {
failure-detector.acceptable-heartbeat-pause = 12
metrics.enabled = off
sharding {
// number-of-shards = 500
number-of-shards = 500
passivate-idle-entity-after = 2 minutes
passivate-idle-entity-after = ${?AKKA_CLUSTER_IDLE_ENTITY_TIMEOUT}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,9 @@ object HmdaValidationError
val log = ctx.asScala.log
implicit val system: UntypedActorSystem = ctx.asScala.system.toUntyped
implicit val materializer: ActorMaterializer = ActorMaterializer()
// implicit val ec: ExecutionContext = system.dispatcher
implicit val blockingEc: ExecutionContext =
system.dispatchers.lookup("akka.blocking-quality-dispatcher")

//Temporarily commented out since adding this bit throws an OOM
// StarvationDetector.checkExecutionContext(blockingEc, system.log, StarvationDetectorSettings.fromConfig(
// system.settings.config.getConfig("akka.diagnostics.starvation-detector")), () => system.whenTerminated.isCompleted)

val sharding = ClusterSharding(ctx.asScala.system)

cmd match {
Expand Down
164 changes: 82 additions & 82 deletions hmda/src/test/scala/hmda/api/http/filing/FilingHttpApiSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,86 +28,86 @@ import scala.concurrent.ExecutionContext
import scala.concurrent.duration._
import scala.util.Random

class FilingHttpApiSpec {
// extends AkkaCassandraPersistenceSpec
// with MustMatchers
// with FilingHttpApi
// with ScalatestRouteTest {
//
// val duration = 10.seconds
//
// implicit val routeTimeout = RouteTestTimeout(duration.dilated)
//
// override implicit val typedSystem: ActorSystem[_] = system.toTyped
// override val log: LoggingAdapter = NoLogging
// val ec: ExecutionContext = system.dispatcher
// override implicit val timeout: Timeout = Timeout(duration)
// override val sharding: ClusterSharding = ClusterSharding(typedSystem)
//
// val oAuth2Authorization = OAuth2Authorization(
// log,
// new KeycloakTokenVerifier(
// KeycloakDeploymentBuilder.build(
// getClass.getResourceAsStream("/keycloak.json")
// )
// )
// )
//
// val sampleInstitution = institutionGen
// .suchThat(_.LEI != "")
// .sample
// .getOrElse(
// Institution.empty.copy(LEI = Random.alphanumeric.take(10).mkString))
//
// val period = "2018"
//
// val institutionProbe = TestProbe[InstitutionEvent]("institution-probe")
//
// override def beforeAll(): Unit = {
// super.beforeAll()
// Cluster(typedSystem).manager ! Join(Cluster(typedSystem).selfMember.address)
// InstitutionPersistence.startShardRegion(sharding)
// FilingPersistence.startShardRegion(sharding)
// val institutionPersistence =
// sharding.entityRefFor(
// InstitutionPersistence.typeKey,
// s"${InstitutionPersistence.name}-${sampleInstitution.LEI}")
// institutionPersistence ! CreateInstitution(sampleInstitution,
// institutionProbe.ref)
// institutionProbe.expectMessage(InstitutionCreated(sampleInstitution))
// }
//
// override def afterAll(): Unit = super.afterAll()
//
// val url = s"/institutions/${sampleInstitution.LEI}/filings/$period"
// val badUrl = s"/institutions/xxxx/filings/$period"
//
// "Filings" must {
// "return Bad Request when institution does not exist" in {
// Get(badUrl) ~> filingRoutes(oAuth2Authorization) ~> check {
// status mustBe StatusCodes.BadRequest
// }
// }
// "return NotFound when institution exists but filing has not been created" in {
// Get(url) ~> filingRoutes(oAuth2Authorization) ~> check {
// status mustBe StatusCodes.NotFound
// }
// }
// "create filing and return it" in {
// Post(url) ~> filingRoutes(oAuth2Authorization) ~> check {
// status mustBe StatusCodes.Created
// val details = responseAs[FilingDetails]
// details.filing.lei mustBe sampleInstitution.LEI
// details.filing.period mustBe period
// details.filing.status mustBe InProgress
// details.submissions mustBe Nil
// }
// Post(url) ~> filingRoutes(oAuth2Authorization) ~> check {
// status mustBe StatusCodes.BadRequest
// }
// Post(badUrl) ~> filingRoutes(oAuth2Authorization) ~> check {
// status mustBe StatusCodes.BadRequest
// }
// }
// }
class FilingHttpApiSpec
extends AkkaCassandraPersistenceSpec
with MustMatchers
with FilingHttpApi
with ScalatestRouteTest {

val duration = 10.seconds

implicit val routeTimeout = RouteTestTimeout(duration.dilated)

override implicit val typedSystem: ActorSystem[_] = system.toTyped
override val log: LoggingAdapter = NoLogging
val ec: ExecutionContext = system.dispatcher
override implicit val timeout: Timeout = Timeout(duration)
override val sharding: ClusterSharding = ClusterSharding(typedSystem)

val oAuth2Authorization = OAuth2Authorization(
log,
new KeycloakTokenVerifier(
KeycloakDeploymentBuilder.build(
getClass.getResourceAsStream("/keycloak.json")
)
)
)

val sampleInstitution = institutionGen
.suchThat(_.LEI != "")
.sample
.getOrElse(
Institution.empty.copy(LEI = Random.alphanumeric.take(10).mkString))

val period = "2018"

val institutionProbe = TestProbe[InstitutionEvent]("institution-probe")

override def beforeAll(): Unit = {
super.beforeAll()
Cluster(typedSystem).manager ! Join(Cluster(typedSystem).selfMember.address)
InstitutionPersistence.startShardRegion(sharding)
FilingPersistence.startShardRegion(sharding)
val institutionPersistence =
sharding.entityRefFor(
InstitutionPersistence.typeKey,
s"${InstitutionPersistence.name}-${sampleInstitution.LEI}")
institutionPersistence ! CreateInstitution(sampleInstitution,
institutionProbe.ref)
institutionProbe.expectMessage(InstitutionCreated(sampleInstitution))
}

override def afterAll(): Unit = super.afterAll()

val url = s"/institutions/${sampleInstitution.LEI}/filings/$period"
val badUrl = s"/institutions/xxxx/filings/$period"

"Filings" must {
"return Bad Request when institution does not exist" in {
Get(badUrl) ~> filingRoutes(oAuth2Authorization) ~> check {
status mustBe StatusCodes.BadRequest
}
}
"return NotFound when institution exists but filing has not been created" in {
Get(url) ~> filingRoutes(oAuth2Authorization) ~> check {
status mustBe StatusCodes.NotFound
}
}
"create filing and return it" in {
Post(url) ~> filingRoutes(oAuth2Authorization) ~> check {
status mustBe StatusCodes.Created
val details = responseAs[FilingDetails]
details.filing.lei mustBe sampleInstitution.LEI
details.filing.period mustBe period
details.filing.status mustBe InProgress
details.submissions mustBe Nil
}
Post(url) ~> filingRoutes(oAuth2Authorization) ~> check {
status mustBe StatusCodes.BadRequest
}
Post(badUrl) ~> filingRoutes(oAuth2Authorization) ~> check {
status mustBe StatusCodes.BadRequest
}
}
}
}
Loading

0 comments on commit dc675ed

Please sign in to comment.