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

Support for evaluating additional test goals #258

Merged

Conversation

imonteroperez
Copy link
Contributor

@imonteroperez imonteroperez commented Sep 23, 2020

This PR provides support for evaluating additional test goals as test results.

Context

  • A new PCT hook to launch integration tests for warnings-ng plugin was introduced in the past. See it here.
  • Although this PCT hook is able to launch new test types (as a complement to default ones based on surefire:test goal) some additional actions are required to provide support for it as well as for others that extends PluginWithIntegrationTestsHook in the future in order to evaluate properly the results obtained from the PCT.

Problem statement

  • Before this PR, when PCT is generating its report and some integration tests fail for warnings-ng it setup it as SUCCESS because it was only evaluating results for surefire:test goal.
  • In addition, detected that if test is skipped, it was marked as failure on test report too (for all test types - including default one based on surefire).
  • Also, if new integration tests for additional plugins are going to be included in the future, current design is extremely coupled to warnings-ng plugin needs.

Solution and implementation details

  • Created a new hook inheritance design for PluginWithIntegrationTestsHook that makes feasible to setup new integration test suites and plugins in an easy way, just providing an implementation for two abstract methods that requires which goals and test types your plugin requires in order to execute integration tests.
  • Status of PCT report is based on the status of the executed tests
  • Skipped tests are considered as ok instead of failure
  • Integration tests are included inside PCT report in case it fails (as usual for default ones based in surefire)
  • Example of output with integration tests failures for warnings-ng:
[INFO] Results:
[INFO] 
[INFO] Executed: 856
[...]    // 417 unit tests launched by surefire:test + 439 integration tests launched by failsafe:integration-test
[INFO] - io.jenkins.plugins.analysis.core.charts.CompositeBuildResultTest.shouldMergeNumberOfFixedIssues
[INFO] - io.jenkins.plugins.analysis.core.charts.CompositeBuildResultTest.shouldMergeNumberOfIssuesByOrigin
[INFO] - io.jenkins.plugins.analysis.core.charts.CompositeBuildResultTest.shouldMergeNumberOfNewIssues
[INFO] - io.jenkins.plugins.analysis.core.charts.CompositeBuildResultTest.shouldMergeNumberOfNewIssuesBySeverity
[INFO] - io.jenkins.plugins.analysis.core.charts.CompositeBuildResultTest.shouldMergeNumberOfTotalIssues
[INFO] - io.jenkins.plugins.analysis.core.charts.CompositeBuildResultTest.shouldMergeTotalNumberOfIssuesBySeverity
[...]
[INFO] - io.jenkins.plugins.analysis.warnings.tasks.TaskScannerTest.shouldScanFileWithWords
[INFO] - io.jenkins.plugins.analysis.warnings.tasks.TaskScannerTest.shouldScanFileWithoutTasks
[INFO] - io.jenkins.plugins.analysis.warnings.tasks.TaskScannerTest.shouldUseDefaults
[INFO] 
[INFO] Failed: 1
[INFO] - io.jenkins.plugins.analysis.warnings.steps.StepsITest.shouldShowWarningsOfGroovyParser
  • Example of generated report:
<entry>
      <pluginInfos>
        <pluginName>warnings-ng</pluginName>
        <pluginVersion>8.4.1</pluginVersion>
        <pluginUrl>jar:file:/pct/tmp/jenkins.war!/WEB-INF/plugins/warnings-ng.hpi</pluginUrl>
      </pluginInfos>
      <list>
        <compatResult>
          [...]
          <status>TEST_FAILURE</status>
          [...]
          <testDetails class="sorted-set">
                    <string>io.jenkins.plugins.analysis.warnings.steps.StepsITest.shouldShowWarningsOfGroovyParser</string>
          </testDetails>
          [...]          
        </compatResult>
      </list>
</entry>

@raul-arabaolaza @bmunozm @fcojfernandez

Copy link
Contributor

@raul-arabaolaza raul-arabaolaza left a comment

Choose a reason for hiding this comment

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

@imonteroperez Can you add a description of what is to be fixed by this PR and a bit of context? I known the reason of the change for other reasons, but that does not apply to any other person but me or @bmunozm that may want to review this.

Long story short, we found that when running the PCT for warnings-ng plugin the results of integration tests of the plugin were not properly recognized by the PCT. Those tests were launched by using maven failsafe plugin and triggered by using this hook

public abstract class PluginWithIntegrationTestsHook extends PluginCompatTesterHookBeforeExecution {

I am requesting changes because I disagree with the approach, hook interface is very simple and generic by purpose, you are adding methods to it to cover the needs of one plugin, not to hook into the default PCT lifecycle (checkout, compile, run tests)

If test results are not properly recognized that is something to be done in a particular hook executed after the tests are run, for example with a preexecution one that prevents default execution from the pct or similar approach, but PCT main code should be perfectly unaware of this.

Also I have my doubts if we should even run those integration tests on the PCT, are the commands used to update test dependencies before surefire:test also working for failsafe tests?

/**
* Provides a list of test types executed under the hook (i.e. hooks used to launch other tests rather than surefire.
*/
default Collection<String> getTestTypes() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a particular need for some plugins, not part (IMO) of any general build cycle process hook mechanism. I do not believe is a good idea to start adding particular methods to cover particular plugins needs to the base interface of the hook mechanism which is aimed to provide a way to override PCT logic for certain plugins. As such it has to be generic, particular needs can be implemented in each individual hook.

For example, what is the purpose of this method in a precompilehook or for a precheckout one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added description inside PR and applied your proposal. Thanks a lot! It improved the previous solution design a lot and simplify implementation. Kudos!

@imonteroperez imonteroperez marked this pull request as ready for review September 25, 2020 11:39
*/
public abstract class PluginWithIntegrationTestsHook extends PluginCompatTesterHookBeforeExecution {

/** Inform about goals to execute integration tests */
abstract public Collection<String> getGoals();
Copy link

Choose a reason for hiding this comment

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

Are we sure these are not being used outside? Also having nullability annotations would be nice I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, AFAIK seems only used here (see also: https://github.com/search?q=PluginWithIntegrationTestsHook&type=code) Added NonNull annotation too here b692261


for (int j = 0; j < nodeList.getLength(); j++) {
if (nodeList.item(j).getNodeName().equals("skipped")) {
return false;
Copy link

Choose a reason for hiding this comment

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

So if there is one skipped test, this is saying there are no test failures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only the specific test that is skipped will not be considered as a failure. Before this PR it was considered as a failure.

return info;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Extra spaces 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! fixed in a917eb1

@imonteroperez
Copy link
Contributor Author

Seems PR builder failures are same than master https://ci.jenkins.io/blue/organizations/jenkins/jenkinsci-libraries%2Fplugin-compat-tester/detail/master/147/pipeline, so unrelated with this PR

@raul-arabaolaza
Copy link
Contributor

Enough approvals or time for others to block this, so merging

@raul-arabaolaza raul-arabaolaza merged commit 38ee180 into jenkinsci:master Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants