1

I am wondering about how can we testing automate functionality.

I am working on a Spring Boot micro-service where we use a GemFire cache. Right now I am testing it manually for below scenarios:

  1. Is the data purged correctly after TTL is reached
  2. Retrieving the data from cache if object exists

So, I know we can have a separate service which calls the GemFire and making sure that the object exists in cache (for step2). But not really sure how can we automate testing for step1.

And the whole point I am wondering is do we really need a new service completely to test this as a overhead? Are there any tools / better approach for testing the functionality?

John Blum
  • 7,381
  • 1
  • 20
  • 30
JingJong
  • 207
  • 1
  • 3
  • 14
  • I echo what Juan as said below; huge +1. To add a bit more detail, _Spring Test for Apache Geode_ (STDG; https://github.com/spring-projects/spring-test-data-geode) is used to extensively test both _Spring Boot for Apache Geode_ (SBDG; https://github.com/spring-projects/spring-boot-data-geode) as well as _Spring Session for Apache Geode_ (SSDG; https://github.com/spring-projects/spring-session-data-geode). Later on, I will be retrofitting the _Spring Data for Apache Geode_ (SDG; https://github.com/spring-projects/spring-data-geode) test suite to use STDG as well. ... – John Blum Aug 07 '20 at 18:19
  • NOTE: when I say Apache Geode, I also mean VMware Tanzu GemFire. – John Blum Aug 07 '20 at 18:23
  • Now, you can always look at Unit & Integration tests in SBDG's test suite (e.g. https://github.com/spring-projects/spring-boot-data-geode/tree/master/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure) or tests in the SSDG test suite (https://github.com/spring-projects/spring-session-data-geode/tree/master/spring-session-data-geode/src) for examples on how to use STDG. I'd also encourage you to start learning about STDG from the README (https://github.com/spring-projects/spring-test-data-geode#stdg-in-a-nutshell). – John Blum Aug 07 '20 at 18:23
  • Finally, If you want to see tests around testing GemFire/Geode's Expiration (TTL or TTI) behavior, then SSDG is probably your best bet since SSDG is particularly interested in the expiration of (HTTP) Sessions, which uses GemFire/Geode's TTI Expiration capabilities along with custom expiration policies (via `CustomExpiry`) OOTB. For example, see these tests: https://github.com/spring-projects/spring-session-data-geode/tree/master/spring-session-data-geode/src/integration-test/java/org/springframework/session/data/gemfire/expiration – John Blum Aug 07 '20 at 18:27
  • SBDG additionally adds an Integration Test to test the proper expiration of (HTTP) Sessions with SSDG in a Spring Boot context: https://github.com/spring-projects/spring-boot-data-geode/blob/master/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/session/SessionExpirationIntegrationTests.java. SBDG provides auto-configuration support for SSDG. – John Blum Aug 07 '20 at 18:33

2 Answers2

2

Since you're using spring-boot and VMware GemFire together, I really hope you're taking advantage of the huge help and functionality spring-boot-data-gemfire provides out of the box. If you are, then you'd be delighted to know that there's yet another project, spring-test-data-geode, which can be used to write Unit and Integration Tests when building Spring Data for Apache Geode & VMware GemFire applications, you should really give it a try as it greatly helps in managing the scope and lifecycle of mock VMware GemFire/Apache Geode objects, along with cleaning all resources used by real objects used during Integration Tests.

As a side note, if you're using the Data Expiration Functionality shipped out of the box with VMware GemFire, I really don't see an actual need (other than the peace of mind that comes with I've tested everything I could) to include custom tests within your testing suite, you should only test what you own. The functionality itself is thoroughly tested already as part of the VMware GemFire / Apache Geode project itself, and you can see some (certainly not all) examples of such tests in the following links: ExpirationDUnitTest, RegionExpirationDistributedTest, ReplicateEntryIdleExpirationDistributedTest.

Cheers.

Juan Ramos
  • 1,421
  • 1
  • 8
  • 13
0

I have had some success using TestContainers here is the code used to create the container and a sample test. It works by executing gfsh commands on the container but is slow.

dturanski
  • 1,723
  • 1
  • 13
  • 8