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

Improving test coverage with keploy #471

Closed
wants to merge 65 commits into from

Conversation

cassiozareck
Copy link
Contributor

@cassiozareck cassiozareck commented Mar 13, 2023

Related Issue

Describe the changes you've made

Ive improved the test-coverage by more than 0.8% of Keploy using Keploy. To accomplish this I mainly used echo-sql as an iterator to Keploy Client at 6789. The Client was of course intercepted by an Keploy server hosted 6790 used to generate those tests

Please let us know if any test cases are added

Two tests-cases were responsible for about 0.2% of the tests-cases (73, 74), they were made using echo-sql in record mode. The others are responsible for the 0.6% and were made using interaction between Keploy Client and echo-sql but the same in Test Mode.

  • 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)

Improvements in test coverage:
Screenshot from 2023-03-13 13-28-24
Keploy actual test coverage:
Screenshot from 2023-03-13 13-28-58

Signed-off-by: Cássio Milczareck cassiomilczareck@gmail.com

iamskp99 and others added 30 commits February 1, 2023 11:50
* feat: add grpc-server support for record and replay

Signed-off-by: iamskp99 <iamskp99@gmail.com>

* feat: add test-export for grpc server support

Signed-off-by: iamskp99 <iamskp99@gmail.com>

* refactor: encoding grpc testcases into yaml

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

* fix: test export for grpc server support

Signed-off-by: iamskp99 <iamskp99@gmail.com>

* fix: grpc test export

Signed-off-by: iamskp99 <iamskp99@gmail.com>

* fix: test export for grpc server

Signed-off-by: iamskp99 <iamskp99@gmail.com>

* chore: updates the pre release of go-sdk

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

* refactor: integerates keploy tests for grpc-server methods

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

* ci: runs the local keploy binary in background to test keploy

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

* test: fix patyh error in TestDenoise tcs

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

* ci: removes grep cmd for mode in test job

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

* ci: test keploy with dedup enabled

* Update go.yml

* test: removes env statements from go test file

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

---------

Signed-off-by: iamskp99 <iamskp99@gmail.com>
Signed-off-by: re-Tick <jain.ritik.1001@gmail.com>
Co-authored-by: re-Tick <jain.ritik.1001@gmail.com>
Co-authored-by: Ritik Jain <60597329+re-Tick@users.noreply.github.com>
* chore: updates the pre release of go-sdk

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

* ci: updates test job of main.yml ci

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

---------

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

Signed-off-by: Neha Gupta <gneha21@yahoo.in>

* docs: updated readme

Signed-off-by: Neha Gupta <gneha21@yahoo.in>

---------

Signed-off-by: Neha Gupta <gneha21@yahoo.in>
* chore: updates the pre release of go-sdk

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

* ci: runs the latest keploy binary in background job

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

---------

Signed-off-by: re-Tick <jain.ritik.1001@gmail.com>
Signed-off-by: Neha Gupta <gneha21@yahoo.in>
* feat(entire-app): This change allows the users to select the headers that they do not want Keploy to record

Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>

* added function in the mock file

Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>

* fix: filter the header fields in testCase service

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

* feat(entire-server): added comments for the changes

Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>

* feat(entire-app): allows the user to remove or replace the fields from the test file

Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>

* feat(entire-app): changed the signature of the remove function to accept interfaces

Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>

* fix(entire-app): fixed merge conflicts

Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>

* feat(mock-library): function complete need to add support for mock library

Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>

* feat: adds replace and remove for mocking lib

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

* feat(mock-library): fixed replace method

Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>

* feat: replaces mock http request fields for mock-lib

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

* style: removes debug statement

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

* test: adds keploy tcs for filtering http tcs fields

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

* test(pkg/utils): adds tcs for filtering and replacing http mocks

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

* test(service/mock): adds input for error handling in replace and remove filters

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

* test(service/mock): adds input for invalid url in test file

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

---------

Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>
Signed-off-by: re-Tick <jain.ritik.1001@gmail.com>
Co-authored-by: re-Tick <jain.ritik.1001@gmail.com>
* Update CONTRIBUTING.md

