Giter Club home page Giter Club logo

fpts's Introduction

FPTS - Framework for Performance Test Specification for Microservices

This framework was build to improve the performance test execution on applications build under Microservices architecture.

Knowing that the test task is one of the main challenges in a Microservices application, the main goal is to provide a manner to automate the performance tests on each Microservice. For that, the developer need to define a test specification for each operation of the service. The specification will then be used by an external application to run performance tests in an automated way.

Application

  • JDK: This project requires JDK 8

  • Web Framework: Spring Web MVC v4.1.6

  • JSON library: Jackson v2.5.4

  • Components:

*API : Provide means to allow developers to define methods that will return test specifications for the service operations. *CORE: Work on runtime to process income requests and return the test specification.

Main Features

  • Framework API: This allows the developer to remove the framework from the application during the build. This is particularly useful when we are building the project for production deployment as we may not want to expose the test methods.
  • Annotation capabilities: This provide a clean and simple way for the developer to define the specifications. In addition, this facility allows the developer to choose which service methods will be exposed.
  • Dynamic data for testing: This refers to the possibility of using the database to fetch data for the test specification and validation. With this, the developer can bypass the changes that the data may have which could lead to failure in the tests. Let us say that we want to test a GET operation and we will get some data by its ID. Therefore, we can query the database and get the object with ID = 1 and provide the same object for validation in the specification. Although this object may change, the Framework will always build the updated data and the test application will have the refreshed data to use.
  • Annotation processor: This feature checks if the return type for the annotated method is valid (must be of type ‘TestSpec’). This check happens during compile time, which prevents errors in runtime and allows the developer to fix these inconsistencies quickly.
  • Build features to validate data: common validation types have been created in order to append the validation data to the specification, such as: validate only header status and validate for both header and body.

How does it work

    1. The test application will send a OPTIONS request to the service URI.
    1. The Framework will filter this request and compose the test specification using the information defined by the developer during the implementation of the service.
    1. The specification is returned in JSON format to the test application.

All other requests that are not OPTIONS request will be forwarded to the service endpoint.

The framework will only perform its action if the core library is found in the build path. So, if we are building the application for restricted environments such as production we can remove this library from the build and no code change is needed as we will keep the API.

How to use

  • Dependency This framework is design to be used along with Spring Boot Framework [https://github.com/spring-projects/spring-boot.git]

  • First step The first thing to do is to add fpts-core and fpts-api to your project

  • Second step The next step is to define your methods that will return the specification. Mainly it will be one for each service operation. This methods will be placed in your service class (the RESTController class).

  @PerformanceTest(path = "/rest/finance", httpMethod = HttpMethodEnum.GET, description = "Get transaction by id")
	public TestSpec<GetTestParameter> getTestSpecForGetById() {
		GetTestParameter testParameter = new GetTestParameter("id", "1");
		TestValidationsBuilder validationBuilder = new TestValidationsBuilder();
		FinancialTransaction testObj = new FinancialTransaction("000023989", "766", "10", "2015");
		TestSpec<GetTestParameter> testSpec = new TestSpec<GetTestParameter>(testParameter,
				validationBuilder.buildHeaderStatus200AndEntityBody(testObj));
		return testSpec;
	}
  • Third step The final step if to add the framework filter in your application configuration. If you choose to place the configuration on code you will add the following code to your Configuration class.
  	@Bean
	@Autowired
	public FilterRegistrationBean performanceTestFilter(RequestMappingHandlerMapping requestMappingHandler) {
		FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
		filterRegistration.setFilter(FilterBuilder.buildPerformanceFilter(requestMappingHandler));
		List<String> urlPatterns = new ArrayList<String>();
		urlPatterns.add("/*");
		filterRegistration.setUrlPatterns(urlPatterns);
		return filterRegistration;
	}

Licenses

  • This code is licensed under the [MIT License].

fpts's People

Contributors

asdcamargo avatar

Stargazers

liu yuqing avatar Marlon Mafra avatar

Watchers

 avatar

Forkers

kishorekkota

fpts's Issues

Improvements on javadoc and automate tests

All flexible classes that has important roles in the frameworks behavior as well as to users need to have javadocs (e.g. TestSpec, PerformanceTestFilter).
The maven build process need to have a new target to generate an external html file with the javadocs.
Additionally we need to add automated test for these classes. This tests will be triggered during maven build process.

FPTS client API

A new component needs to be created to provide useful features on the client side.
This will facilitate the integration with performance test applications such as JMeter.

FPTS example project

A new example module needs to be created.
This module will contain several examples showing how to use the different features such as:

  • Annotation to compose the test specification
  • Validation features on the test specification
  • Web Filter configuration

Allow ObjectMapper replacement

The framework need to allow the user to specify which instance of the Object Mapper will be used to generate the JSON.
This is important because we want to allow the user to specify the exactly attributes that will be send along with the test specification.
This change needs to cover the test parameter transformation and also the JSON-Schema both are attributes that compose the test specification.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.