Skip to content

This project is a Software to manage iBeacon chronometers (Frontend + Backend + Client)

License

Notifications You must be signed in to change notification settings

fabricepipart/teknichrono

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Teknichrono

Build Status codecov GitHub actions workflow Dependabot Status

Description

Purpose of the project

This project is the backend part of the Software: the REST API that sits on a server receiving calls from two types of clients:

  • Chronometers that sends the pings to compute the lap times
  • End users that consult the lap times or Administrators

Architecture

The backend part is based on Quarkus that receives API calls implemented with Jax-RS. Persistence is implemented with Hibernate and JPA. The testing part of the project is based on JUnits (very few), QuarkusTest and Python end to end tests that simulate real activity.

Requirements

  • Java 11
  • Maven 3.6

How to build

How to build locally

mvn clean verify

CI Build

The CI is done thanks to GitHub actions and runs the following:

  • Server tests
    • JUnits
    • Quarkus Integration tests
    • A docker image is built with the Python Integration Tests integrated and pushed to dockerhub along with the server itself
    • Code coverage for sever side code is gathered
    • A staging environment is started on a private Kubernetes cluster
    • Python integration tests are ran against this staging environment
  • Client tests
    • When the staging environment is loaded, the client is started in demo mode which simulates random Bluetooth reception
    • Auto update of the client is tested
    • Test coverage is gathered and sent to codecov
  • Releasing
    • Version is bumped automatically. Add #major or #patch in your commit tags if you want to bump the corresponding number. By default, the minor is bumped.
    • Repository is tagged for each version
    • All changes are gathered in a ChangeLog and GH releases are used
    • Builds of the master branch are directly loaded on the Production environment

How to run

There are three profiles. See in src/main/resources/application.properties.

How to run locally with dev profile

mvn quarkus:dev

Note: you can connect your IDE for debugging on port 5005.

How to run locally with localmariadb profile

First: kubectl port-forward -n teknichrono $(kubectl get pod -n teknichrono -l app=mysql -o jsonpath='{.items[0].metadata.name}') 3306:3306 kubectl port-forward -n teknichrono service/mysql-service 3306:3306 then mvn -Dquarkus.datasource.password=xxx quarkus:dev -Dquarkus-profile=localmariadb or java -Dquarkus.datasource.password=xxx -Dquarkus-profile=localmariadb -jar target/teknichrono-runner.jar

How to test

JUnit

mvn clean test

QuarkusTest

mvn clean verify

End to End

Run the E2E tests : ./src/test/scripts/bash/moto_tests.sh (or any bash script in this folder)

Interact with Raspberry

See the client documentation

Services

TODO List of the REST API services here

For the time being, you can have a look in: src/main/java/org/trd/app/teknichrono/rest

Interesting pointers

Quarkus migration todo list

Outdated section

OpenShift support has been discarded for Kubernetes plain commands. In case it is needed, here were the commands for OpenShift:

How to build via OpenShift

oc new-build --binary --name teknichrono-quarkus --to='teknichrono-quarkus:local'
oc patch bc/teknichrono-quarkus -p "{\"spec\":{\"strategy\":{\"dockerStrategy\":{\"dockerfilePath\":\"src/main/docker/Dockerfile\"}}}}"
oc start-build teknichrono-quarkus --from-dir=. --follow

Port forward with OpenShift

oc port-forward mariadb-3-qgvwj 3306:3306

CI Build and Kubernetes build images

The project relies on the Kubernetes plugin to run its CI in Jenkins. The podTemplate referenced here has the following settings:

  podTemplate(label:label , cloud: 'openshift', serviceAccount:'jenkins', containers: [	
    containerTemplate(name: 'maven', image: 'maven:3.6-jdk-8-alpine',	ttyEnabled: true, command: 'cat'),	
    containerTemplate(name: 'python', image: 'docker.io/python:3.6-slim',	ttyEnabled: true, command: 'cat')]) {
      ...
  }

I did not provide the configuration inline because, I integrated a Nexus proxy to speed up the builds in my case. It requires providing a custom build image in order to customize the settings.xml .

How to run on OpenShift

oc new-app --image-stream=teknichrono-quarkus:local
oc expose service teknichrono-quarkus --name=teknichrono-quarkus-route --port=8080 --hostname=teknichrono-quarkus.h-y.fr

How to re-generate scaffhold:

  • Delete src/main/webapp
  • In Ecipse run Forge (Command + ' or Ctrl + 4) with default settings and AngularJS