- Overview
- OpenAPI SPecification
- Functional Requirements
- Technologies
- Run Locally
- Run using Docker
- TESTING
- Unit Tests
- Integration Tests
- Load tests
- Keycloak
- Jenkins
- Kubernetes
This is a restful API that'll help sorting out movies and add them to users' favorites list based on their genres or names.
- Get a list of actors that is filterable based on actors' names.
- Create,read, update and delete an
actor
. - Get a list of movies that should be filterable based on their
genres
ormovieName
- Create,read, update and delete a
movie
. The system allows to add or delete a genre from a movie record usinggenreId
. - Get a list of users,genres and favorite lists. Favorites list uses pagination so we can change the default values of
limit
andpage
. - The system allows to update a
favorite
list by adding or erasing movies from it'smovies
list. - Create,read, update and delete an
user
orgenre
record .
- Java 11
- MySQL
- Maven
- JUnit
- JMeter
- Postman
- Docker
- Keycloak
- Jenkins
Ports
- API-8080
- MySQL-3306
You can run this project using docker containers. Make sure that Docker is installed and go to Movies/ folder where you can run the docker-compose up -d
command and start the necessary containers. It should take a while to start all containers since movies-api container waits for keycloak.
Make sure that the necessary ports are available 3306
for mysql database ,8090
for movies-api and 8080
for keycloak container.
git clone https://cakinn@bitbucket.org/mountainstatesoftware/cakin-sb-proj.git
- Unit Tests
- Integration Tests
- Load Tests
Unit tests for this project were made using JUnit and Mockito. Run tests and generate the report using mvn clean test
The report can be found at target\site\jacoco\index.html
.
Integration tests were made using Postman. Install node to run from the command line or run the collection using Postman UI. Navigate to the postman folder and run the following command iterating the tests 5 times.
>newman run -n 5 movies-api-remake.postman_collection.json -e movies-local.postman_environment.json
Load tests were made using Apache JMeter. The tests should hit 1000 requests to each endpoint of the API. Try to reach that number increasing the loop number (100 users and 10 loops).
The report can be found at test-report\index.html
.
jmeter -n -t movies-api-x.jmx -l load-test.csv -e -o test-report
In this project Keycloak is used for authentication and every single request must have a JWT(Jason Web Token) present in it's header.
To acces that token wait tillmovies-auth container is up and running and send a POST request using the values below:
` client_id: movies-api username: apiuser password: password grant_type: password client_secret: rxb5qnx4JnCmcZQ0vNwh2mNKIYT2ZNU4
`
Keycloak realm data is present in keycloak/movies-realm.json , a JSON file which was exported from a keycloak container with all of it's credentials, users and clients.
This project uses a Jenkins script for executing a pipeline and run tests. It takes about 6-8 min to run all tests.
Make sure that Jenkins is installed and that the necessary credentials ares set, navigate where the jar file is located and run :
java -jar jenkins.war --httpPort=9090
Run Jenkins on port 9090 to avoid collading with other containers.
Then set a pipeline and set URL for this repository, choose the branch and specify the script path.
In 'Kubernetes' folder can be found files that deploy all components to a kubernetes cluster using movies
namespace.