dosubot[bot] commented on issue #2558:
URL:
https://github.com/apache/incubator-hugegraph/issues/2558#issuecomment-2154795821
<!-- Answer -->
To resolve the `java.lang.AssertionError` indicating that 'gremlin-groovy is
not an available GremlinScriptEngine' when running `GremlinApiTests` on
HugeGraph, follow these steps:
1. **Ensure Dependencies**: Add the `gremlin-groovy` dependency to your
`pom.xml` if you are using Maven:
```xml
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-groovy</artifactId>
<version>3.4.10</version> <!-- Use the appropriate version -->
</dependency>
```
2. **Check Configuration**: Verify that the `gremlin-groovy` script engine
is correctly configured in your HugeGraph server configuration. Ensure that the
`gremlin-groovy` script engine is listed in the `scriptEngines` configuration
in `gremlin-server.yaml`:
```yaml
scriptEngines: {
gremlin-groovy: {
plugins: {
org.apache.hugegraph.plugin.HugeGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
classImports: [
java.lang.Math,
org.apache.hugegraph.backend.id.IdGenerator,
org.apache.hugegraph.type.define.Directions,
org.apache.hugegraph.type.define.NodeRole,
org.apache.hugegraph.traversal.algorithm.CollectionPathsTraverser,
org.apache.hugegraph.traversal.algorithm.CountTraverser,
org.apache.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser,
org.apache.hugegraph.traversal.algorithm.CustomizePathsTraverser,
org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser,
org.apache.hugegraph.traversal.algorithm.HugeTraverser,
org.apache.hugegraph.traversal.algorithm.JaccardSimilarTraverser,
org.apache.hugegraph.traversal.algorithm.KneighborTraverser,
org.apache.hugegraph.traversal.algorithm.KoutTraverser,
org.apache.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser,
org.apache.hugegraph.traversal.algorithm.NeighborRankTraverser,
org.apache.hugegraph.traversal.algorithm.PathsTraverser,
org.apache.hugegraph.traversal.algorithm.PersonalRankTraverser,
org.apache.hugegraph.traversal.algorithm.SameNeighborTraverser,
org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser,
org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser,
org.apache.hugegraph.traversal.algorithm.SubGraphTraverser,
org.apache.hugegraph.traversal.algorithm.TemplatePathsTraverser,
org.apache.hugegraph.traversal.algorithm.steps.EdgeStep,
org.apache.hugegraph.traversal.algorithm.steps.RepeatEdgeStep,
org.apache.hugegraph.traversal.algorithm.steps.WeightedEdgeStep,
org.apache.hugegraph.traversal.optimize.Text,
org.apache.hugegraph.traversal.optimize.TraversalUtil,
org.apache.hugegraph.util.DateUtil
],
methodImports: [java.lang.Math#*]
},
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {
files: [scripts/empty-sample.groovy]
}
}
}
}
```
3. **Initialize Script Engine**: Ensure that the script engine is
initialized properly in your test setup. You might need to explicitly
initialize the `gremlin-groovy` script engine before running the tests:
```java
import
org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine;
import javax.script.ScriptEngineManager;
public class GremlinApiTest extends BaseApiTest {
static {
// Initialize the GremlinGroovyScriptEngine
ScriptEngineManager manager = new ScriptEngineManager();
manager.registerEngineName("gremlin-groovy", new
GremlinGroovyScriptEngine());
}
// Your test methods
}
```
4. **Set Language in GremlinRequest**: Ensure that your `GremlinRequest`
class in `GremlinAPI` is correctly setting the language to `gremlin-groovy`:
```java
public static class GremlinRequest implements Checkable {
@JsonProperty
private String gremlin;
@JsonProperty
private Map<String, Object> bindings = new HashMap<>();
@JsonProperty
private String language = "gremlin-groovy";
@JsonProperty
private Map<String, String> aliases = new HashMap<>();
// Other methods...
}
```
By ensuring that the `gremlin-groovy` dependency is included, the script
engine is properly initialized and configured, and the `GremlinRequest` class
is correctly set up, you should be able to resolve the
`java.lang.AssertionError` and run your `GremlinApiTests` successfully
<sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/GremlinApiTest.java)</sup><sup>[[2]](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-tools/assembly/travis/conf/gremlin-server.yaml)</sup><sup>[[3]](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-client/assembly/travis/conf/gremlin-server.yaml)</sup><sup>[[4]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/job/GremlinAPI.java)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]