generator-jhipster icon indicating copy to clipboard operation
generator-jhipster copied to clipboard

Improve Gatling integration

Open mraible opened this issue 3 years ago • 35 comments

Overview of the issue

I think our Gatling integration can be improved, especially for microservices. First of all, we should document how to run it on https://www.jhipster.tech/running-tests as a took me a bit to figure it out.

Step 1: Download Gatling Step 2. Extract it somewhere and add /path/to/gatling/bin to your PATH Step 3. In a terminal, cd into src/test/gatling and run gatling.sh or gatling.bat, depending on your OS

This is the first thing I think we should fix.

Next, I realized that for OAuth architectures, microservices are only resource servers. There's no way to log in to them, you can only access them by sending a valid access token. Currently, when you add Gatling to OAuth microservices, it generates the tests in the microservice project and fails to authenticate.

For this reason, I think we should generate all the Gatling tests in the gateway and adjust paths accordingly (kinda like we do for the UI files). This would have the added benefit of testing the gateway's routing performance.

Motivation for or Use Case

OAuth with Gatling in a microservices environment doesn't currently work.

Reproduce the error

Generate a microservices architecture with the following JDL:

application {
  config {
    baseName gateway
    reactive true
    packageName com.okta.developer.gateway
    applicationType gateway
    authenticationType oauth2
    prodDatabaseType postgresql
    serviceDiscoveryType eureka
    testFrameworks [cypress]
  }
  entities Blog, Post, Tag, Product
}

application {
  config {
    baseName blog
    reactive true
    packageName com.okta.developer.blog
    applicationType microservice
    authenticationType oauth2
    databaseType neo4j
    devDatabaseType neo4j
    prodDatabaseType neo4j
    enableHibernateCache false
    serverPort 8081
    serviceDiscoveryType eureka
    testFrameworks [gatling]
  }
  entities Blog, Post, Tag
}

application {
  config {
    baseName store
    reactive true
    packageName com.okta.developer.store
    applicationType microservice
    authenticationType oauth2
    databaseType mongodb
    devDatabaseType mongodb
    prodDatabaseType mongodb
    enableHibernateCache false
    searchEngine elasticsearch
    serverPort 8082
    serviceDiscoveryType eureka
    testFrameworks [gatling]
  }
  entities Product
}

entity Blog {
  name String required minlength(3),
  handle String required minlength(2)
}

entity Post {
  title String required
  content TextBlob required
  date Instant required
}

entity Tag {
  name String required minlength(2)
}

entity Product {
  title String required,
  price BigDecimal required min(0),
  image ImageBlob
}

relationship ManyToOne {
  Blog{user(login)} to User,
  Post{blog(name)} to Blog
}

relationship ManyToMany {
  Post{tag(name)} to Tag{post}
}

paginate Post, Tag with infinite-scroll
paginate Product with pagination

microservice Product with store
microservice Blog, Post, Tag with blog

After starting everything (including Docker containers), cd into blog/src/test/gatling and run ./gatling.sh. Choose any test and watch it fail to authenticate.

Suggest a Fix

See above.

JHipster Version(s)

Version 7, beta 0

mraible avatar Dec 31 '20 00:12 mraible