Fixed smoke tests and firther cleanup

This commit is contained in:
Francisco M. Aramburo Torres
2020-03-03 16:35:01 +01:00
parent 43de003d7c
commit 50a7a20e37
17 changed files with 51 additions and 196 deletions

View File

@@ -1,12 +1,4 @@
encryption.enabled = false
encryption.enabled = ${?BAAS_INGREDIENT_ENCRYPTION_ENABLED}
encryption.secret = ""
encryption.secret = ${?BAAS_INGREDIENT_ENCRYPTION_SECRET}
baas-component.http-api-port = "8080"
baas-component.http-api-port = ${?BAAS_COMPONENT_HTTP_API_PORT}

View File

@@ -1,8 +0,0 @@
encryption.enabled = false
encryption.enabled = ${?BAAS_INGREDIENT_ENCRYPTION_ENABLED}
encryption.secret = ""
encryption.secret = ${?BAAS_INGREDIENT_ENCRYPTION_SECRET}

View File

@@ -1,12 +1,4 @@
encryption.enabled = false
encryption.enabled = ${?BAAS_INGREDIENT_ENCRYPTION_ENABLED}
encryption.secret = ""
encryption.secret = ${?BAAS_INGREDIENT_ENCRYPTION_SECRET}
baas-component.http-api-port = "8080"
baas-component.http-api-port = ${?BAAS_COMPONENT_HTTP_API_PORT}

View File

@@ -1,12 +1,4 @@
encryption.enabled = false
encryption.enabled = ${?BAAS_INGREDIENT_ENCRYPTION_ENABLED}
encryption.secret = ""
encryption.secret = ${?BAAS_INGREDIENT_ENCRYPTION_SECRET}
baas-component.http-api-port = "8080"
baas-component.http-api-port = ${?BAAS_COMPONENT_HTTP_API_PORT}

View File

@@ -1,13 +1,5 @@
include "baker.conf"
encryption.enabled = false
encryption.enabled = ${?BAAS_INGREDIENT_ENCRYPTION_ENABLED}
encryption.secret = ""
encryption.secret = ${?BAAS_INGREDIENT_ENCRYPTION_SECRET}
baas-component.http-api-port = 8080
baas-component.http-api-port = ${?BAAS_COMPONENT_HTTP_API_PORT}

View File

@@ -43,12 +43,15 @@ object Main extends IOApp {
timeouts = AkkaBakerConfig.Timeouts.from(config),
bakerValidationSettings = AkkaBakerConfig.BakerValidationSettings.from(config)
)(system))
_ <- Resource.liftF(IO.async[Unit] { callback =>
Cluster(system).registerOnMemberUp {
callback(Right(()))
}
})
_ <- Resource.liftF(serviceDiscovery.plugBakerEventListeners(baker))
_ <- StateNodeService.resource(baker, hostname)
} yield ()
IO(Cluster(system).registerOnMemberUp {
mainResource.use(_ => IO.never).unsafeRunAsyncAndForget()
}).as(ExitCode.Success)
mainResource.use(_ => IO.never).as(ExitCode.Success)
}
}

View File

@@ -1,12 +1,3 @@
apiVersion: v1
data:
encryption-secret: c2VjcmV0
kind: Secret
metadata:
name: ingredient-encryption-secret
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
@@ -40,7 +31,7 @@ metadata:
name: baas-state-service
labels:
baas-component: state
run: baas-state-service
app: baas-state-service
spec:
selector:
app: baas-state
@@ -94,15 +85,9 @@ spec:
containerPort: 8080
protocol: TCP
env:
- name: BAAS_INGREDIENT_ENCRYPTION_ENABLED
value: "true"
- name: BAAS_INGREDIENT_ENCRYPTION_SECRET
valueFrom:
secretKeyRef:
name: ingredient-encryption-secret
key: encryption-secret
#namespace needed for akka discovery
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace

View File

