Trello:
https://trello.com/b/iq9xkiwX/lord-of-the-rings-character-generator
Middle Earth Character Generator was designed and created for my second SFIA project with QA-academy, it utilizes a collection of five micro-services that are containerized and deployed via docker-swarm stack and Jenkins CI pipeline.
The five micro-services are written in python and utilise python flask API to communicate and exchange information between each other, the first service is the front end python flask to html jinja2 template that imports all the necessary information to be displayed on the page.
The second, third and fourth micro-service generates random objects from a predefined list at random. the five and final micro-service uses predefined rules via if statements to change the values and modify the imported objects from services 1-4 then posts the results back to service 1.
• Create a front-end service that displays all the imported data in a clean readable manner.
• Generate random objects for Race, Stature, Location, Rank and Profession.
• Generate random objects for Grade, Weapon, Stance, Trait_1, Trait_2 and Trait_3.
• Generate random objects for Melee_Prowess, Archery_Prowess, Strength, Endurance, Intelligence, Awareness, Dexterity and Dodge.
• The ability to reassign the attributes generated in service 4 among other objects using if statements based on class e.g. Wizards are given more Intelligence and less Strength.
• The ability to create, display, update and delete (CRUD) character entries using the external mysql database
• Achieve 80% test coverage or above in each and every individual service along with a variety and range of tests.
• Deploy my micro-service with continuous integration via Jenkins Pipeline and github Webhooks.
The API requests from the front-end service to retrieve the necessary objects from the other services:
My first challenge was implementing post request API's to transfer generated objects around my services and getting them to relay back to my front-end, I solved this by importing non-modified variables directly into my front end and by using a post request from service 1 combined with a get request from service 2 and 4 to retrieve all the information I needed to modify.
My second challenge was getting my containerised MYSQL database working with my front-end service whilst in a swarm-stack, after troubleshooting many possible solutions I decided the best use of my limited time was to make an external MYSQL database and connect it to my services.
My third and final challenge was getting the jenkins user to execute all the required commands in my scripts because of the lack of sudo permissions, I solved this problem by editing a config file as root and adding the line jenkins ALL= NOPASSWD: ALL which allows jenkins to utilise sudo commands without issue.
Due to unforeseen complications with the development and deployment of the Jenkins pipeline I was sadly unable to implement CRUD into my micro-services therefore the data generated is only stored in the external MYSQL database.
Service 1
Service 2
Service 3
Service 4
Service 5
Service-1:
Mock POST and GET data request example:
Service-2:
Mock GET data request example with high range coverage:
Service-3:
Mock GET data request example with high range coverage:
Service-4:
Mock GET data request example with high range coverage:
Service-5:
Mock POST and GET data request example with high range coverage:
Overall I achieved 96%, 100%, 100%, 100% and 100% test coverage while testing all the services functionality with a high range of mock data, the only function I did not test was the form data input, the other improvement would be to find a way to test my service-5 with a iteration loop or similar method because to achieve 100% coverage I had to write 1300 lines of test code.
• Read, Update And Delete Functionality
• Containerised MYSQL Database
• Better Front-End layout and input form
• More efficient testing methods
• Form authentication rules to stop duplicate database entries
• Expanded list of possible randomly generated objects
• Generation of secondary weapon
• Generation of jenkins artifacts
• Use of environmental variables to hide sensitive information like MYSQL instance log in details
• Tagged docker images so I can perform a rollback
• Better source code management
In conclusion I think this project went really well with only medium to minor issues encounter along the way, my knowledge of docker and all its modules have expanded massively and it is now my favorite deployment method, Ansible can have some major issues with its syntax and caused me a little trouble but overall its a very useful piece of configuration software to have learned.
Jenkins on the other hand, well its a brilliant and revolutionary piece of automation software when you manage to get it working, but getting there is another issue, compared to my peers I had less issues with it since I found a way to bypass jenkins sudo permissions early on but it still has a high learning curve and am I yet to utilize its full capabilities.