Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: change binary lists in mysql mocks to base64 strings for readability #1276

Merged
merged 12 commits into from
Jan 10, 2024

Conversation

Hermione2408
Copy link
Member

Related Issue

  1. ‘look by kind’changes in mysql so that It doesn't get different packet from config mock.
  2. encoding/decoding of packets to base64.
    Closes: #[issue number that will be closed through this PR]

Describe the changes you've made

A clear and concise description of what you have done to successfully close your assigned issue. Any new files? or anything you feel to let us know!

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Please let us know if any test cases are added

Please describe the tests(if any). Provide instructions how its affecting the coverage.

Describe if there is any unusual behaviour of your code(Write NA if there isn't)

A clear and concise description of it.

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Screenshots (if any)

Original Updated
original screenshot updated screenshot

Copy link

sweep-ai bot commented Dec 31, 2023

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Refactor large functions to be more modular.
  • Apply: Add docstrings to all functions and file headers.

@Sarthak160 Sarthak160 changed the title Hd mysqlchanges refactor: change integer lists in mysql mocks to base64 strings for readability Dec 31, 2023
@Sarthak160 Sarthak160 changed the title refactor: change integer lists in mysql mocks to base64 strings for readability refactor: change binary lists in mysql mocks to base64 strings for readability Dec 31, 2023
for {
configMocks := h.GetConfigMocks()
tcsMocks := h.GetTcsMocks()
firstSQLMock := func(configMocks []*models.Mock) (*models.Mock, bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function can be defined outside and better be named as GetFirstMysqlMock and I guess we should also compare the mock with some properties, instead of impetuously returning the first mock. Reason behind can be the case where fist mock written in the yaml itself is not the initial handshake mock .

@Sarthak160
Copy link
Member

Also make this field into base46 as well -

 message:
            capability_flags: 423535119
            max_packet_size: 16777215
            character_set: 255
            reserved:
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                - 0
                

@Sarthak160
Copy link
Member

Also since we have implemented memDb for handling mvcc in the mock transactions, It's beneficiary to use the newly introduced method h.DeleteTCSmocks from the PR #1214 instead of just slicing down the index which can cause race condition when two different parsers try to access the same mocks object at same time.
So After that PR gets merged to main you can also replace your logic for deleting mocks to just h.DeleteTcsMock(matchedMock).

			matchedIndex := 0
			matchedReqIndex := 0
			configMocks[matchedIndex].Spec.MySqlResponses = append(configMocks[matchedIndex].Spec.MySqlResponses[:matchedReqIndex], configMocks[matchedIndex].Spec.MySqlResponses[matchedReqIndex+1:]...)
			if len(configMocks[matchedIndex].Spec.MySqlResponses) == 0 {
				configMocks = (append(configMocks[:matchedIndex], configMocks[matchedIndex+1:]...))
			}

@Hermione2408
Copy link
Member Author

Okay will make the changes once PR 1214 gets merged

@Sarthak160
Copy link
Member

@Hermione2408 you can make the above changes as the PR has been merged for the deleteTCS mocks

Hermione2408 and others added 10 commits January 8, 2024 01:15
Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
…trings for readability

change binary lists in mysql mocks to base64 strings for readability and add a function to filter
out the firstSQL mock for handshake

Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
* fix: runs the commands using the -c flag of sh

the sh shell provides a flag to run multiple commands from a single shell cmd. So using this we will be able to use the parsing of script cmds of shell

Signed-off-by: re-Tick <jain.ritik.1001@gmail.com>

---------

Signed-off-by: re-Tick <jain.ritik.1001@gmail.com>
Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
* fix: remove binary match

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

* fix: add in memoryDb in test mode

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

* fix: merge conflicts

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

* fix: add binary matching with benchmark

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

* fix: remove mongo changes

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

* fix: remove print statements

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

---------

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
… tags in MYSQL

add omitempty,flow to json,yaml tags in MYSQL

Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
* fix: remove binary match

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

* fix: add in memoryDb in test mode

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

* fix: merge conflicts

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

* fix: add binary matching with benchmark

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

* fix: remove mongo changes

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

* fix: remove print statements

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

---------

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
Copy link
Member

@Sarthak160 Sarthak160 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Sarthak160 Sarthak160 merged commit e8a9497 into keploy:main Jan 10, 2024
13 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants