utPLSQL / utPLSQL-cli

Command line client for invoking utPLSQL
Apache License 2.0
40 stars 15 forks source link

reporters throwing the error #153

Closed MS-24 closed 5 years ago

MS-24 commented 5 years ago

Hi I am new to implementing utPLSQL-cli .

  1. When I use 'run' it executing fine , but with 'reporters' getting the below error.
    $ utplsql reporters $UT_DATABASE
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleType
        at org.utplsql.api.reporter.inspect.ReporterInspector310.getDescription(ReporterInspector310.java:67)
        at org.utplsql.api.reporter.inspect.ReporterInspector310.getReporterInfo(ReporterInspector310.java:51)
        at org.utplsql.api.reporter.inspect.ReporterInspector310.<init>(ReporterInspector310.java:34)
        at org.utplsql.api.reporter.inspect.ReporterInspector.create(ReporterInspector.java:35)
        at org.utplsql.cli.ReportersCommand.run(ReportersCommand.java:45)
        at org.utplsql.cli.Cli.runWithExitCode(Cli.java:42)
        at org.utplsql.cli.Cli.main(Cli.java:14)
    Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleType
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
  2. Also html report (-f=ut_coverage_html_reporter -o=coverage.html ) is not providing the coverage for the packages outside of the utplsql schema( utplsql framework installed in a separate schema) .
  3. I have successfully generated the html report for the same test suit with 'ut.run' html_report command.
  4. Please throw some light on what '-source_path' and how to identify my sourcepath . The value 'source' throwing error. (-source_path=source)
Successfully connected to database. UtPLSQL core: v3.1.2.2134
Oracle-Version: 12.1.0.2.0
java.lang.IllegalArgumentException: source is not a directory.
        at org.utplsql.cli.FileWalker.getFileList(FileWalker.java:20)
        at org.utplsql.cli.FileWalker.getFileList(FileWalker.java:13)
        at org.utplsql.cli.RunCommand.getFileMapperOptionsByParamListItem(RunCommand.java:310)
        at org.utplsql.cli.RunCommand.newTestRunner(RunCommand.java:232)
        at org.utplsql.cli.RunCommand.doRun(RunCommand.java:168)
        at org.utplsql.cli.RunCommand.run(RunCommand.java:216)
        at org.utplsql.cli.Cli.runWithExitCode(Cli.java:42)
        at org.utplsql.cli.Cli.main(Cli.java:14)

Could you please suggest what could have gone wrong here . Is it mismatch between the utPLSQL and utPLSQL-cli ? I thought utPLSQL-cli is compatible with utPLSQL3.0 and above per documentation.

Oracle-Version: 12.1.0.2.0 Running on utPLSQL v3.1.2.2134 utPLSQL-cli 3.1.6.local utPLSQL-java-api 3.1.6.411 Java-Version: 1.8.0_212

Thanks!!

jgebal commented 5 years ago

Can you share the full command you're using to issue html coverage? Are you coonecting as test owner or utplsql user?

pesse commented 5 years ago

Hi @MS-24

can you please run utplsql reporters $conn with the latest develop-binaries of cli? https://bintray.com/utplsql/utPLSQL-cli/download_file?file_path=utPLSQL-cli-develop-201906071035.zip

Cli should be downwards-compatible, but we didn't have automated tests against all previous versions (something we improved since then)

As for the source-path, please see http://utplsql.org/utPLSQL/v3.1.2/userguide/coverage.html#project-based-coverage (coverage documentation of the utPLSQL version you are using). It's a non-trivial topic and I'm not the best to help you out there (though plan to be :) )

jgebal commented 5 years ago

The source_path is not mandatory for html coverage. It is needed for peoper cobertura and sonar reports Source path needs to point to directory where your sources are stored. You can find details on all of those optipns in utPLSQL documentation.

MS-24 commented 5 years ago

Can you share the full command you're using to issue html coverage? Are you coonecting as test owner or utplsql user?

Hi @jgebal Thanks for the response . I have created new schema 'vutplsql' . Frankly I am not sure if it is the test owner or utplsql user. I defenitely didn't use 'ut3' user if it is the utplsql user that your refering to :) .

