dspot icon indicating copy to clipboard operation
dspot copied to clipboard

FEAT: support of parametrized that have complex naming conventions

Open gibello opened this issue 5 years ago • 5 comments

Characteristics

  • Issue Type: bug
  • Reproducibility: always
  • Severity: crash
  • Tool/Service/Component: DSpot maven plugin 2.1.1-SNAPSHOT
  • Execution Environment: Ubuntu Linux 18.04
  • Reporter: Pierre-Yves Gibello, [email protected]

Description

DSpot crashes with NPE. Seems related to reporting ?

Steps to reproduce

Tested on authzforce core project (https://gitlab.ow2.org/authzforce/core).

DSpot launched in core/pdp-engine directory, as follows: mvn eu.stamp-project:dspot-maven:2.1.1-SNAPSHOT:amplify-unit-tests -e

Ends with a NPE, and following stack:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  06:20 min
[INFO] Finished at: 2019-05-17T15:35:35+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal eu.stamp-project:dspot-maven:2.1.1-SNAPSHOT:amplify-unit-tests (default-cli) on project authzforce-ce-core-pdp-engine: Execution default-cli of goal eu.stamp-project:dspot-maven:2.1.1-SNAPSHOT:amplify-unit-tests failed.: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal eu.stamp-project:dspot-maven:2.1.1-SNAPSHOT:amplify-unit-tests (default-cli) on project authzforce-ce-core-pdp-engine: Execution default-cli of goal eu.stamp-project:dspot-maven:2.1.1-SNAPSHOT:amplify-unit-tests failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal eu.stamp-project:dspot-maven:2.1.1-SNAPSHOT:amplify-unit-tests failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.lang.NullPointerException
    at eu.stamp_project.utils.report.output.selector.TestSelectorReportImpl.lambda$output$0 (TestSelectorReportImpl.java:34)
    at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:193)
    at java.util.HashMap$KeySpliterator.forEachRemaining (HashMap.java:1556)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:471)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:499)
    at eu.stamp_project.utils.report.output.selector.TestSelectorReportImpl.output (TestSelectorReportImpl.java:35)
    at eu.stamp_project.utils.report.GlobalReport.output (GlobalReport.java:35)
    at eu.stamp_project.DSpotMojo.execute (DSpotMojo.java:316)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

gibello avatar May 17 '19 13:05 gibello

Hello @gibello

in the pdp-engine module, there are only parametrized tests.

It seems that the test-runner of DSpot does not support junit4 parametrized tests anymore. I might have introduced a regression.

I'm going to investigate.

In the meantime, I opened a pull request #805 to avoid the misleading error above.

danglotb avatar May 27 '19 13:05 danglotb

Actually, this happened when I had some configuration in the pom.xml of pdp-engine.

Do you have modified your pom.xml? If so, could you provide me your configuration?

Thank you.

danglotb avatar May 27 '19 14:05 danglotb

No config at all in the pom. Lanched exactly as specified in the issue : maybe not the right way to do (?), but should not produce a NPE.

gibello avatar May 27 '19 15:05 gibello

Okay, I did reproduce using the -Duse-maven-to-exe-test command line option (without I do not have the error thrown).

The real errors is the following:

[INFO] [INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ authzforce-ce-core-pdp-engine ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.ow2.authzforce.core.pdp.impl.test.value.StandardJavaTypeToXacmlAttributeDatatypeConversionTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.435 sec - in org.ow2.authzforce.core.pdp.impl.test.value.StandardJavaTypeToXacmlAttributeDatatypeConversionTest
[INFO] 
[INFO] Results :
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time:  4.889 s
[INFO] [INFO] Finished at: 2019-05-27T20:32:52+02:00
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project authzforce-ce-core-pdp-engine: No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]

The test-runner seems not to be able to execute parametrized tests using maven goals. It uses:

mvn clean test -Dtest=org.ow2.authzforce.core.pdp.impl.test.value.StandardJavaTypeToXacmlAttributeDatatypeConversionTest#test

to execute the test, which seems to be wrong since the test methods is parametrized.

I'll implement it ASAP and keep you update.

The reported errors (i.e. NPE on TestSelectorReport ) was a side effect of the fact that test-runner cannot (yet) execute parametrized tests with maven goals.

danglotb avatar May 27 '19 18:05 danglotb

After further investigations, the problem comes from the way the parametrized tests are named.

For example, in org.ow2.authzforce.core.pdp.impl.test.DefaultEnvironmentPropertiesTest, the tests are named as follow:

@Parameters(name = "{index}: {1}; user={2}; sys={3} -> {5}")

There are two issues here:

  1. the spaces between elements.
  2. the presence of : in the name, which is the path separator of Linux.

Why it is an issue?

Because to run the tests, DSpot uses the library test-runner that uses a classic java command line to execute the tests.

In a command line, the spaces are used to separate arguments and the path separator is used to specify arrays/list.

This is why DSpot is not able to execute the tests, and thus amplify them.

To be honest, I do not have the development power nor the time to address this very specific issue.

As already mentioned, the best targets for DSpot are unit tests. I suggest you move forward to another case study since this one is not applicable to DSpot.

However, if anyone in your team wants to address this issue, I would be glad to support its development both on DSpot and test-runner by answering questions and giving directions to do so.

Thank you very much.

danglotb avatar May 27 '19 21:05 danglotb