tzurp / performance-total

This WebdriverIO service is used to analyze performance of any test flow.
16 stars 2 forks source link

Results files are created for feature files that do NOT contain sampleStart/sampleEnd functions #36

Closed RaduIG closed 8 months ago

RaduIG commented 10 months ago

I have integrated the PerformanceTotal plugin 3.1.0 to the following framework:

Status: currently I have created a suite of E2E tests using the libraries above and for certain page transitions and some actions I would like to record the elapsed time using the PerformanceTotal plugin. For this purpose I have created separate feature files that are copy of the existing E2E that have the additional sampleStart and sampleEnd functions defined as steps in order to monitor the performance statistics wherever it is required.

Issue: after installing the performanceTotal plugin, whenever I start a test that does NOT contain the sampleStart/sampleEnd steps, the plugin still runs and generates results files with the last known values. This is not quite correct as it would affect ALL my E2E tests increasing run time and polluting the logs.

Question: would it be possible to have the performanceTotal plugin NOT affect feature files where the sampleStart/End functions are NOT used so that the results log are not displayed?

Steps definitions:

Given(/^I start performance analysis for feature: "([^"]*)?"$/, async (feature) => { performancetotal.sampleStart(feature); });

Given(/^I end performance analysis for feature: "([^"]*)?"$/, async (feature) => { performancetotal.sampleEnd(feature); });

Usage in performance feature files:

`@performance @generic Scenario: Login performance Given I start performance analysis for feature: "Login" When I log in as Admin user

tzurp commented 10 months ago

@RaduIG thanks for the detailed issue description! I guess that what you experienced is the normal behavior when the option is set by default to: 'disableAppendToExistingFile: false'. By default, previous data is not deleted from the 'performanceResultsDirectory' to enable accumulation of data to increase statistic accuracy. You can change this behavior by either of the following steps:

  1. Delete the performance results directory (manually or using a script), before you run your suites (default directory name is 'performance-results' and is located in the root of your test project).
  2. Change the plugin option to 'disableAppendToExistingFile: true'. Please note that this option deletes any previous performance data except that of the last wdio runner worker. Be aware that if you don't run tests in parallel, it would give you the optimal solution for your issue. However, if you run tests in parallel, the report would include only the data from the last worker.
  3. You can try adding a timestamp to the value of the 'performanceResultsDirectory' option. e.g. performanceResultsDirectory: "performance-results" + timestamp, but I can't guarantee it would solve your issue.

FYI, even if you accumulate a large amount of data from previous runs, it won't affect your tests runtime because the analysis of the data is occurring after the tests in a worker are done.

RaduIG commented 10 months ago

@tzurp thank you very much for your reply. I will test the suggestions you mentioned and come back with a reply, but please note that my feedback would most likely come either at the end of this week or next week at the latest due to some scheduling issues on my side. Please do not close the issue until then, thanks again!

RaduIG commented 8 months ago

@tzurp I will close the issue as I have found a much more convenient (and simpler) solution for my situation: instead of using one of the methods you suggested (which would imply refactoring some functions), I found it quicker and easier to run the tests using a separate wdio.config file using a separate tag. This avoids mixing the E2E tests and the performance ones and also allows me to run my tests independently on our Jenkins server.

Thank you again for your help!