@@ -49,13 +49,6 @@ spec:
containerPort: 8082
protocol: TCP
env:
- name: BAAS_INGREDIENT_ENCRYPTION_ENABLED
value: "true"
- name: BAAS_INGREDIENT_ENCRYPTION_SECRET
valueFrom:
secretKeyRef:
name: ingredient-encryption-secret
key: encryption-secret
- name: BAAS_STATE_NODE_HOSTNAME
value: http://baas-state-service:8081/
- name: BAAS_COMPONENT_HTTP_API_PORT

View File

@@ -36,14 +36,6 @@ spec:
- name: baas-interaction
image: interaction-webshop.webservice.reserveitemsinstance:3.0.2-SNAPSHOT
imagePullPolicy: Never
env:
- name: BAAS_INGREDIENT_ENCRYPTION_ENABLED
value: "true"
- name: BAAS_INGREDIENT_ENCRYPTION_SECRET
valueFrom:
secretKeyRef:
name: ingredient-encryption-secret
key: encryption-secret
readinessProbe:
httpGet:
path: /api/v3/health
@@ -97,14 +89,6 @@ spec:
- name: baas-interaction
image: interaction-webshop.webservice.shipitemsinstance:3.0.2-SNAPSHOT
imagePullPolicy: Never
env:
- name: BAAS_INGREDIENT_ENCRYPTION_ENABLED
value: "true"
- name: BAAS_INGREDIENT_ENCRYPTION_SECRET
valueFrom:
secretKeyRef:
name: ingredient-encryption-secret
key: encryption-secret
readinessProbe:
httpGet:
path: /api/v3/health
@@ -158,14 +142,6 @@ spec:
- name: baas-interaction
image: interaction-webshop.webservice.makepaymentinstance:3.0.2-SNAPSHOT
imagePullPolicy: Never
env:
- name: BAAS_INGREDIENT_ENCRYPTION_ENABLED
value: "true"
- name: BAAS_INGREDIENT_ENCRYPTION_SECRET
valueFrom:
secretKeyRef:
name: ingredient-encryption-secret
key: encryption-secret
readinessProbe:
httpGet:
path: /api/v3/health

View File

@@ -59,13 +59,6 @@ spec:
env:
- name: EXPOSE_EVENTS_PORT
value: "8081"
- name: BAAS_INGREDIENT_ENCRYPTION_ENABLED
value: "true"
- name: BAAS_INGREDIENT_ENCRYPTION_SECRET
valueFrom:
secretKeyRef:
name: ingredient-encryption-secret
key: encryption-secret
readinessProbe:
httpGet:
path: /api/v3/health
@@ -143,13 +136,6 @@ spec:
env:
- name: EXPOSE_EVENTS_PORT
value: "8081"
- name: BAAS_INGREDIENT_ENCRYPTION_ENABLED
value: "true"
- name: BAAS_INGREDIENT_ENCRYPTION_SECRET
valueFrom:
secretKeyRef:
name: ingredient-encryption-secret
key: encryption-secret
readinessProbe:
httpGet:
path: /api/v3/health

View File