Command used for Run: "utplsql run VUTPLSQL/test123@myService -p=vutplsql.test_accountCreate_suite -f=ut_coverage_html_reporter -o=coverage.html "

Command used for reporters: utplsql reporters VUTPLSQL/test123@myService

Thanks!!

MS-24 commented 5 years ago

Hi @MS-24

can you please run utplsql reporters $conn with the latest develop-binaries of cli? https://bintray.com/utplsql/utPLSQL-cli/download_file?file_path=utPLSQL-cli-develop-201906071035.zip

Cli should be downwards-compatible, but we didn't have automated tests against all previous versions (something we improved since then)

As for the source-path, please see http://utplsql.org/utPLSQL/v3.1.2/userguide/coverage.html#project-based-coverage (coverage documentation of the utPLSQL version you are using). It's a non-trivial topic and I'm not the best to help you out there (though plan to be :) )

Hi @pesse Thanks for the response . No luck with the one you have provided.

/myHome/utPLSQL-cli-develop-201906071035/utPLSQL-cli/bin $ ./utplsql reporters $UT_DATABASE
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleType
        at org.utplsql.api.reporter.inspect.ReporterInspector310.getDescription(ReporterInspector310.java:67)
        at org.utplsql.api.reporter.inspect.ReporterInspector310.getReporterInfo(ReporterInspector310.java:51)
        at org.utplsql.api.reporter.inspect.ReporterInspector310.<init>(ReporterInspector310.java:34)
        at org.utplsql.api.reporter.inspect.ReporterInspector.create(ReporterInspector.java:35)
        at org.utplsql.cli.ReportersCommand.run(ReportersCommand.java:45)
        at org.utplsql.cli.Cli.runWithExitCode(Cli.java:42)
        at org.utplsql.cli.Cli.main(Cli.java:14)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleType
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
MS-24 commented 5 years ago

Hi I am new to implementing utPLSQL-cli .

  1. When I use 'run' it executing fine , but with 'reporters' getting the below error.
$ utplsql reporters $UT_DATABASE
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleType
        at org.utplsql.api.reporter.inspect.ReporterInspector310.getDescription(ReporterInspector310.java:67)
        at org.utplsql.api.reporter.inspect.ReporterInspector310.getReporterInfo(ReporterInspector310.java:51)
        at org.utplsql.api.reporter.inspect.ReporterInspector310.<init>(ReporterInspector310.java:34)
        at org.utplsql.api.reporter.inspect.ReporterInspector.create(ReporterInspector.java:35)
        at org.utplsql.cli.ReportersCommand.run(ReportersCommand.java:45)
        at org.utplsql.cli.Cli.runWithExitCode(Cli.java:42)
        at org.utplsql.cli.Cli.main(Cli.java:14)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleType
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
  1. Also html report (-f=ut_coverage_html_reporter -o=coverage.html ) is not providing the coverage for the packages outside of the utplsql schema( utplsql framework installed in a separate schema) .
  2. I have successfully generated the html report for the same test suit with 'ut.run' html_report command.
  3. Please throw some light on what '-source_path' and how to identify my sourcepath . The value 'source' throwing error. (-source_path=source)
Successfully connected to database. UtPLSQL core: v3.1.2.2134
Oracle-Version: 12.1.0.2.0
java.lang.IllegalArgumentException: source is not a directory.
        at org.utplsql.cli.FileWalker.getFileList(FileWalker.java:20)
        at org.utplsql.cli.FileWalker.getFileList(FileWalker.java:13)
        at org.utplsql.cli.RunCommand.getFileMapperOptionsByParamListItem(RunCommand.java:310)
        at org.utplsql.cli.RunCommand.newTestRunner(RunCommand.java:232)
        at org.utplsql.cli.RunCommand.doRun(RunCommand.java:168)
        at org.utplsql.cli.RunCommand.run(RunCommand.java:216)
        at org.utplsql.cli.Cli.runWithExitCode(Cli.java:42)
        at org.utplsql.cli.Cli.main(Cli.java:14)

Could you please suggest what could have gone wrong here . Is it mismatch between the utPLSQL and utPLSQL-cli ? I thought utPLSQL-cli is compatible with utPLSQL3.0 and above per documentation.

