Skip to content

Instantly share code, notes, and snippets.

@Hermione2408
Last active May 14, 2024 06:45
Show Gist options
  • Save Hermione2408/5ab360ca77c28ef6a38ad5a45316b755 to your computer and use it in GitHub Desktop.
Save Hermione2408/5ab360ca77c28ef6a38ad5a45316b755 to your computer and use it in GitHub Desktop.

GSoC logo

Author: Hermione Dadheech
Organisation: Keploy
Project: Keploy Typescript/Javascript SDK
Mentors:Ritik Jain,Gourav kumar

Abstract

Keploy is an end-to-end (E2E) testing tool that harnesses real traffic to produce tests and mocks. This streamlines the testing process by generating mocks and stubs, making the testing process both simpler and more efficient.Initially I was privileged to contribute to the Javascript/Typescript SDK of Keploy. However, to broaden the platform's compatibility and make it language-agnostic, we initiated the development of Keploy's V2. This newer version aims to capture messages at the network layer.

My Contribution to Keploy

I undertook the challenge of developing a MySQL parser using Golang. This parser is designed to capture interactions between destination and client servers.

MySQL calls have two phases one is initial handshake or Connection phase and other is Command phase. I developed central functions to decode(from binary to go struct) and encode(go struct to binary) various MySQL packets like COM_QUERY,COM_STMT_PREPARE, COM_STMT_PREPARE_OK etc. in command phase and HANDSHAKE , HANDSHAKE_RESPONSE etc. packet during the connection phase.

It operates in two distinct modes:

Record Mode: This mode captures and generates mocks for the communications between the client and the server. Leveraging our functions, we intercept these network calls, decode them based on the binary protocol, and produce YAML files.

Test Mode: Utilizing the mocks generated in record mode, this mode facilitates communication with the client-server based on the client's requests.

I have kept a single PR for this entire project PR- keploy/keploy#733

Additionally, for testing purposes, I crafted a MySQL application in Go, supporting all CRUD operations.- https://github.com/keploy/samples-go/pull/66/files

Challenges Overcome

  • Shift from JavaScript to Golang: My foundational experience lay in Javascript-based projects. Transitioning to Golang for this project was an immense learning curve.
  • MySQL's Binary Protocol: This format is not intuitively readable, and the limited documentation available further accentuated the complexity.
  • Time management and unknown blockers: One of the biggest learning for me was to manage my time between to attending college, appearing for exams and working on project ,but eventually i am happy about the outcome, Also at times there were challenges like how to keep connection alive in case there are multiple api calls in one session, so we implemented an infinite for loop to keep listening to the calls

Blogs

https://hashnode.com/preview/64ba4fc2a9165f000ffd5211

What's Next

Building on the foundation of my current work, I have crafted a standalone Redis parser. My immediate objective is to refine and integrate it alongside other parsers within Keploy's suite.I'll continue working on these projects, as I find the codebase very interesting. Moreover, they've given me a solid start in the open source community.

Pre GSOC

Before starting this amazing journey of GSoc with Keploy,these were the contributions that i made

PR LINK DESCRIPTION TYPE STATUS
#59(Typescript-sdk) Adding Unit test cases for wrappedNodeFetch and adding github actions #59 Feature Accepted
#53(Type-script-sdk) cp cmd in build script not working for windows Bug Accepted
#48(Typescript-sdk) Adding Keploy mode in logs to notify user in which mode keploy is running whether it is record, test, off Feature Accepted
#330(Keploy) Adding details of the only unit test case file needed. Doc Merged

Final Note

I’ve had a wonderful and productive summer during these 14 weeks journey and have learned plenty of things about golang, git,even Keploy through this project. My heartfelt gratitude goes out to my mentors, Ritik Jain and Gourav Kumar. They mentored me really well and were always ready to help me out. Finally, I would like to thank this amazing Keploy community!

Footnotes

@varunsh17
Copy link

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment