diff --git a/native-image-tests/build.sbt b/native-image-tests/build.sbt index 1af47ce0..d26cd73a 100644 --- a/native-image-tests/build.sbt +++ b/native-image-tests/build.sbt @@ -2,7 +2,7 @@ name := "native-image-tests" version := "1.0" -scalaVersion := s"2.13.12" +scalaVersion := "2.13.12" resolvers += "Akka library repository".at("https://repo.akka.io/maven") @@ -47,5 +47,6 @@ nativeImageVersion := "21.0.2" nativeImageOptions := Seq( "--no-fallback", "--verbose", + "--initialize-at-build-time=ch.qos.logback", "-Dakka.native-image.debug=true" ) diff --git a/native-image-tests/src/main/resources/application.conf b/native-image-tests/src/main/resources/application.conf index f921292b..13a4f6d6 100644 --- a/native-image-tests/src/main/resources/application.conf +++ b/native-image-tests/src/main/resources/application.conf @@ -34,4 +34,7 @@ akka { cluster { downing-provider-class = "akka.cluster.sbr.SplitBrainResolverProvider" } -} \ No newline at end of file +} + +# just to keep the class name out of graalvms sight +pod-cost-class = "akka.rollingupdate.kubernetes.PodDeletionCost" \ No newline at end of file diff --git a/native-image-tests/src/main/resources/logback.xml b/native-image-tests/src/main/resources/logback.xml index b1fe9ae9..7aff0586 100644 --- a/native-image-tests/src/main/resources/logback.xml +++ b/native-image-tests/src/main/resources/logback.xml @@ -7,14 +7,8 @@ - - 1024 - true - - - - + diff --git a/native-image-tests/src/main/scala/com/lightbend/Main.scala b/native-image-tests/src/main/scala/com/lightbend/Main.scala index 680ad2f7..637e5b82 100644 --- a/native-image-tests/src/main/scala/com/lightbend/Main.scala +++ b/native-image-tests/src/main/scala/com/lightbend/Main.scala @@ -1,16 +1,40 @@ package com.lightbend +import akka.actor.ExtendedActorSystem +import akka.actor.ExtensionId 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.coordination.lease.LeaseSettings import akka.management.scaladsl.AkkaManagement import scala.concurrent.duration.DurationInt object RootBehavior { + + def checkK8Lease(system: ActorSystem[_]): Unit = { + // this throws if not all spray-json metadata in place + new akka.coordination.lease.kubernetes.internal.KubernetesJsonSupport {} + + // we can't really set up the lease but it is expected to be constructed via config/reflection, so let's check access + // that native-image can't guess + val exensionNameClass = system.settings.config.getString("akka.coordination.lease.kubernetes.lease-class") + val clazz = system.dynamicAccess.getClassFor[akka.coordination.lease.scaladsl.Lease](exensionNameClass).get + // we cant really call it though, but would get a NoSuchMethod here if it can't be found + clazz.getConstructor(classOf[LeaseSettings], classOf[ExtendedActorSystem]) + + } + + def checkK8RollingUpdate(system: ActorSystem[_]): Unit = { + // this throws if not all spray-json metadata in place + new akka.rollingupdate.kubernetes.KubernetesJsonSupport {} + val extensionClazzName = system.settings.config.getString("pod-cost-class") + system.dynamicAccess.getObjectFor[ExtensionId[_]](extensionClazzName).get + } + 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 @@ -18,8 +42,9 @@ object RootBehavior { timers.startSingleTimer("Timeout", 30.seconds) Cluster(context.system).subscriptions ! Subscribe(context.self, classOf[SelfUp]) - // FIXME cover k8 lease - // FIXME cover rolling-update + // best effort coverage of k8 lease and rolling update without actually using them + checkK8RollingUpdate(context.system) + checkK8Lease(context.system) Behaviors.receiveMessagePartial { case SelfUp(_) =>