Skip to content

feat(scala-sdk): Integration test template#565

Merged
raboof merged 21 commits intomainfrom
integrationSpec
Oct 6, 2021
Merged

feat(scala-sdk): Integration test template#565
raboof merged 21 commits intomainfrom
integrationSpec

Conversation

@raboof
Copy link
Copy Markdown
Contributor

@raboof raboof commented Oct 5, 2021

Part of #372

Copy link
Copy Markdown
Member

@octonato octonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

with small suggestions

ValueEntityTestKitGenerator.integrationTest(main, entity, service).content,
"""package com.example.shoppingcart.api

import com.akkaserverless.scalasdk.testkit.AkkaServerlessTestkit
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we moving out of using the |? I have see that at least one other suite were not using it.

I don't mind. Maybe be even easier to read. Soon I will be write codegen for the replicated entity. I will use that new style then.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this was not particularly intentional, I'm fine with either

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe be easier if we remove the |.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we have mostly used | I think we should continue with that, and at least to me it reads a bit weird to suddenly have code to the very left

* testkit before testing the service with gRPC or HTTP clients. Call {@link #stop} after tests are complete.
*/
class AkkaServerlessTestkit(impl: JTestKit) {
def start() = impl.start()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking:

We have been using impl, but I think we should call it delegate. Both are implementations, but one is an adapter that delegates all calls to the other impl.


def stop() = delegate.stop()
}
object AkkaServerlessTestkit {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have this at the top, since that is the starting point for using it?

* <p>Create an AkkaServerlessTestkit with an {@link AkkaServerless} service descriptor, and then {@link #start} the
* testkit before testing the service with gRPC or HTTP clients. Call {@link #stop} after tests are complete.
*/
class AkkaServerlessTestkit(delegate: JTestKit) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the constructor private


val testkit = AkkaServerlessTestkit(Main.createAkkaServerless())
testkit.start()
implicit val system = testkit.system
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

system: ActorSystem to avoid warnings in Intellij

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that needed for running streaming calls, or something else? wonder if we should not include it since it exposes a bit too much low level Akka? btw, if it's for streams we should have it as Materializer since that is what we have in the contexts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used for creating the Akka gRPC client

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, we could have a grpcClient utility method similar to what we provide in the context. That would become more unified. Can be a separate ticket.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created issue #568 for this idea


def system = delegate.getActorSystem()

def stop() = delegate.stop()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explicit return type on all things here

val entityClassName = service.fqn.name

File(
service.fqn.fileBasename + "IntegrationSpec.scala",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have these in test scope I wonder if there is a way to run all unit tests without these?

Thinking about testOnly **Spec but that would include IntegrationSpec too. Shall we name the others UnitSpec so that testOnly **UnitSpec would work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*UnitSpec could work, though it's a bit unfortunate when ideally you'd want to have many unit tests and few integration tests. The only alternative I can think of is using ScalaTest tagging, though that's a bit obscure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created issue #571 for this thought

ValueEntityTestKitGenerator.integrationTest(main, entity, service).content,
"""package com.example.shoppingcart.api

import com.akkaserverless.scalasdk.testkit.AkkaServerlessTestkit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we have mostly used | I think we should continue with that, and at least to me it reads a bit weird to suddenly have code to the very left

* <p>Create an AkkaServerlessTestkit with an {@link AkkaServerless} service descriptor, and then {@link #start} the
* testkit before testing the service with gRPC or HTTP clients. Call {@link #stop} after tests are complete.
*/
object AkkaServerlessTestkit {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different casing than all other test kits

Suggested change
object AkkaServerlessTestkit {
object AkkaServerlessTestKit {

Copy link
Copy Markdown
Contributor Author

@raboof raboof Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, the javadsl AkkaServerlessTestkit is also lowercase-k. I'll also update that one then ;)

Copy link
Copy Markdown
Contributor

@patriknw patriknw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

val entityClassName = service.fqn.name

File(
service.fqn.fileBasename + "IntegrationSpec.scala",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created issue #571 for this thought

@raboof raboof mentioned this pull request Oct 6, 2021
21 tasks
@raboof raboof merged commit 1bdbe61 into main Oct 6, 2021
@raboof raboof deleted the integrationSpec branch October 6, 2021 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants