-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
434cb7d
commit ceceaa3
Showing
9 changed files
with
172 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
target/ | ||
|
||
.settings | ||
.project | ||
.classpath | ||
|
||
.idea | ||
*.iml | ||
|
||
.metals | ||
.bloop | ||
.bsp |
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,51 @@ | ||
name := "native-image-tests" | ||
|
||
version := "1.0" | ||
|
||
scalaVersion := s"2.13.12" | ||
|
||
resolvers += "Akka library repository".at("https://repo.akka.io/maven") | ||
|
||
lazy val akkaVersion = sys.props.getOrElse("akka.version", "2.9.1") | ||
lazy val akkaHttpVersion = sys.props.getOrElse("akka.http.version", "10.6.0") | ||
|
||
// Note: this default isn't really used anywhere so not important to bump | ||
lazy val akkaManagementVersion = sys.props.getOrElse("akka.management.version", "1.5.0") | ||
|
||
// Run in a separate JVM, to make sure sbt waits until all threads have | ||
// finished before returning. | ||
// If you want to keep the application running while executing other | ||
// sbt tasks, consider https://github.com/spray/sbt-revolver/ | ||
fork := true | ||
|
||
libraryDependencies ++= Seq( | ||
"com.typesafe.akka" %% "akka-actor-typed" % akkaVersion, | ||
"com.typesafe.akka" %% "akka-cluster-typed" % akkaVersion, | ||
"com.typesafe.akka" %% "akka-cluster" % akkaVersion, | ||
"com.typesafe.akka" %% "akka-discovery" % akkaVersion, | ||
"com.typesafe.akka" %% "akka-persistence" % akkaVersion, | ||
"com.typesafe.akka" %% "akka-cluster-sharding" % akkaVersion, | ||
"com.typesafe.akka" %% "akka-remote" % akkaVersion, | ||
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion, | ||
"com.typesafe.akka" %% "akka-http-core" % akkaHttpVersion, | ||
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion, | ||
"com.lightbend.akka.management" %% "akka-management" % akkaManagementVersion, | ||
"com.lightbend.akka.management" %% "akka-management-cluster-bootstrap" % akkaManagementVersion, | ||
"com.lightbend.akka.management" %% "akka-management-cluster-http" % akkaManagementVersion, | ||
"com.lightbend.akka.discovery" %% "akka-discovery-kubernetes-api" % akkaManagementVersion, | ||
"com.lightbend.akka.management" %% "akka-lease-kubernetes" % akkaManagementVersion, | ||
"com.lightbend.akka.management" %% "akka-rolling-update-kubernetes" % akkaManagementVersion, | ||
"ch.qos.logback" % "logback-classic" % "1.2.13" | ||
) | ||
|
||
// useful for investigations: sbt nativeImageRunAgent | ||
|
||
// GraalVM native image build | ||
enablePlugins(NativeImagePlugin) | ||
nativeImageJvm := "graalvm-community" | ||
nativeImageVersion := "21.0.2" | ||
nativeImageOptions := Seq( | ||
"--no-fallback", | ||
"--verbose", | ||
"-Dakka.native-image.debug=true" | ||
) |
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 @@ | ||
sbt.version=1.9.8 |
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 @@ | ||
addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.4") |
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,37 @@ | ||
akka { | ||
actor.provider = "cluster" | ||
extensions = ["akka.management.cluster.bootstrap.ClusterBootstrap"] | ||
|
||
|
||
discovery { | ||
aggregate { | ||
discovery-methods = ["kubernetes-api", "config"] | ||
} | ||
config.services.local-cluster.endpoints = [ | ||
{ | ||
host = "127.0.0.1" | ||
port = 8558 | ||
} | ||
] | ||
} | ||
|
||
|
||
management { | ||
http.hostname = "127.0.0.1" | ||
http.port = 8558 | ||
cluster.bootstrap { | ||
contact-point-discovery { | ||
# to allow easier testing, we aggregate kubernetes-api and then use config as a fallback, | ||
# native-image-brokenness would cause class not found or linker error, so k8 api discovery failing because | ||
# not running inside k8 means things likely works as expected (not a watertight check though) | ||
discovery-method = aggregate | ||
service-name = "local-cluster" | ||
required-contact-point-nr = 1 | ||
} | ||
} | ||
} | ||
|
||
cluster { | ||
downing-provider-class = "akka.cluster.sbr.SplitBrainResolverProvider" | ||
} | ||
} |
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,20 @@ | ||
<configuration> | ||
<!-- This is a development logging configuration that logs to standard out, for an example of a production | ||
logging config, see the Akka docs: https://doc.akka.io/docs/akka/2.6/typed/logging.html#logback --> | ||
<appender name="STDOUT" target="System.out" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>[%date{ISO8601}] [%level] [%logger] [%thread] [%X{akkaSource}] - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender"> | ||
<queueSize>1024</queueSize> | ||
<neverBlock>true</neverBlock> | ||
<appender-ref ref="STDOUT" /> | ||
</appender> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="ASYNC"/> | ||
</root> | ||
|
||
</configuration> |
42 changes: 42 additions & 0 deletions
42
native-image-tests/src/main/scala/com/lightbend/Main.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,42 @@ | ||
package com.lightbend | ||
|
||
import akka.actor.typed.ActorSystem | ||
import akka.actor.typed.Behavior | ||
import akka.actor.typed.scaladsl.Behaviors | ||
import akka.cluster.typed.Cluster | ||
import akka.cluster.typed.SelfUp | ||
import akka.cluster.typed.Subscribe | ||
import akka.management.scaladsl.AkkaManagement | ||
|
||
import scala.concurrent.duration.DurationInt | ||
|
||
object RootBehavior { | ||
def apply(): Behavior[AnyRef] = Behaviors.setup { context => | ||
Behaviors.withTimers { timers => | ||
// Note that some exceptions in the log from k8 api discovery is expected, see application.conf | ||
AkkaManagement(context.system).start() | ||
timers.startSingleTimer("Timeout", 30.seconds) | ||
Cluster(context.system).subscriptions ! Subscribe(context.self, classOf[SelfUp]) | ||
|
||
// FIXME cover k8 lease | ||
// FIXME cover rolling-update | ||
|
||
Behaviors.receiveMessagePartial { | ||
case SelfUp(_) => | ||
context.log.info("Managed to bootstrap cluster, shutting down") | ||
Behaviors.stopped | ||
|
||
case "Timeout" => | ||
context.log.error("Didn't manage to bootstrap within 30s, something is off") | ||
System.exit(1) | ||
Behaviors.same | ||
} | ||
} | ||
} | ||
} | ||
|
||
object Main extends App { | ||
|
||
val system: ActorSystem[AnyRef] = ActorSystem(RootBehavior(), "ManagementNativeImageTests") | ||
|
||
} |