You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/12/07 19:49:00 UTC

[jira] [Commented] (TINKERPOP-2816) Gherkin test issues for implementers

    [ https://issues.apache.org/jira/browse/TINKERPOP-2816?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17644494#comment-17644494 ] 

ASF GitHub Bot commented on TINKERPOP-2816:
-------------------------------------------

vkagamlyk opened a new pull request, #1892:
URL: https://github.com/apache/tinkerpop/pull/1892

   Improved Gherkin tests for more consistent results




> Gherkin test issues for implementers
> ------------------------------------
>
>                 Key: TINKERPOP-2816
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2816
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: test-suite
>    Affects Versions: 3.6.1
>            Reporter: pieter martin
>            Assignee: Valentyn Kahamlyk
>            Priority: Blocker
>
> Sqlg is encountering some issues when running the Gherkin feature tests.
> h2. g_V_repeatXout_repeatXoutX_timesX1XX_timesX1X_limitX1X_path_by_name
> {code:java}
>   Scenario: g_V_repeatXout_repeatXoutX_timesX1XX_timesX1X_limitX1X_path_by_name
>       Given the modern graph
>       And the traversal of
>         """
>         g.V().repeat(__.out().repeat(__.out()).times(1)).times(1).limit(1).path().by("name")
>         """
>       When iterated next
>       Then the result should be unordered
>         | result |
>         | marko |
>         | josh |
>         | ripple |
> {code}
> This test assumes an implicit order in the traversal. To fix the test we need to add in an {{order().by("name")}}
> {code:java}
>   Scenario: g_V_repeatXout_repeatXoutX_timesX1XX_timesX1X_limitX1X_path_by_name
>       Given the modern graph
>       And the traversal of
>         """
>         g.V().repeat(__.out().repeat(__.out().order().by("name", Order.desc)).times(1)).times(1).limit(1).path().by("name")
>         """
>       When iterated next
>       Then the result should be unordered
>         | result |
>         | marko |
>         | josh |
>         | ripple |
> {code}
> h2. g_V_both_both_dedup_byXoutE_countX_name
> {code:java}
>   Scenario: g_V_both_both_dedup_byXoutE_countX_name
>     Given the modern graph
>     And the traversal of
>       """
>       g.V().both().both().dedup().by(__.outE().count()).values("name")
>       """
>     When iterated to list
>     Then the result should be unordered
>       | result |
>       | marko |
>       | josh |
>       | peter |
>       | ripple |
> {code}
> This test assumes the order of {{{}V().both().both(){}}}.
> Unfortunately putting in an {{order().by("name")}} does not help. This is because of a second bug where {{TinkerPop}} is rewriting the steps incorrectly.
> {code:java}
> @Test
> public void testDedupSteps() {
>     final TinkerGraph g = TinkerFactory.createModern();
>     GraphTraversal<Vertex, String> traversal = g.traversal().V().both().both().order().by("name", Order.asc).dedup().by(__.outE().count()).<String>values("name");
>     traversal.hasNext();
>     System.out.println(((DefaultGraphTraversal)traversal).getSteps());
> }
> {code}
> This produces,
> {code:java}
> [TinkerGraphStep(vertex,[]), VertexStep(BOTH,vertex), NoOpBarrierStep(2500), VertexStep(BOTH,vertex), DedupGlobalStep(null,[VertexStep(OUT,edge), CountGlobalStep]), OrderGlobalStep([[value([CoalesceStep([value(name), (null)])]), asc]]), PropertiesStep([name],value)]
> {code}
> For some reason the {{OrderGlobalStep}} is moved to the end, after the {{DedupGlobalStep}}
> h2. g_V_playlist_paths
> {code:java}
>   Scenario: g_V_playlist_paths
>     Given the grateful graph
>     And the traversal of
>       """
>       g.V().has("name", "Bob_Dylan").
>         in("sungBy").order().by('name').as("a").
>         repeat(__.out().order().by('name').simplePath().from("a")).
>           until(__.out("writtenBy").has("name", "Johnny_Cash")).limit(1).as("b").
>         repeat(__.out().order().by('name').as("c").simplePath().from("b").to("c")).
>           until(__.out("sungBy").has("name", "Grateful_Dead")).limit(1).
>         path().from("a").unfold().
>         project("song", "artists").
>           by("name").
>           by(__.coalesce(__.out("sungBy", "writtenBy").dedup().values("name").order(), __.constant("Unknown")).fold())
>       """
>     When iterated to list
>     Then the result should be unordered
>       | result |
>       | m[{"song": "CHIMES OF FREEDOM", "artists": ["Bob_Dylan"]}] |
>       | m[{"song": "QUEEN JANE", "artists": ["Unknown"]}] |
>       | m[{"song": "ALTHEA", "artists": ["Garcia","Hunter"]}] |
>       | m[{"song": "BIG RIVER", "artists": ["Johnny_Cash","Weir"]}] |
>       | m[{"song": "HES GONE", "artists": ["Garcia","Hunter"]}] |
>       | m[{"song": "CAUTION", "artists": ["Grateful_Dead"]}] |
> {code}
> This test also assumes `order`. Even though it has `__.out().order().by('name')` it is the path that needs to be ordered. Ordering on `name` is not good enough as there are duplicates.
> Here is an improved version.
> {code:java}
>         List<Map<String, Object>> result = g.traversal().V().has("name", "Bob_Dylan").
>                 in("sungBy").order().by("name").as("a").
> //                repeat(__.out().order().by("name").simplePath().from("a")).
>                 repeat(__.out().order().by(__.path().by("name").map(pathTraverser -> pathTraverser.get().toString()), String::compareTo).simplePath().from("a")).
>                 until(__.out("writtenBy").has("name", "Johnny_Cash")).limit(1).as("b").
> //                repeat(__.out().order().by("name").as("c").simplePath().from("b").to("c")).
>                 repeat(__.out().order().by(__.path().by("name").map(pathTraverser -> pathTraverser.get().toString()), String::compareTo).as("c").simplePath().from("b").to("c")).
>                 until(__.out("sungBy").has("name", "Grateful_Dead")).limit(1).
>                 path().from("a").unfold().
>                 project("song", "artists").
>                 by("name").
>                 by(__.coalesce(__.out("sungBy", "writtenBy").dedup().values("name").order(), __.constant("Unknown")).fold()).toList();
>         List<Map<String, Object>> expected = Arrays.asList(
>                 new HashMap<String, Object>() {{
>                     put("song", "CHIMES OF FREEDOM");
>                     put("artists", Arrays.asList("Bob_Dylan"));
>                 }},
>                 new HashMap<String, Object>() {{
>                     put("song", "QUEEN JANE");
>                     put("artists", Arrays.asList("Unknown"));
>                 }},
>                 new HashMap<String, Object>() {{
>                     put("song", "ALTHEA");
>                     put("artists", Arrays.asList("Garcia", "Hunter"));
>                 }},
>                 new HashMap<String, Object>() {{
>                     put("song", "BIG RIVER");
>                     put("artists", Arrays.asList("Johnny_Cash", "Weir"));
>                 }},
>                 new HashMap<String, Object>() {{
>                     put("song", "BERTHA");
>                     put("artists", Arrays.asList("Garcia", "Hunter"));
>                 }},
>                 new HashMap<String, Object>() {{
>                     put("song", "DRUMS");
>                     put("artists", Arrays.asList("Grateful_Dead"));
>                 }}
>         );
>         Assert.assertEquals(expected, result);
> {code}
> h2. g_withStrategiesXReadOnlyStrategyX_addVXpersonX_fromXVX1XX_toXVX2XX
> {code:java}
>   @WithReadOnlyStrategy
>   Scenario: g_withStrategiesXReadOnlyStrategyX_addVXpersonX_fromXVX1XX_toXVX2XX
>     Given the empty graph
>     And the traversal of
>       """
>       g.withStrategies(ReadOnlyStrategy).addE("link").from(__.V(1)).to(__.V(2))
>       """
>     When iterated to list
>     Then the traversal will raise an error with message containing text of "The provided traversal has a mutating step and thus is not read only"
> {code}
> This test assumes Integer ids are valid. If a graph does not support Integer ids then it fails with a different exception.
> h2. g_withStrategiesXReadOnlyStrategyX_V_addVXpersonX_fromXVX1XX
> {code:java}
>   @WithReadOnlyStrategy
>   Scenario: g_withStrategiesXReadOnlyStrategyX_V_addVXpersonX_fromXVX1XX
>     Given the empty graph
>     And the traversal of
>       """
>       g.withStrategies(ReadOnlyStrategy).V().addE("link").from(__.V(1))
>       """
>     When iterated to list
>     Then the traversal will raise an error with message containing text of "The provided traversal has a mutating step and thus is not read only"
> {code}
> This test assumes Integer ids are valid. If a graph does not support Integer ids then it fails with a different exception.
> h2. g_V_order_byXoutE_count_descX
> {code:java}
>   Scenario: g_V_order_byXoutE_count_descX
>     Given the modern graph
>     And the traversal of
>       """
>       g.V().order().by(__.outE().count(), Order.desc)
>       """
>     When iterated to list
>     Then the result should be ordered
>       | result |
>       | v[marko] |
>       | v[josh]   |
>       | v[peter] |
>       | v[vadas] |
>       | v[lop] |
>       | v[ripple] |
> {code}
> The order is not guaranteed as the out edge count repeats for 'vadas', 'lop' and 'ripple'.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)