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

Issue with the read function in 0.9.9RC4 Standalone Jar #1480

Closed
ricardgo403 opened this issue Feb 12, 2021 · 11 comments
Closed

Issue with the read function in 0.9.9RC4 Standalone Jar #1480

ricardgo403 opened this issue Feb 12, 2021 · 11 comments
Assignees

Comments

@ricardgo403
Copy link

Issue in Karate 0.9.9.RC4 (2021-02-09) Standalone Jar

Description

  • I followed the developer guide provided by intuit/karate repo to build the jar, and till this point, everything looked great, because all the unit tests passed and the built was successful. Build JAR

  • Then I tried to run my already built and functional test suites with this JAR, but unfortunately, it didn't go as expected.

  • The issue is when running using the following command:

java -jar karate.jar -e=dev smoke.feature

The run is stopped by an error, an exception thrown when reading from within the karate-config.js file some JSON and txt files.

ERROR com.intuit.karate - smoke.feature:5
* def projectCreation = read('features/subsMgmtOn/projects/createProject.feature')
smoke.feature:3
karate-config.js
>>>> js failed:
01: function fn() {
    ...
}
<<<<
org.graalvm.polyglot.PolyglotException: java.io.FileNotFoundException: null/configs.json (No such file or directory)
- com.intuit.karate.resource.FileResource.getStream(FileResource.java:94)
- com.intuit.karate.core.ScenarioFileReader.readFileAsStream(ScenarioFileReader.java:101)
- com.intuit.karate.core.ScenarioFileReader.readFileAsString(ScenarioFileReader.java:97)
- com.intuit.karate.core.ScenarioFileReader.readFile(ScenarioFileReader.java:53)
- com.intuit.karate.core.ScenarioEngine.lambda$new$0(ScenarioEngine.java:115)
- <js>.fn(Unnamed:7)

And as you can see the file configs.json is on the root path, in the latest stable version there was no problem with it.

So to me, the expected result was running the already known command and expect that all the features passed successfully.

It seems to me that the problem might be in the read function because when I asked about it a solution was provided, that was adding the file: prefix to the file path string; it worked. But then, when the smoke.feature called the features files it threw the same error/exception.

10:54:38.066 [main]  ERROR com.intuit.karate - smoke.feature:5
* def projectCreation = read('features/subsMgmtOn/projects/createProject.feature')
>>>> js failed:
01: read('features/subsMgmtOn/projects/createProject.feature')
<<<<
org.graalvm.polyglot.PolyglotException: java.io.FileNotFoundException: null/features/subsMgmtOn/projects/createProject.feature (No such file or directory)
- com.intuit.karate.resource.FileResource.getStream(FileResource.java:94)
- com.intuit.karate.core.FeatureParser.parse(FeatureParser.java:73)
- com.intuit.karate.core.Feature.read(Feature.java:66)
- com.intuit.karate.core.ScenarioFileReader.readFile(ScenarioFileReader.java:64)
- com.intuit.karate.core.ScenarioEngine.lambda$new$0(ScenarioEngine.java:115)
- <js>.:program(Unnamed:1)

You could find the Minimal, Complete and Verifiable version of the project in this repo

@ptrthomas ptrthomas self-assigned this Feb 12, 2021
@ptrthomas ptrthomas added the bug label Feb 12, 2021
@ptrthomas
Copy link
Member

@ricardgo403 I've attempted a fix, but see some other failures now. cc @ivangsa in case he has time to investigate

ptrthomas added a commit that referenced this issue Feb 12, 2021
@ptrthomas
Copy link
Member

