Embarking on a Professional Growth Adventure: Insights from my LFX Mentorship Program at LitmusChaos
Tags: opensource, webdev, programming, beginners
Published: 2023-12-03 17:08:30

**Introduction**

The Linux Foundation Mentorship Program offers a dynamic 12-week internship where participants engage in hands-on projects while receiving a stipend. When I first applied for the LFX mentorship program, I was a novice in the field and had no idea how this experience would impact my professional growth. Looking back now, I can confidently say that my journey within the LFX program has been transformative, teaching me the power of perseverance and learning.

One of the main reasons I was drawn to the LFX mentorship program was the fact that the project on which the mentee will be working was already set before the beginning of the application process. This allowed me to choose a project that aligned with my interests and skill set.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5w65b0azk60ri95sj041.png)

**Early Challenges and Overcoming Them**


My initial applications to the LFX program back in 2022 were unsuccessful, which served as a stark reminder of the competitive nature of this program. However, I refused to let the setbacks deter me and immersed myself in various open-source communities. This period was crucial for me as I honed my skills, expanded my understanding, and became more comfortable diving into any codebase quickly. This groundwork enabled me to craft a compelling proposal for the LFX program in Fall 2023, leading to my acceptance into my first-choice project – a perfect match for an area I was looking forward to improving.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v25ecv1989sf5v58hazz.png)

**The Mentorship Experience**

My mentors, [Sayan Mondal](https://mentorship.lfx.linuxfoundation.org/mentor/21102070-974f-49fb-9a5c-08950670f081) and [Saranya Jena](https://mentorship.lfx.linuxfoundation.org/mentor/e967ae3d-e016-432e-b0df-bced2c38860f), were instrumental in my journey, providing guidance and support throughout the program. Our weekly meetings became a cornerstone of my learning process, where I shared progress, discussed challenges, and received tasks for the upcoming week. These tasks were primarily focused on adding unit tests for both the authentication server and unit, incorporating a new documentation for Chaoscenter API. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrcdwohuorwx2tfxhlta.png)

After a quick adaptation, I got my first task in the second week: to modify the code architecture to interface model for the [environment service package](https://github.com/litmuschaos/litmus/blob/master/chaoscenter/graphql/server/pkg/environment/handler/handler.go) and write test cases for it. Which I successfully accomplished. The satisfaction of having my first contributions merged was unparalleled.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hwowuow86olxpqsnf3e.png)


**Implementation**

- Test Cases for Auth server

_1. Modifying the code architecture to interface model:_

The first step in implementing test cases for the authentication server was to modify the code architecture to interface model. This was done to ensure that the code was modular and easy to test. This made it easier to test each piece of code individually and ensure that it was working as expected.

_2. Creating a mock client of the services used by both GRPC and REST API:_

The second step was to create a mock client of the services used by both GRPC and REST API. This was done to ensure that the test cases were isolated from the actual services. By creating a mock application service, I could simulate the behavior of the services without actually calling them.

_3. Writing test cases to improve test coverage:_

The final step was to write test cases to improve test toward improving the coverage. For each test, I created a new instance of the **MockApplicationService** and then passed a data test for different scenarios. One major issue I faced during this work was that the first scenario tested was directly impacting the new service instantiated from the mocked was affected by the first scenario that was run, so I was forced to use one scenario by test cases, but later on, I figured out that each scenario should have their one instance of the **MockApplicationService**, from there I was able created more a test cases and improved the coverage. Here is that particular [PR](https://github.com/litmuschaos/litmus/pull/4238)

- Tests Cases for Frontend Views Components

LitmusChaos uses a [TestWrapper](https://github.com/litmuschaos/litmus/blob/master/chaoscenter/web/src/utils/testUtils.tsx) to encapsulate most of the dependencies that need to be mocked. For the first tests I wrote, I had to mock 2 main dependencies, the **ReactqueryProvider** and **ApolloClient**, but in order to ensure consistency and simplicity across the test cases, I implemented them into the TestWrapper and used the TestWrapper to wrap each component I wanted to test.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fzoa60czldvh2mj6qyhk.png)

- Incorporating API documentation for ChaosCenter API

For this, I decided to use an OPENAPI SPEC that will be used to automatically generate API documentation for each handler. For this work, I discovered a library called [swaggo](https://github.com/swaggo/swag) that I used to define annotations, from the description of the handler to defining responses. I created a doc file that lists all responses and errors from each endpoint, and to finish, I used [go-swagger](https://goswagger.io/) library to generate the API doc from the OPENAPI SPEC file generated by swaggo. [Click here](https://github.com/litmuschaos/litmus/blob/master/chaoscenter/authentication/DOC_SETUP.md) to learn more about the new API documentation of Litmus Chaoscenter

**Achievements and Realizations**

Throughout the program, I raised nine PRs, with [eight successfully merged and one under review](https://github.com/litmuschaos/litmus/pulls?q=is%3Apr+author%3AFreedisch+is%3Aclosed). My work not only increased the backend coverage from 0 to 25.48% and enhanced the frontend coverage from 0 to 14.56%. One of my essential suggestions was the implementation of a new workflow to track test coverage in the Chaoscenter auth server. My contributions laid a foundation for future enhancements by other contributors. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ywkic66kt0spo4w2sqs5.png)

Moreover, I was able to register all 34 REST endpoints defining both Responses and the Return Error, which enables contributors to easily update the documentation page when a new endpoint is created just by modifying the annotations. This simplified the documentation process and made it more accessible for newcomers and existing contributors.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/72nu0ul4eeffamol0qir.png)


**Challenges Faced**

The journey was not without its challenges. One of the major issues I encountered during that time was writing positive test cases. I struggled to write positive tests for the GRPC and environment handler. I tried different approaches to mocking most of the services used by the handler, but after doing unsuccessful research on the internet, I asked for help from the community. I got referred to different resources on how to [mock handlers using GIN](https://semaphoreci.com/community/tutorials/test-driven-development-of-go-web-applications-with-gin). All these resources were super helpful and helped me write positive test cases and [close this PR](https://github.com/litmuschaos/litmus/pull/4175). That taught me that even though you have to figure out things on your own, it is OKAY to ask for help. It was my first time writing unit tests at this scale for a large project, but I learned, researched, and asked for help from my mentors.


**What's Next?**

After spending the whole fall working on this project, I plan to continue contributing to the testing strategy of LimusChaoscenter by helping new contributors who want to contribute to the project. I currently have one PR pending and a testing strategies documentation for Chaoscenter frontend to add. After that, I will maintain existing test cases and work on new ones.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32a5ai2ehkislr45fpy5.png)

**Conclusion**

The LFX mentorship program has been the most rewarding experience of my year. It has transformed me from a beginner in open-source to a confident contributor capable of making meaningful improvements. This experience enhanced my technical understanding of writing test cases, improved my Golang skills, and helped me gain insights into my code. I have learned that anything is achievable with the right amount of energy and time. Don't hesitate to [submit](https://mentorship.lfx.linuxfoundation.org/#projects_all) your proposal for next quarter.




Thanks for reading.

By Magnim Thibaut F. Batale

[Linkedin](https://www.linkedin.com/in/magnim-thibaut-batale-905843208/) | [Github](https://github.com/Freedisch)
LFX'23 Mentee at [Litmus](https://litmuschaos.io/)