Oracle-Version: 12.1.0.2.0 Running on utPLSQL v3.1.2.2134 utPLSQL-cli 3.1.6.local utPLSQL-java-api 3.1.6.411 Java-Version: 1.8.0_212

Thanks!!

On Point#2 ,please suggest why utplsql couldn't generate the html report.

I have tried the below code for which the coverage report generated for the package 'codeToBeTested_pkg' in schema 'otherSchema' .

SET SERVEROUTPUT ON SIZE UNLIMITED
set lines 300
spool coverage_accUnbilledUsg.html

execute ut.run('vutplsql.test_accountCreation_suite', ut_coverage_html_reporter(),a_include_objects => ut_varchar2_list('otherSchema.codeToBeTested_pkg'));

But with utplsql I couldn't able to see the coverage report generated.

utplsql run vutplsql/test123@myservice -p=vutplsql.test_accountCreation_suite -f=ut_coverage_html_reporter -o=coverage.html -include=otherSchema.codeToBeTested_pkg

 or

utplsql run vutplsql/test123@myservice -p=vutplsql.test_accountCreation_suite -f=ut_coverage_html_reporter -o=coverage.html
MS-24 commented 5 years ago

Could someone help here please?

jgebal commented 5 years ago

When you run from SQL, are you also connected as vutplsql?

jgebal commented 5 years ago

Hi @MS-24 Sorry for a brief reply before - I was writing from my mobile.

In order to be able to help you we need to understand few basic challenges around your current setup.

Issue 1 - no coverage using utplsql-cli

Looking at the commands you're using I deduct that:

The unknowns are:

The reason why I'm asking is because you have non-recommended (harder to use) setup. Your test packages exist in different schema than the packages under test.

Due to the nature of how coverage is gathered, the user invoking (executing) unit tests must have additional privileges, if that user is not owning the code under test. You will not get coverage if user vutplsql doesn't have create any procedure and directly granted execute privileges on that is to gather coverage on. This is all documented in coverage doc

Issue 2 mapping sources

This is again well described in doc.

The idea is to be able to reflect DB code coverage on your project source files. This is only applicable if you are using some form of standardized project structure and is of great use if you want to represent coverage on Sonar (with sonar reporter) or Jenkins (with cobertura). Its not really needed to map sources to get coverage in HTML format. You can see example of how project source files get mapped into html report here

And to see how project files coverage can be presented sonar have a look here

Note

Almost all of command-line parameters for utplsql-cli map back to parameters available within ut.run procedure.

The client doesn't do much of extra transformations on top utplsql itself. The issue you're facing (no report output) is most-likely related to db user privileges.

Please let me know if that helps.

MS-24 commented 5 years ago

When you run from SQL, are you also connected as vutplsql?

Yes @jgebal . I am using the same schema when I use SQLPLUS ,sqldeveloper and utplsql. And this schema has 'CREATE ANY PROCEDURE' grant .

pesse commented 5 years ago

Hi @MS-24 , could you probably open a separate issue for the reporters-command problem or the source mapping problem? It's difficult to track multiple problems in one issue. Please also provide which ojdbc-library you are using, you can get information about it by running java -jar <ojdbc-libary.jar>

Example:

> java -jar ojdbc8-12.2.0.1.jar
Oracle 12.2.0.1.0 JDBC 4.2 compiled with javac 1.8.0_91 on Tue_Dec_13_06:08:31_PST_2016
jgebal commented 5 years ago

@pesse can you verify the command issued by cli when passing include list? I would expect it to be same as the example provided by @MS-24 See https://github.com/utPLSQL/utPLSQL/blob/develop/docs/userguide/coverage.md#setting-coverage-schemas for details on different behaviors with different options.

pesse commented 5 years ago

The command is always ut_runner.run( .... a_include_objects => ? ... ) where ? is an Oracle UT_VARCHAR2_LIST array. Is it somewhere logged what params are received by the API? Probably similar i18n problem as in #146

jgebal commented 5 years ago

@MS-24 do you include orai18n.jar with ojdbc in utplsql-cli lib folder?

MS-24 commented 5 years ago

Thanks much @jgebal for the help provided . Very much appreciate it . The problem solved for me by using the 3.1.2 version of utPLSQL-cli along with -include option . I am closing the issue. Thanks!!