Generator-jhipster: Daily builds: JDL microservices broken with OAuth2+Cypress

Created on 6 Oct 2020  ·  17Comments  ·  Source: jhipster/generator-jhipster

Overview of the issue

See https://github.com/hipster-labs/jhipster-daily-builds

The daily builds for JDL Microservices + OAuth2 + Cypress are broken since days

Motivation for or Use Case
Reproduce the error
Related issues
Suggest a Fix
JHipster Version(s)
JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System

  • [ ] Checking this box is mandatory (this is just to show you read everything)
$$ bug-bounty $$ $200 area CI builds

Most helpful comment

An update.
I have tracked down the issue. And a fix is in the works.

  • This problem happens with cypress + oauth2 + applications running inside docker, not only microservice.
  • Our current tests doesn't uses applications inside docker.

Without application inside docker, keycloak is reached by localhost:9080 everywhere.

With docker:

Fixes:

  • change cypress to don't rely on cypress.json for keycloak endpoint
  • fix oauth2 authentication in beforeEach.

All 17 comments

I can take a look at this issue if no one is on it already. 😄

yes plz, @SudharakaP

Here some very quick analyze:

  • for JDLMs in GitHub Actions, the registry started at the same time than Keycloak, and Keycloak took approximatively 20sec to be "up", so the registry failed and is not up, so the other services can't start as the registry is not up

  • once, this 1st bug is fixed, Cypress can't access to Keycloak for unknown reason -> I manage to reproduce the issue locally. Maybe because cypress.json has "localhost:9080" hard coded, and here, we should use "keycloak:9080"

Easy to reproduce locally:

  • create a gateway with OAuth2
  • create a microservice with OAuth2
  • generate entity for microservice
  • generate the front part for this entity in gateway
  • build image with docker
  • run sub generator dockercompose
  • then, start the stack -> it will fail because of registry
  • once it's fixed, launch cypress -> it will fail because of config with cypress

@pascalgrimaud : Interestingly enough I think we didn't used to run the e2e tests when things were passing before; for example; https://github.com/hipster-labs/jhipster-daily-builds/runs/1127373854?check_suite_focus=true. Although just switching to Protractor and running the e2e seems to fix the issue; which probably means I think this is a mis-configuration in Cypress.

Run with Protractor in my fork: https://github.com/SudharakaP/jhipster-daily-builds/runs/1227102969?check_suite_focus=true

@SudharakaP : yes, it's related to Cypress, as it works approximatively well with protractor (but with some random failures)

@pascalgrimaud @SudharakaP : I looked a little at each of them, we use a request to connect to keycloak with Cypress (keycloak commands here) and we use UI with Protractor (angular example). As @pascalgrimaud said, maybe we should use 'keycloak:9080' when it's needed.

We can save Cypress screenshots of the daily builds with something like this :

          - name: 'E2E: Store failure screenshots'
            uses: actions/upload-artifact@v2
            if: ${{ always() }}
            with:
                name: screenshots-${{ matrix.app-type }}
                path: /home/runner/app/store/target/cypress/screenshots

@nassimerrahoui : Thanks for the tips. I tried changing the auth_base_url to http://keycloak:9080/auth but Cypress still wasn't able to connect I think. 🤔

same @SudharakaP
My tests locally :

@pascalgrimaud @nassimerrahoui : My guess is we are hitting this; https://github.com/cypress-io/cypress/issues/944

this build needs to be reactivated once it's fixed:https://github.com/jhipster/generator-jhipster/pull/12777

@SudharakaP are you working on this?

@mshima : I am, and was trying different things; but kinda out of ideas right now. 😢

EDIT: If you have any ideas or want to work on it please feel free to take it. 😄

An update.
I have tracked down the issue. And a fix is in the works.

  • This problem happens with cypress + oauth2 + applications running inside docker, not only microservice.
  • Our current tests doesn't uses applications inside docker.

Without application inside docker, keycloak is reached by localhost:9080 everywhere.

With docker:

Fixes:

  • change cypress to don't rely on cypress.json for keycloak endpoint
  • fix oauth2 authentication in beforeEach.

@mshima : Thanks a lot for the detailed analysis. Seems like the daily builds are fixed. 👍🏼

After few days, your PR seems to fix the main problem, @mshima : good job !!!

There is still another problem, related to Registry, which doesn't start in time:

CONTAINER ID        IMAGE                                                 COMMAND                  CREATED              STATUS                      PORTS                                                                                          NAMES
a9c537e00b26        postgres:13.0                                         "docker-entrypoint.s…"   About a minute ago   Up About a minute           5432/tcp                                                                                       docker-compose_crm-postgresql_1
56f9bab3f16c        store                                                 "bash -c /entrypoint…"   About a minute ago   Up About a minute           0.0.0.0:8080->8080/tcp                                                                         docker-compose_store_1
2bbeb9a8b64b        jboss/keycloak:11.0.1                                 "/opt/jboss/tools/do…"   About a minute ago   Up About a minute           8080/tcp, 0.0.0.0:9080->9080/tcp, 0.0.0.0:9443->9443/tcp, 8443/tcp, 0.0.0.0:10990->10990/tcp   docker-compose_keycloak_1
e59590f5068a        docker.elastic.co/elasticsearch/elasticsearch:7.6.2   "/usr/local/bin/dock…"   About a minute ago   Up About a minute           9200/tcp, 9300/tcp                                                                             docker-compose_crm-elasticsearch_1
10cafcb4b42e        jhipster/jhipster-registry:v6.3.0                     "/bin/sh -c 'java   …"   About a minute ago   Exited (1) 41 seconds ago                                                                                                  docker-compose_jhipster-registry_1
b36cc8e28d2d        mariadb:10.5.6                                        "docker-entrypoint.s…"   About a minute ago   Up About a minute           127.0.0.1:3306->3306/tcp                                                                       docker-compose_store-mariadb_1
3562320e87c1        crm                                                   "bash -c /entrypoint…"   About a minute ago   Up About a minute           5701/udp, 8081/tcp                                                                             docker-compose_crm_1

I'm fixing this last part

@pascalgrimaud : I think this is done right? Maybe we can close this and I think @mshima should also claim the bounty. 😄

Indeed, we can close this.
@mshima can claim the bounty, but he never did it, I don't understand why :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SudharakaP picture SudharakaP  ·  3Comments

tomj0101 picture tomj0101  ·  3Comments

Steven-Garcia picture Steven-Garcia  ·  3Comments

SudharakaP picture SudharakaP  ·  3Comments

lsadehaan picture lsadehaan  ·  3Comments