Integration Tests for AWS Kinesis consumer built using Spring Boot - java

We are working on Micro service developed using spring boot which consumes data from Kinesis stream process it and then stores it in DB. We have good JUnit Mockito test coverage .Now we need Integration test on this . Can you please suggest a good framework or set of frameworks which can be used to test the entire application end to end . We have checked so far Citrus, and spring-integration-aws but no luck

Generally you can use localstack to run AWS services like Kinesis locally, and start them up from your integration tests using Docker commands or something like Testcontainers.
Depending on how you have everything setup, you will need to inject a different Amazon Kinesis Client when the tests are running so that they connect to the local AWS services.

Related

How can I make a connection for service based on gRPC deployed as containerised microservices on EKS?

We have a Test Automation Suite based on Java and we need to make a connection request to gRPC micro service for different RPC calls deployed as containerised services on AWS EKS.
Can someone please share a sample code or blog link to make a grpc call to a service via java?
This is a simple HelloWorld example https://github.com/grpc/grpc-java/tree/master/examples/src/main/java/io/grpc/examples/helloworld . Take a look at the client (and proto file in https://github.com/grpc/grpc-java/blob/master/examples/src/main/proto/helloworld.proto)
For "containerised services on AWS EKS" I am assuming you are accessing them from inside AWS cloud with network connectivity not being an issue. Make sure the container (pod) ports are accessible from your client.

Environment and Project setup for Rest Assured and Sprint Boot Application

I have a spring boot microservice which connects to MySQL Database on production. This project also exposes REST endpoints and also consumes a REST endpoint from another microservice. It also connects to Kafka.
Now what I want to understand if I write REST Assured test cases using cucumber then where does this test cases will be kept. In the same spring boot microservice or code or it should be independent of that. If it should be kept independent and then how to achieve that. What is best practices ?
I am thinking of using WireMock to mock the endpoint which this microservice consumes. I am thinking of using EmbeddedKafka to connect it to Kafka.
How all of this thing will happen in CICD ?

How to run an application that uses aws Service Discovery locally?

I'm currently trying to create an application that have some separated micros-services and they need to communicate between them.
The problem is: I want to deploy the complete application to aws, using ECS, ECR, and mainly using AWS Service Discovery.
The application runs ok on the cloud, but how to run it locally?
My initial thoughts tends towards something like choosing between using the Service Discovery when on the cloud or using something like Eureka locally.

Spring Boot IT test after Deploy

I have Spring Boot Integration tests (IT) that connect to a real DB or to a real 3rd parties. I use them during development but I find them quite usefull to check the real behaviour of the application therefore I would like to run them during CI process. The goal is to run them on the environment on which the application is deployed and not on CI machine where Jenkins is running. Is there a way how to achieve this? I know I can use for example SOAP UI maven plugin and execute tests against REST endpoints, but I would prefer to use Spring Boot IT tests already written.
Many thanks
Running tests against your production database is a really bad idea. Please please please reconsider. It is better to have your test database updated to be more like production than to run your tests on production data.
That being said, you can point your database configuration to your production machine via the application.properties file (mongo example):
spring.data.mongodb.uri=mongodb://user:pass#production.myhost.com:27017/mydb
I'm guessing that it defaults to localhost:27017. In your test/resources folder you can setup a differing application.properties. Check out the spring-boot externalized properties details.

How to verify that a spring-boot web server is running

I am writing an integration test for a spring-boot web server
I want to use junit-jupiter (junit5) to check if the server is running using Assumptions.assumeTrue so that the test do not fail if the server is not running...
There seems not to be any API support for such operation, but can it be achieved in some other way? Pinging the server?
You could make use of the actuator module in spring boot. It will provide you with a health check URL and you could make a call to this URL and verify that it returns healthy.
Now that that is out of the way, if you need the server to be running while running your tests, you should probably be using the spring boot test runner, instead of using the JUnit runner. In this case you could still mock some of your spring beans and achieve the same kind of test, but with a spring context running alongside your tests. The downside of this is the overhead of needing to spin up the spring context before running tests, but if you need to use the actual web server, then this is what you should be doing.

Categories