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

Getting error "Could not find option with name js.ecmascript-version" when running test #2243

Closed
droger88 opened this issue Jan 22, 2023 · 12 comments

Comments

@droger88
Copy link

Currently we are planning to use karate test for our Apis developed using Quarkus/native.
Created a simple test case

Feature: get all products
    Background:
        url baseUrl
    Scenario: fetch all products should return non empty results
        Given url 'http://localhost:8080'
        Given path 'product'
        When method GET
        Then status 200

Integration test:

public class ProductIT {

    @Karate.Test
    Karate productAPITest() {
        return Karate.run().relativeTo(getClass());
    }
}

The idea is to run with @QuarkusIntegrationTest to test the native executable.
But we are getting following error

java.lang.IllegalArgumentException: Could not find option with name js.ecmascript-version.
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotEngineException.illegalArgument(PolyglotEngineException.java:131)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.OptionValuesImpl.failNotFound(OptionValuesImpl.java:274)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotContextConfig.findObjectForContextOption(PolyglotContextConfig.java:479)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotContextConfig.<init>(PolyglotContextConfig.java:284)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotEngineImpl.createContext(PolyglotEngineImpl.java:1732)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotEngineDispatch.createContext(PolyglotEngineDispatch.java:162)
	at org.graalvm.sdk/org.graalvm.polyglot.Context$Builder.build(Context.java:1861)
	at

Version:
Java:

openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)

Karate version

<dependency>
                <groupId>com.intuit.karate</groupId>
                <artifactId>karate-junit5</artifactId>
                <version>1.3.1</version>
                <scope>test</scope>
            </dependency>
@ptrthomas
Copy link
Member

@droger88 I think this thread will give you the answer, in short - try 1.4.0.RC3 and let us know: #2148 (comment)

@droger88
Copy link
Author

@ptrthomas Thanks for the quick reply. I have tried 1.4.0.RC3, and the error message did go away, but now I am getting org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 4 (expected 3).

@ptrthomas
Copy link
Member

@droger88 then read this and try using karate-core with classifier all: https://github.com/karatelabs/karate#karate-core-fat-jar

@droger88
Copy link
Author

@ptrthomas still no luck.
To make it simple without other complicated dependencies. I generate a new project using

 mvn archetype:generate \
-DarchetypeGroupId=com.intuit.karate \
-DarchetypeArtifactId=karate-archetype \
-DarchetypeVersion=1.4.0.RC3 \
-DgroupId=com.mycompany \
-DartifactId=myproject

Updated the pom with dependencies:

<dependencies>         
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-core</artifactId>
            <version>1.4.0.RC3</version>
            <classifier>all</classifier>
          </dependency>
          <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.9.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

run command man clean test
then I am getting the error again:

java.lang.IllegalArgumentException: Could not find option with name js.ecmascript-version.
        at examples.ExamplesTest.testParallel(ExamplesTest.java:14)

@ptrthomas
Copy link
Member

@droger88 sorry, it must be something about your Java install then. I generated a new project and used 1.4.0.RC3 and it works fine for me.

I suggest you help investigate and contribute a fix. as you would have seen in the other thread, there are folks using karate with quarkus without issues.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>com.mycompany</groupId>
    <artifactId>myproject</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
 
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <maven.compiler.version>3.8.1</maven.compiler.version>
        <maven.surefire.version>2.22.2</maven.surefire.version>        
        <karate.version>1.4.0.RC3</karate.version>
    </properties>    

    <dependencies>         
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-junit5</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>		
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgument>-Werror</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.version}</version>
                <configuration>
                    <argLine>-Dfile.encoding=UTF-8</argLine>
                </configuration>
            </plugin>          
        </plugins>        
    </build>       
    
</project>

@droger88
Copy link
Author

@ptrthomas Thanks a lot for the help. It is indeed the version of GraalVM version which cause the problem.
GraalVM 17.0.3+7-jvmci-22.1-b06 with java 17 works, but 22.2 or 22.3 does not. However the Quarkus version 2.14.3 we are using requires graalvm 22.3.0 with java 17.

I guess we will have to downgrade to java 11 GraalVM 22.2 build. Or is it something you can fix karate in the java 17 GraalVM 22.3 build? I am not a GraalVM experts, need to figure out what exactly causes the issue

@ptrthomas
Copy link
Member

@droger88 you can comment on the other thread and see if someone has some ideas. right now we don't have the bandwidth to investigate this. I have a feeling you are missing something because as far as I know, Karate should work for 1.4.0.RC3 (which uses Graal 22.3) on Java 17. I also thought that you are blocked by the ANTLR problem.

if you can submit a simple example following these instructions, it can increase the chances that someone investigates: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue

@ptrthomas
Copy link
Member

ptrthomas commented Feb 3, 2023

update - as per #2245 looks like Karate can work only with the "normal" JVM

@filsero
Copy link

filsero commented Apr 27, 2023

@droger88 I solved this issue by installing the nodejs component into graalvm (v. 22.3.1) with this command: gu install nodejs (maybe just installing js is enough: gu install js).

@ptrthomas
Copy link
Member

@filsero thanks for sharing !

@droger88
Copy link
Author

@filsero thanks a lot for sharing

@ptrthomas
Copy link
Member

cc @edwardsph @droger88 @filsero @maxandersen - folks I've just created a Karate-Quarkus example, do check it out when you get a chance: https://github.com/karatelabs/karate-examples/tree/main/quarkus

happy to take feedback and suggestions on any other common-patterns that can be added. if you know of public examples I can link to as a reference, do let me know. thanks !

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