Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-2816

Gherkin test issues for implementers

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 3.6.1
    • 3.7.0, 3.6.2, 3.5.5
    • test-suite
    • None

    Description

      Sqlg is encountering some issues when running the Gherkin feature tests.

      g_V_repeatXout_repeatXoutX_timesX1XX_timesX1X_limitX1X_path_by_name

        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 |
      

      This test assumes an implicit order in the traversal. To fix the test we need to add in an order().by("name")

        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 |
      

      g_V_both_both_dedup_byXoutE_countX_name

        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 |
      

      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.

      @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());
      }
      
      

      This produces,

      [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)]
      

      For some reason the OrderGlobalStep is moved to the end, after the DedupGlobalStep

      g_V_playlist_paths

        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"]}] |
      

      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.

              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);
      

      g_withStrategiesXReadOnlyStrategyX_addVXpersonX_fromXVX1XX_toXVX2XX

        @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"
      

      This test assumes Integer ids are valid. If a graph does not support Integer ids then it fails with a different exception.

      g_withStrategiesXReadOnlyStrategyX_V_addVXpersonX_fromXVX1XX

        @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"
      

      This test assumes Integer ids are valid. If a graph does not support Integer ids then it fails with a different exception.

      g_V_order_byXoutE_count_descX

        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] |
      

      The order is not guaranteed as the out edge count repeats for 'vadas', 'lop' and 'ripple'.

      Attachments

        Activity

          People

            valentyn Valentyn Kahamlyk
            pietermartin pieter martin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: