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

Feature: added generateTestReport flag #1513

Merged
merged 13 commits into from
Feb 11, 2024

Conversation

Yaxhveer
Copy link
Contributor

@Yaxhveer Yaxhveer commented Feb 6, 2024

Related Issue

  • Info about Issue or bug

Closes: #1393

Describe the changes you've made

Added a Flag --generateTestReports to keploy test and config file which is true by default.

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

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
@Yaxhveer
Copy link
Contributor Author

Yaxhveer commented Feb 6, 2024

@gouravkrosx test reports will be generated in serve command since they are used to show status.

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
@gouravkrosx
Copy link
Member

gouravkrosx commented Feb 7, 2024

@Yaxhveer
You can delete the TestReport folder and files after the completion in case of the serve command.

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
@Yaxhveer
Copy link
Contributor Author

Yaxhveer commented Feb 7, 2024

@gouravkrosx Please review the changes.

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
@@ -384,17 +391,21 @@ func (t *Test) GetCmd() *cobra.Command {
}

path += "/keploy"
t.logger.Info("", zap.Any("keploy test and mock path", path))
Copy link
Member

Choose a reason for hiding this comment

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

Why has this line been added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually t.logger.Info("", zap.Any("keploy test and mock path", path), zap.Any("keploy testReport path", testReportPath)) was a combined log and I have divided it into two different log for path and testReport Path.

}

t.logger.Info("", zap.Any("keploy test and mock path", path), zap.Any("keploy testReport path", testReportPath))
Copy link
Member

Choose a reason for hiding this comment

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

Why have these essential logs been removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar reason divided it into two different logs

err = cfg.TestReportFS.Write(context.Background(), cfg.TestReportPath, cfg.TestReport)

t.logger.Info("test report for "+cfg.TestSet+": ", zap.Any("name: ", cfg.TestReport.Name), zap.Any("path: ", cfg.Path+"/"+cfg.TestReport.Name))
if cfg.GenerateTestReport {
Copy link
Member

Choose a reason for hiding this comment

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

if we are not generating the testreport we should atleast log once that we are skipping the test report since the flag has been set to false. Do this in all the services with this if condition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

var ps *proxy.ProxySet

defer pkg.DeleteTestReports(g.logger, generateTestReport)
Copy link
Member

Choose a reason for hiding this comment

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

why exactly are we deleting the reports at the end of the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

serve command require testReports to show status. So I removed the testReports when function ends

Copy link
Member

Choose a reason for hiding this comment

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

Can't we just get the status without writing to a file, or checking the condition before writing to the file?

Copy link
Contributor Author

@Yaxhveer Yaxhveer Feb 8, 2024

Choose a reason for hiding this comment

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

Actually this approach was recommended here #1513 (comment).

Copy link
Member

Choose a reason for hiding this comment

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

ok

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
@PranshuSrivastava
Copy link
Member

@Yaxhveer the functionality is working correctly, there is just one problem with the logs
image
Why is this same log being printed 3 times? It should be printed only once, or if you are logging three logs, they should atleast contain useful information that was not in the previous log, although I don't think that will be the case.

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
@Yaxhveer
Copy link
Contributor Author

Yaxhveer commented Feb 9, 2024

@PranshuSrivastava fixed the extra logs issue

Copy link
Member

@PranshuSrivastava PranshuSrivastava left a comment

Choose a reason for hiding this comment

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

LGTM

@PranshuSrivastava PranshuSrivastava merged commit e5e0872 into keploy:main Feb 11, 2024
13 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 11, 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.

[feature]: Make generating testReports files optional
3 participants