Signed-off-by: sonichigo <kurosakiichigo.songoku@gmail.com>

* typo fixed

Signed-off-by: sonichigo <kurosakiichigo.songoku@gmail.com>

---------

Signed-off-by: sonichigo <kurosakiichigo.songoku@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
* Update CONTRIBUTING.md

Signed-off-by: sonichigo <kurosakiichigo.songoku@gmail.com>

* typo fixed

Signed-off-by: sonichigo <kurosakiichigo.songoku@gmail.com>

* Readme UI Removed

Signed-off-by: sonichigo <kurosakiichigo.songoku@gmail.com>

---------

Signed-off-by: sonichigo <kurosakiichigo.songoku@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Added telemetry events at service level
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
Co-authored-by: Neha Gupta <gneha21@yahoo.in>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Predefining Installation_id in telemetry-check
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Correcting telemetry-check github action
Signed-off-by: Ananya Nayak <55504616+Ananya2001-an@users.noreply.github.com>
Signed-off-by: Jyotirmoy Roy <jyotirmoyroy649@gmail.com>
Signed-off-by: Advik <adviksingh6632@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>

Added Telemetry Object in regression Test

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

Added Telemetry object in regression test

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

Added code coverage

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Changed trigger for RecordedTest and RecordedMock events
nehagup and others added 2 commits March 30, 2023 18:00
Signed-off-by: Neha Gupta <gneha21@yahoo.in>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
@cassiozareck
Copy link
Contributor Author

Sure i'll work on it

@cassiozareck cassiozareck force-pushed the improving_test_coverage branch 2 times, most recently from 620d072 to 0e2a077 Compare April 7, 2023 14:11
@cassiozareck
Copy link
Contributor Author

Hi @re-Tick I improved the test-coverage by testing replaceHttpFields function almost entirely. Im still working on this file to improve the test coverage but I could increase it in 15.7% already. I've found a way to increase even more soon I'll launch new commits but I've updated the PR so you can already review it.

* fix: downgrade dependencies to support go 1.16

BREAKING CHANGE: this downgrades go version of the project from v1.17 to v1.16

keploy#521
Signed-off-by: Shubham Jain <shubhamkjain@outlook.com>

* chore: use keploy-sdk v0.8.6

---------

Signed-off-by: Shubham Jain <shubhamkjain@outlook.com>
@cassiozareck
Copy link
Contributor Author

cassiozareck commented Apr 9, 2023

Coverage increased again by 7.6%. Which means a total of 23.3% increased since the actual version.
old:
Screenshot from 2023-04-08 21-31-13
new:
Screenshot from 2023-04-08 21-26-58

@re-Tick
Copy link
Contributor

re-Tick commented Apr 10, 2023

Please update the go.mod file

cassiozareck and others added 16 commits April 10, 2023 11:28
fix: downgrade dependencies to support go 1.16 (keploy#528)
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Also I changed the assignment of doc.Spec.Req.URL at "domain" case to be url.String() and not the raw string
"somethings" because this is the expected behaviour and doing this the tests can run properly.
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>

Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Here I've refactored so it becomes more alike the way keploy
do unit tests (table-driven pattern). Its important to mention
this commits solve the problem of pointing to the same object
from the last. Another observation is that changes will need
to be made on the mock.go file as tests are not passing. It
seems to be a bug related to the domain case at the switch.

Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Now we are covering almost the entire replaceHttpFields func. which
increases the coverage of the service/mock/mock.go file by 15.7%.
It's important to mention that it was necessary a change at the "domain"
case in the switch of the function in the assignment of doc.Spec.Req.URL
as it was before being assigned with the raw "something", now its being
assigned with url.Host which is the expected behaviour and helptests
 works.

Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Change from improving_coverage to main branch

Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
@Sarthak160
Copy link
Member

This PR is stale since we migrated to V2 which has newer code structure .

@Sarthak160 Sarthak160 closed this Sep 5, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accepted Don't Merge Should not be merged until this label is removed
Projects
None yet
Development

Successfully merging this pull request may close these issues.