@ricardgo403 haven't heard back, and I'm assuming this is fixed, closing. please open a new issue with specifics if needed, and try and simplify the project more (also don't check in the big zip file please)

@hujunhaorobert
Copy link

@ptrthomas I had reported a similar issue in the early part of thread #1373. When running mock testing with the latest karate-0.9.9.RC4.jar, I got the same error.
`Caused by: com.intuit.karate.KarateException: >>>> js failed:
01: read('karate-config.js')
<<<<
org.graalvm.polyglot.PolyglotException: java.io.FileNotFoundException: null/karate-config.js (No such file or directory)

  • com.intuit.karate.resource.FileResource.getStream(FileResource.java:94)
  • com.intuit.karate.core.ScenarioFileReader.readFileAsStream(ScenarioFileReader.java:101)
  • com.intuit.karate.core.ScenarioFileReader.readFileAsString(ScenarioFileReader.java:97)
  • com.intuit.karate.core.ScenarioFileReader.readFile(ScenarioFileReader.java:57)
  • com.intuit.karate.core.ScenarioEngine.lambda$new$0(ScenarioEngine.java:115)
  • .:program(Unnamed:1)`

If this bug is fixed, has the fix solution been integrated a release candidate yet?

@ptrthomas
Copy link
Member

@hujunhaorobert no RC so if you are able to follow these instructions and build locally, that will be very helpful: https://github.com/intuit/karate/wiki/Developer-Guide

@hujunhaorobert
Copy link

hujunhaorobert commented Feb 22, 2021

@ptrthomas , I had build a new karate-2.0.0.jar successfully by following the developer guide, which is great.
When running the mock test, there is an exception seen:
`
$ java -jar karate-2.0.0.jar -m main-mock-server.feature -p 8644

10:06:01.953 [main] INFO com.intuit.karate - Karate version: 2.0.0
10:06:03.458 [main] ERROR com.intuit.karate - mock-server background failed - main-mock-server.feature:4
com.intuit.karate.KarateException: mock-server background failed - main-mock-server.feature:4
at com.intuit.karate.core.MockHandler.(MockHandler.java:104)
at com.intuit.karate.core.MockServer$Builder.build(MockServer.java:107)
at com.intuit.karate.Main.call(Main.java:384)
at com.intuit.karate.Main.call(Main.java:57)
at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
at picocli.CommandLine.access$1200(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
at picocli.CommandLine.execute(CommandLine.java:2058)
at com.intuit.karate.Main.main(Main.java:291)
Caused by: com.intuit.karate.KarateException: java.lang.NullPointerException
main-mock-server.feature:4
at .: * call read('utils/utils.feature') (main-mock-server.feature:4:4)

main-mock-server.feature file
Feature: stateful mock server
Background:
* call read('karate-config.js')
* call read('utils/utils.feature')

utils/utils.feature is a common utility functions defined in a feature file.
I reckon the file name resolving ('utils/utils.feature' )might be problematic.

@ptrthomas
Copy link
Member

@hujunhaorobert help us replicate this please

@hujunhaorobert
Copy link

hujunhaorobert commented Feb 23, 2021

@ptrthomas do you want me to replicate the issue I reported above or the issue by @ricardgo403 at this thread beginning? I just guess the 2 issues might be duplicated or due to the similar root cause, so I put my finding here for reference.

@ptrthomas
Copy link
Member

@hujunhaorobert I want you to replicate the issue you found please, follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

@hujunhaorobert
Copy link

Hi @ptrthomas , here I attached a demo repo to replicate the failure : Would you please check it? https://github.com/hujunhaorobert/demoMockFailure

ptrthomas added a commit that referenced this issue Mar 2, 2021
the reason was because for the temp-use-runtime the suite hooks was null
but now changed to an empty collection to avoid the npe
also discovered an optimization in file-resource code
and also improved cli to load a logback.xml from working folder if exists ref #1471
@ptrthomas
Copy link
Member

@hujunhaorobert @JoshSchreuder I think I fixed the problem you reported, can you confirm off the develop branch

@hujunhaorobert
Copy link

hujunhaorobert commented Mar 2, 2021

@ptrthomas I re-generate karate-2.0.0.jar based on the latest develop branch and re-run the mock testing, seems the reported error is gone. Thanks for your effort on the fix solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants