-
-
Notifications
You must be signed in to change notification settings - Fork 420
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
fix: Keploy unexpected behaviour with multiple dependencies #1214
Conversation
Apply Sweep Rules to your PR?
|
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@charankamarapu This looks good to me and the only method where I was updating mocks for change to MD5 Auth type has been also merged with Match function only, And that is used in case of latest postgres versions. Since test bench is also passing using that version only so we can conclude to be fine .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
Related Issue
Closes: #1209
Describe the changes you've made
PS : The line numbers below are corresponding to the line numbers in the issue mentioned above.
Time out is encountered in generic dependency because of the logic of writing mocks into yaml in generic. If any other dependencies is appending the mocks and as mutex is put, the generic parser had to wait till it gets its turn to add mock. Due to this there is a delay in receiving data from client or server in generic parser which is causing client timeouts in generic. Added go routine in generic parser where keploy appends mocks in mocks.yaml. This is go routine logic is already present in other parsers expect in generic.
Increased similarity index to improve approximate matching in generic dependency.
Implemented sorting the mocks in the
GetTcsMocks
function according to the req timestamp of the mock.There are two race conditions obeserved for this mismatch or misDelete of the mocks while matching.
i)
GetTcsMocks
is returning thetcsMocks
slice variable of the struct instead returning a copy it. So as different parsers update thetcsMocks
it will be reflected in all other parsers suddenly and causes race conditionsii) Updating the
tcsMocks
viaSetTcsMocks
function after every parser get its match with a mock. Due to this there is a race condition.Lets say
tcsMocks
viaGetTcsMocks
tcsMocks
viaGetTcsMocks
tcsMocks
viasetTcsMocks
tcsMocks
viasetTcsMocks
What happened here is the update made by parser a is lost.
To deal with these two race condition we are implementing a in-memory db go-memdb(which implements mvcc) and instead of resetting the tcsMocks after every match, we will delete that particular mock from the in-memory db. The only case where we can get a conflict is when some parser wants to delete the same mock which some other parser has already deleted. This cannot happen in different type of parsers. This can only happen in the case of connection pooling. In this case of conflict we will restart the matching process for that parser which faced the conflict. As we only have delete behaviour and not update we will not be implementing version based mvcc approach here.
Type of change
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:
Screenshots (if any)