Skip to content

Commit

Permalink
[GAIA CI Tests] Unify gremlin ci tests under different storages (#2504)
Browse files Browse the repository at this point in the history
<!--
Thanks for your contribution! please review
https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before
opening an issue.
-->

## What do these changes do?
1. unify gremlin ci tests under different storages
(groot/expr/vineyard), see
[RemoteTestGraph.java](https://github.com/shirly121/GraphScope/blob/ir_integrate_ci_tests/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/graph/RemoteTestGraph.java).
2. reorg test suite package from
`src/test/java/com/alibaba/graphscope/integration` to
`src/main/java/com/alibaba/graphscope/gremlin/integration/suite` , to be
imported by other modules.

<!-- Please give a short brief about these changes. -->

## Related issue number

<!-- Are there any issues opened that will be resolved by merging this
change? -->

Fixes #2510

---------

Co-authored-by: BingqingLyu <bingqing.lbq@alibaba-inc.com>
Co-authored-by: siyuanzhang.zsy <siyuanzhang.zsy@alibaba-inc.com>
  • Loading branch information
3 people committed Mar 16, 2023
1 parent ff9e85b commit 200034a
Show file tree
Hide file tree
Showing 53 changed files with 294 additions and 4,507 deletions.
2 changes: 1 addition & 1 deletion interactive_engine/compiler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test:
# start rpc server
# make run
gremlin_test:
mvn test -Dtest=com.alibaba.graphscope.integration.IrGremlinTest
mvn test -Dtest=com.alibaba.graphscope.integration.standard.IrGremlinTest

submit:
cd $(CUR_DIR) && $(java) \
Expand Down
1 change: 0 additions & 1 deletion interactive_engine/compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.FilterRankingStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.checkerframework.checker.nullness.qual.Nullable;

@Graph.OptIn("com.alibaba.graphscope.integration.IrGremlinTestSuite")
@Graph.OptIn("com.alibaba.graphscope.integration.ldbc.IrLdbcTestSuite")
@Graph.OptIn("com.alibaba.graphscope.integration.pattern.IrPatternTestSuite")
@Graph.OptIn(
"com.alibaba.graphscope.gremlin.integration.suite.standard.additional.IrAdditionalGraphTestSuite")
@Graph.OptIn("com.alibaba.graphscope.gremlin.integration.suite.standard.IrGremlinTestSuite")
@Graph.OptIn("com.alibaba.graphscope.gremlin.integration.suite.ldbc.IrLdbcTestSuite")
@Graph.OptIn("com.alibaba.graphscope.gremlin.integration.suite.pattern.IrPatternTestSuite")
@Graph.OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupTest",
method = "g_V_groupCount_selectXvaluesX_unfold_dedup",
Expand Down Expand Up @@ -1482,20 +1485,48 @@
method = "g_V_both_hasLabelXpersonX_order_byXage_descX_limitX5X_name",
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderTest",
reason = "Projection may introduce additional shuffling that can break the order.")

// cases unsupported in groot
// @Graph.OptOut(
// test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest",
// method = "g_VX1X_out_hasXid_2_3X",
// reason = "unsupported")
@Graph.OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest",
method = "g_V_hasXp_neqXvXX",
reason = "unsupported")
@Graph.OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest",
method = "g_V_hasXblahX",
reason = "unsupported")
@Graph.OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest",
method = "g_VX1X_hasXcircumferenceX",
reason = "unsupported")
@Graph.OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest",
method = "g_EX11X",
reason = "unsupported")
// @Graph.OptOut(
// test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ValueMapTest",
// method = "g_V_valueMapXname_ageX",
// reason = "unsupported")
public class RemoteTestGraph extends DummyGraph {
public static final String GRAPH_NAME = "test.graph.name";
private RemoteGremlinConnection remoteGremlinConnection;

public RemoteTestGraph(final Configuration configuration) {
public RemoteTestGraph(@Nullable final Configuration configuration) {
try {
String gremlinEndpoint = configuration.getString(GRAPH_NAME);
this.remoteGremlinConnection = new RemoteGremlinConnection(gremlinEndpoint);
if (configuration != null) {
String gremlinEndpoint = configuration.getString(GRAPH_NAME);
this.remoteGremlinConnection = new RemoteGremlinConnection(gremlinEndpoint);
}
} catch (Exception e) {
throw new RuntimeException("initiate remote test graph fail " + e);
}
}

public static RemoteTestGraph open(final Configuration configuration) {
public static RemoteTestGraph open(final Configuration configuration) throws Exception {
return new RemoteTestGraph(configuration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.alibaba.graphscope.integration.ldbc;
package com.alibaba.graphscope.gremlin.integration.suite.ldbc;

import org.apache.tinkerpop.gremlin.AbstractGremlinSuite;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.alibaba.graphscope.integration.ldbc;
package com.alibaba.graphscope.gremlin.integration.suite.ldbc;

import com.alibaba.graphscope.gremlin.plugin.traversal.IrCustomizedTraversal;
import com.google.common.collect.Sets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.alibaba.graphscope.integration.pattern;
package com.alibaba.graphscope.gremlin.integration.suite.pattern;

import org.apache.tinkerpop.gremlin.AbstractGremlinSuite;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

package com.alibaba.graphscope.integration.pattern;
package com.alibaba.graphscope.gremlin.integration.suite.pattern;

import com.alibaba.graphscope.gremlin.antlr4.__;
import com.alibaba.graphscope.gremlin.integration.suite.utils.__;
import com.alibaba.graphscope.gremlin.plugin.traversal.IrCustomizedTraversal;

import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/

package com.alibaba.graphscope.integration;
package com.alibaba.graphscope.gremlin.integration.suite.standard;

import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.dedup;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.outE;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*;

import com.alibaba.graphscope.gremlin.plugin.traversal.IrCustomizedTraversal;

import org.apache.tinkerpop.gremlin.LoadGraphWith;
import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
Expand All @@ -33,6 +33,7 @@
import java.util.*;

public abstract class IrGremlinQueryTest extends AbstractGremlinProcessTest {

public abstract Traversal<Vertex, Map<Object, Long>>
get_g_V_group_by_by_dedup_count_order_by_key();

Expand All @@ -45,44 +46,34 @@ public abstract class IrGremlinQueryTest extends AbstractGremlinProcessTest {
public abstract Traversal<Vertex, Object>
get_g_V_out_as_a_in_select_a_as_b_select_b_by_values();

@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
@Test
public void g_V_group_by_by_dedup_count_test() {
Traversal<Vertex, Map<Object, Long>> traversal =
this.get_g_V_group_by_by_dedup_count_order_by_key();
this.printTraversalForm(traversal);

String expected =
"{v[1]=1, v[2]=1, v[72057594037927939]=1, v[4]=1, v[72057594037927941]=1, v[6]=1}";
String expected = "{1=1, 2=1, 3=1, 4=1, 5=1, 6=1}";

Map<Object, Long> result = traversal.next();
Assert.assertEquals(expected, result.toString());
Assert.assertFalse(traversal.hasNext());
}

@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
@Test
public void g_V_group_by_outE_count_test() {
Traversal<Vertex, Map<Object, List>> traversal =
this.get_g_V_group_by_outE_count_order_by_key();
this.printTraversalForm(traversal);
Map<Object, List> result = traversal.next();
Assert.assertEquals(4, result.size());
result.forEach(
(k, v) -> {
Collections.sort(
v,
(Object o1, Object o2) -> {
long v1Id = (long) ((Vertex) o1).id();
long v2Id = (long) ((Vertex) o2).id();
return (int) (v1Id - v2Id);
});
});
Assert.assertEquals(
"{0=[v[2], v[72057594037927939], v[72057594037927941]], 1=[v[6]], 2=[v[4]],"
+ " 3=[v[1]]}",
result.toString());
result.forEach((k, v) -> Collections.sort(v));
Assert.assertEquals("{0=[2, 3, 5], 1=[6], 2=[4], 3=[1]}", result.toString());
Assert.assertFalse(traversal.hasNext());
}

@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
@Test
public void g_VX4X_bothE_as_otherV() {
Traversal<Vertex, Object> traversal = this.get_g_VX4X_bothE_as_otherV();
Expand All @@ -100,6 +91,7 @@ public void g_VX4X_bothE_as_otherV() {
Assert.assertEquals(expected.size(), counter);
}

@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
@Test
public void g_V_hasLabel_hasId_values() {
Traversal<Vertex, Object> traversal = this.get_g_V_hasLabel_hasId_values();
Expand All @@ -117,6 +109,7 @@ public void g_V_hasLabel_hasId_values() {
Assert.assertEquals(1, counter);
}

@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
@Test
public void g_V_out_as_a_in_select_a_as_b_select_b_by_valueMap() {
Traversal<Vertex, Object> traversal =
Expand All @@ -141,16 +134,16 @@ public static class Traversals extends IrGremlinQueryTest {
public Traversal<Vertex, Map<Object, Long>> get_g_V_group_by_by_dedup_count_order_by_key() {
return (IrCustomizedTraversal)
g.V().group()
.by()
.by("id")
.by(dedup().count())
.order()
.by(__.select(Column.keys).values("id"), Order.asc);
.by(__.select(Column.keys), Order.asc);
}

@Override
public Traversal<Vertex, Map<Object, List>> get_g_V_group_by_outE_count_order_by_key() {
return (IrCustomizedTraversal)
g.V().group().by(outE().count()).order().by(__.select(Column.keys));
g.V().group().by(outE().count()).by("id").order().by(__.select(Column.keys));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* under the License.
*/

package com.alibaba.graphscope.integration;
package com.alibaba.graphscope.gremlin.integration.suite.standard;

import org.apache.tinkerpop.gremlin.AbstractGremlinSuite;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
/*
* Copyright 2020 Alibaba Group Holding Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.graphscope.function.test.gremlin;
package com.alibaba.graphscope.gremlin.integration.suite.standard.additional;

import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.CREW;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* Copyright 2020 Alibaba Group Holding Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.graphscope.gremlin.integration.suite.standard.additional;

import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData;
import static org.apache.tinkerpop.gremlin.process.traversal.Order.desc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.apache.tinkerpop.gremlin.LoadGraphWith;
import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.List;
import java.util.Map;

@RunWith(GremlinProcessRunner.class)
public abstract class GratefulProcessTest extends AbstractGremlinProcessTest {
public abstract Traversal<Vertex, Long> get_g_V_both_both_count();

public abstract Traversal<Vertex, Map<Object, Object>>
get_g_V_hasXsong_name_OHBOYX_outXfollowedByX_outXfollowedByX_order_byXperformancesX_byXsongType_descX();

public abstract Traversal<Vertex, String>
get_g_V_hasLabelXsongX_order_byXperformances_descX_byXnameX_rangeX110_120X_name();

@Test
@LoadGraphWith(GraphData.GRATEFUL)
public void g_V_both_both_count() {
final Traversal<Vertex, Long> traversal = get_g_V_both_both_count();
printTraversalForm(traversal);
assertEquals(new Long(1406914), traversal.next());
assertFalse(traversal.hasNext());
}

@Test
@LoadGraphWith(GraphData.GRATEFUL)
public void
g_V_hasXsong_name_OHBOYX_outXfollowedByX_outXfollowedByX_order_byXperformancesX_byXsongType_descX() {
final Traversal<Vertex, Map<Object, Object>> traversal =
get_g_V_hasXsong_name_OHBOYX_outXfollowedByX_outXfollowedByX_order_byXperformancesX_byXsongType_descX();
printTraversalForm(traversal);
int counter = 0;
String lastSongType = "a";
int lastPerformances = Integer.MIN_VALUE;
while (traversal.hasNext()) {
final Map<Object, Object> valueMap = traversal.next();
final String currentSongType = (String) ((List) valueMap.get("songType")).get(0);
final int currentPerformances = (Integer) ((List) valueMap.get("performances")).get(0);
assertTrue(
currentPerformances == lastPerformances
|| currentPerformances > lastPerformances);
if (currentPerformances == lastPerformances)
assertTrue(
currentSongType.equals(lastSongType)
|| currentSongType.compareTo(lastSongType) < 0);
lastSongType = currentSongType;
lastPerformances = currentPerformances;
counter++;
}
assertEquals(144, counter);
}

public static class Traversals extends GratefulProcessTest {
@Override
public Traversal<Vertex, Long> get_g_V_both_both_count() {
return g.V().both().both().count();
}

@Override
public Traversal<Vertex, Map<Object, Object>>
get_g_V_hasXsong_name_OHBOYX_outXfollowedByX_outXfollowedByX_order_byXperformancesX_byXsongType_descX() {
return g.V().has("song", "name", "OH BOY")
.out("followedBy")
.out("followedBy")
.as("a")
.select("a")
.valueMap("performances", "songType")
.order()
.by(__.select("a").by("performances"))
.by(__.select("a").by("songType"), desc);
}

@Override
public Traversal<Vertex, String>
get_g_V_hasLabelXsongX_order_byXperformances_descX_byXnameX_rangeX110_120X_name() {
return g.V().hasLabel("song")
.order()
.by("performances", desc)
.by("name")
.range(110, 120)
.values("name");
}
}
}
Loading

0 comments on commit 200034a

Please sign in to comment.