@@ -124,7 +124,7 @@ abstract class BakeryFunSpec extends fixture.AsyncFunSpecLike {
_ <- exec(prefix, command = s"kubectl apply -f $kubernetesConfigPath -n $testUUID")
_ = if(args.skipCleanup) {
println(Console.YELLOW + s"### Will skip cleanup after the test, to manually clean the environment run: " + Console.RESET)
println(s"\n\tkubectl delete -f $kubernetesConfigPath -n $testUUID\n")
println(s"\n\tkubectl delete -f $kubernetesConfigPath -n $testUUID && kubectl delete namespace $testUUID\n")
}
} yield testUUID
}
@@ -139,29 +139,32 @@ abstract class BakeryFunSpec extends fixture.AsyncFunSpecLike {
IO( println(Console.GREEN + "Skipped startup, will run the tests immediately" + Console.RESET)) *> IO.pure(0)
}
val clientResource = BlazeClientBuilder[IO](executionContext).resource
val exampleAppClient = new ExampleAppClient(clientResource, args.clientAppHostname)
val recipeEventsClient = new EventListenerClient(clientResource, args.eventListenerHostname)
val bakerEventsClient = new EventListenerClient(clientResource, args.bakerEventListenerHostname)
val setupWaitTime = 1.minute
val setupWaitSplit = 3
val setupWaitTime = 5.minute
val setupWaitSplit = 60
def dontSkipTest: IO[Assertion] =
for {
namespace <- setup(createEnvironment)
_ <- within(setupWaitTime, setupWaitSplit)(for {
_ <- IO ( println(Console.GREEN + s"\nWaiting for environment (20s)..." + Console.RESET) )
_ <- getPods(namespace)
status <- exampleAppClient.ping
} yield assert(status.code == 200))
attempt <- runTest(TestContext(
clientApp = exampleAppClient,
recipeEventListener = recipeEventsClient,
bakerEventListener = bakerEventsClient
)).attempt
_ <- cleanup(deleteEnvironment(namespace))
outcome <- IO.fromEither(attempt)
outcome <- BlazeClientBuilder[IO](executionContext).resource.use { client =>
val exampleAppClient = new ExampleAppClient(client, args.clientAppHostname)
val recipeEventsClient = new EventListenerClient(client, args.eventListenerHostname)
val bakerEventsClient = new EventListenerClient(client, args.bakerEventListenerHostname)
for {
_ <- within(setupWaitTime, setupWaitSplit)(for {
_ <- IO ( println(Console.GREEN + s"\nWaiting for environment (5s)..." + Console.RESET) )
_ <- getPods(namespace)
status <- exampleAppClient.ping
} yield assert(status.code == 200))
attempt <- runTest(TestContext(
clientApp = exampleAppClient,
recipeEventListener = recipeEventsClient,
bakerEventListener = bakerEventsClient
)).attempt
_ <- cleanup(deleteEnvironment(namespace))
outcome <- IO.fromEither(attempt)
} yield outcome
}
} yield outcome
def skipTest: IO[Assertion] =

View File

