Skip to content

Latest commit

 

History

History
151 lines (110 loc) · 6.24 KB

README.adoc

File metadata and controls

151 lines (110 loc) · 6.24 KB

Test Services

About the Project

This project contains three microservices to facilitate the creation of PoCs for API gateway technologies and frameworks. To support simulation of real world service behaviour, these services allow annotation-based simulation of service latencies as well as service failures.

These services have originally been devised during a master thesis on GraphQL.

Stack

Services are based on the following Stack:

  • Java 21 as latest LTS Version

  • Spring Boot 3.2.2

  • Maven

  • Postgres

  • Docker via JIB

👉

Why are these services no Spring Data REST Projects?

Most of the services are not more than exposing REST APIs for CRUD operations on specific entities and would hence be ideal candidates for Spring Data REST. However, since being able to modify specific API and service behaviours on the fly is key for using these services in PoCs, a manual approach to service creation was applied.

Test Service Overview

Table 1. Test Service Overview
Service Domain Objects Authentication Request ID for Logging

Customer Service

Customer Information, Customer Networks

API Key

Request Epoch as Request ID

Product Service

Product Information, Product Reviews

Basic Auth

UUID

ECommerce Service

Purchases, Price Information

Basic Auth

UID

Customer Service

Provides two distinct services:

  • Customer Information: Allowing CRUD operations focussed on personal data of customers

  • Customer Network: Storing and querying of relationships between customers

Product Service

Product Service also provides services on two distinct domains:

  • Product Information: Provides REST APIs for retrieval, editing and creation of product information.

  • Product Reviews: Exposes endpoints for basic functionality to review products.

eCommerce Service

Again, eCommerce Service provides services for two interacting domains:

  • Price Information: Information on current and historic pricing can be managed.

  • Purchase Information: Past purchases can be retrieved and new purchases can be made.

Simulation Support

In order to support simulation of specific integration challenges such as unstable services or services with high latencies, two additional functionalities are provided:

Overall Service Delay and API Specific Delay

Services can be configured in the respective application properties to incorporate "lag" based on three distinct approaches: These lag simulations can be activated by adding @EnableDelaySimulation on a class in the spring context.

  • Fixed Delay: Calls to all endpoints exposed by this service exhibit a fixed delay.

  • Normally Distributed Random Delay: Calls to all endpoints exposed by this service exhibit a random delay following a gaussian distribution with configurable mean and standard deviation.

  • Probabilistic Delay: Calls to all endpoints to this service either exhibit no or a fixed amount of delay, based on a probability that can be set. This is intended to simulate wake up behavior or less reliable downstream services.

Similar to the overall delay approaches, all endpoints can be used to simulate similar delays by adding annotation to the respective controller functions:

  • Fixed Delay: @FixedDelaySimulation, providing delayInMs

  • Normally Distributed Random Delay: @NormallyDistributedDelaySimulation, providing mean and standardDeviation

  • Probabilistic Delay: @ProbabilisticDelaySimulation, providing probability`and `delayInMs

These endpoint-specific delays can be used to simulate different service response times with respect to server loads and average query response times.

Probabilistic Failure

Based on controller or rest endpoint level, probabilities for failures (as represented by 4 and 5 status code responses) can be set. This simulated error behaviour can be enabled by adding @EnableFailureSimulation on a class in the spring context.

Adding the @ProbabilisticFailureSimulation (providing both probability and errorCode) on class or method level enables failure simulation.

Installation/How To Use

Local Execution

All services can be run using the local profile without any additional required setup. This will use a H2 in memory database as persistence layer for each simulated service.

If run in local profile, some test data and default users are set up for the respective service during start up. For services with basic auth, user credentials for these users follow the same pattern for all services:

  • User name: $service_$role (e.g. productservice_user)

  • Password: $service_$role_password (e.g. productservice_user_password)

When using the local profile services will expose their APIs as follows:

Service URI Port Username Password API Key

Customer Service

http://localhost

8082

-

-

supersecret

eCommerce Service

http://localhost

8083

ecommerceservice_$role

ecommerceservice_$role_password

-

Product Service

http://localhost

8081

productservice_$role

productservice_$role_password

-

Execution within a Docker Container

Additionally, the JIB Maven plugin has been preconfigured to allow easy dockerization of the services.

Images can be created by running mvn clean package jib:dockerBuild for a local Docker Daemon. To push to a remote docker registry, a <to> tag must be added to the configuration as described here.

Dockerized services will be using the docker profile by default. This profile causes the same application behavior as the local profile described above.

API Reference

A complete postman collection as well as a postman environment for the local setup is available as part of this repository.

Additional Support for Tinkering

  • H2 Consoles are exposed for local and docker profile under /h2-console for all services.