@@ -1,14 +1,14 @@
package com.ing.baker.baas.smoke
import cats.effect.{ContextShift, IO, Resource, Timer}
import org.http4s.{Status, Uri}
import cats.effect.{ContextShift, IO, Timer}
import org.http4s.client.Client
import org.http4s.{Status, Uri}
class EventListenerClient(client: Resource[IO, Client[IO]], hostname: Uri)(implicit cs: ContextShift[IO], timer: Timer[IO]) {
class EventListenerClient(client: Client[IO], hostname: Uri)(implicit cs: ContextShift[IO], timer: Timer[IO]) {
def ping: IO[Status] =
client.use(_.statusFromUri(hostname / "api"))
client.statusFromUri(hostname / "api")
def events: IO[List[String]] =
client.use(_.expect[String](hostname / "api" / "events")).map(_.split(", ").toList)
client.expect[String](hostname / "api" / "events").map(_.split(", ").toList)
}

View File

@@ -1,6 +1,6 @@
package com.ing.baker.baas.smoke
import cats.effect.{ContextShift, IO, Resource, Timer}
import cats.effect.{ContextShift, IO, Timer}
import cats.implicits._
import io.circe.generic.auto._
import io.circe.syntax._
@@ -12,33 +12,33 @@ import org.http4s.{Status, Uri}
import webshop.webservice.WebShopService.Implicits._
import webshop.webservice.WebShopService._
class ExampleAppClient(client: Resource[IO, Client[IO]], hostname: Uri)(implicit cs: ContextShift[IO], timer: Timer[IO]) {
class ExampleAppClient(client: Client[IO], hostname: Uri)(implicit cs: ContextShift[IO], timer: Timer[IO]) {
def ping: IO[Status] =
client.use(_.statusFromUri(hostname / "api"))
client.statusFromUri(hostname / "api")
def createCheckoutOrder(items: List[String]): IO[String] = {
val request = POST(
PlaceOrderRequest(items).asJson,
hostname / "api" / "order")
client.use(_.expect[PlaceOrderResponse](request)).map(_.orderId)
client.expect[PlaceOrderResponse](request).map(_.orderId)
}
def addCheckoutAddressInfo(orderId: String, address: String): IO[Unit] = {
val request = PUT(
AddAddressRequest(address).asJson,
hostname / "api" / "order" / orderId / "address")
client.use(_.status(request)).void
client.status(request).void
}
def addCheckoutPaymentInfo(orderId: String, paymentInfo: String): IO[Unit] = {
val request = PUT(
AddPaymentRequest(paymentInfo).asJson,
hostname / "api" / "order" / orderId / "payment")
client.use(_.status(request)).void
client.status(request).void
}
def pollOrderStatus(orderId: String): IO[String] = {
client.use(_.expect[PollPaymentStatusResponse](hostname / "api" / "order" / orderId)).map(_.status)
client.expect[PollPaymentStatusResponse](hostname / "api" / "order" / orderId).map(_.status)
}
}

View File

@@ -18,7 +18,7 @@ lazy val buildExampleDockerCommand: Command = Command.command("buildExampleDocke
"buildInteractionDockerImage docker:publishLocal webshop.webservice.ShipItemsInstance" ::
"project baas-interaction-example-reserve-items" ::
"buildInteractionDockerImage docker:publishLocal webshop.webservice.ReserveItemsInstance" ::
"project baker" ::
"project baas-smoke-tests" ::
state
})
@@ -304,7 +304,7 @@ lazy val `baas-node-state` = project.in(file("baas-node-state"))
)
)
.settings(
maintainer in Docker := "The Apollo Squad",
maintainer in Docker := "The Bakery Team",
packageSummary in Docker := "The core node",
packageName in Docker := "baas-node-state",
dockerRepository in Docker := sys.env.get("BAAS_DOCKER_REPO")
@@ -407,7 +407,7 @@ lazy val `baker-example` = project
)
)
.settings(
maintainer in Docker := "The Apollo Squad",
maintainer in Docker := "The Bakery Team",
packageSummary in Docker := "A web-shop checkout service example running baker",
packageName in Docker := "baker-example-app",
dockerExposedPorts := Seq(8080)
@@ -440,7 +440,7 @@ lazy val `baas-client-example` = project
)
)
.settings(
maintainer in Docker := "The Apollo Squad",
maintainer in Docker := "The Bakery Team",
packageSummary in Docker := "A web-shop checkout service example running on baas",
packageName in Docker := "baas-client-example",
dockerRepository in Docker := sys.env.get("BAAS_DOCKER_REPO")
@@ -467,7 +467,7 @@ lazy val `baas-event-listener-example` = project
) ++ testDeps()
)
.settings(
maintainer in Docker := "The Apollo Squad",
maintainer in Docker := "The Bakery Team",
packageSummary in Docker := "A web-shop checkout service example running on baas",
packageName in Docker := "baas-event-listener-example",
dockerRepository in Docker := sys.env.get("BAAS_DOCKER_REPO")
@@ -494,7 +494,7 @@ lazy val `baas-baker-event-listener-example` = project
) ++ testDeps()
)
.settings(
maintainer in Docker := "The Apollo Squad",
maintainer in Docker := "The Bakery Team",
packageSummary in Docker := "A web-shop checkout service example running on baas",
packageName in Docker := "baas-baker-event-listener-example",
dockerRepository in Docker := sys.env.get("BAAS_DOCKER_REPO")
@@ -503,6 +503,7 @@ lazy val `baas-baker-event-listener-example` = project
lazy val `baas-interaction-example-reserve-items` = project.in(file("examples/baas-interaction-examples/reserve-items"))
.enablePlugins(JavaAppPackaging)
.enablePlugins(baas.sbt.BuildInteractionDockerImageSBTPlugin)
.settings(commonSettings)
.settings(
moduleName := "baas-interaction-example-reserve-items",
@@ -519,17 +520,11 @@ lazy val `baas-interaction-example-reserve-items` = project.in(file("examples/ba
scalaCheck
)
)
.settings(
maintainer in Docker := "The Apollo Squad",
packageSummary in Docker := "The reserve-items interaction",
packageName in Docker := "baas-interaction-example-reserve-items",
dockerRepository in Docker := sys.env.get("BAAS_DOCKER_REPO")
)
.dependsOn(`baas-node-interaction`)
.enablePlugins(baas.sbt.BuildInteractionDockerImageSBTPlugin)
lazy val `baas-interaction-example-ship-items` = project.in(file("examples/baas-interaction-examples/ship-items"))
.enablePlugins(JavaAppPackaging)
.enablePlugins(baas.sbt.BuildInteractionDockerImageSBTPlugin)
.settings(commonSettings)
.settings(
moduleName := "baas-interaction-example-ship-items",
@@ -546,17 +541,11 @@ lazy val `baas-interaction-example-ship-items` = project.in(file("examples/baas-
scalaCheck
)
)
.settings(
maintainer in Docker := "The Apollo Squad",
packageSummary in Docker := "The Ship-items interaction",
packageName in Docker := "baas-interaction-example-ship-items",
dockerRepository in Docker := sys.env.get("BAAS_DOCKER_REPO")
)
.dependsOn(`baas-node-interaction`)
.enablePlugins(baas.sbt.BuildInteractionDockerImageSBTPlugin)
lazy val `baas-interaction-example-make-payment` = project.in(file("examples/baas-interaction-examples/make-payment"))
.enablePlugins(JavaAppPackaging)
.enablePlugins(baas.sbt.BuildInteractionDockerImageSBTPlugin)
.settings(commonSettings)
.settings(
moduleName := "baas-interaction-example-make-payment",
@@ -573,19 +562,7 @@ lazy val `baas-interaction-example-make-payment` = project.in(file("examples/baa
scalaCheck
)
)
.settings(
maintainer in Docker := "The Apollo Squad",
packageSummary in Docker := "The Make-payment interaction",
packageName in Docker := "baas-interaction-example-make-payment",
dockerRepository in Docker := sys.env.get("BAAS_DOCKER_REPO")
)
.dependsOn(`baas-node-interaction`)
.enablePlugins(baas.sbt.BuildInteractionDockerImageSBTPlugin)
lazy val `baas-example-setup` = project.in(file("examples/baas-example-setup"))
.aggregate(`baas-node-client`, `baas-node-state`, `baas-node-interaction`, `baas-node-event-listener`,
`baas-client-example`, `baas-event-listener-example`, `baas-baker-event-listener-example`,
`baas-interaction-example-reserve-items`, `baas-interaction-example-make-payment`, `baas-interaction-example-ship-items`)
lazy val `baas-smoke-tests` = project.in(file("baas-smoke-tests"))
.settings(defaultModuleSettings)

View File

@@ -1,10 +0,0 @@
package webshop.webservice
import com.ing.baker.baas.scaladsl.RemoteInteraction
import com.ing.baker.runtime.scaladsl.InteractionInstance
import scala.concurrent.ExecutionContext.Implicits.global
object Main extends App {
RemoteInteraction.load(InteractionInstance.unsafeFrom(new MakePaymentInstance))
}

View File

@@ -1,9 +0,0 @@
package webshop.webservice
import com.ing.baker.baas.scaladsl.RemoteInteraction
import com.ing.baker.runtime.scaladsl.InteractionInstance
import concurrent.ExecutionContext.Implicits.global
object Main extends App {
RemoteInteraction.load(InteractionInstance.unsafeFrom(new ReserveItemsInstance()))
}

View File

@@ -1,9 +0,0 @@
package webshop.webservice
import com.ing.baker.baas.scaladsl.RemoteInteraction
import com.ing.baker.runtime.scaladsl.InteractionInstance
import concurrent.ExecutionContext.Implicits.global
object Main extends App {
RemoteInteraction.load(InteractionInstance.unsafeFrom(new ShipItemsInstance))
}