Skip to content

Commit

Permalink
[test case] Check DML cases (#5264)
Browse files Browse the repository at this point in the history
* Check DML cases

* Add chinses char tests

Add more tests

Add mero delete edge tests

* Revert cases
  • Loading branch information
Aiee authored and Sophie-Xie committed Jan 28, 2023
1 parent cf5773e commit a94c6a9
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 4 deletions.
72 changes: 72 additions & 0 deletions tests/tck/features/delete/DeleteEdge.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,78 @@ Feature: Delete int vid of edge
| "Zhangsan" | 50 | "Jack" |
Then drop the used space

Scenario: delete edges delete the edge with rank 0 by default
Given an empty graph
And create a space with following options:
| partition_num | 1 |
| replica_factor | 1 |
| vid_type | int |
And having executed:
"""
CREATE TAG IF NOT EXISTS person(name string, age int);
CREATE EDGE IF NOT EXISTS friend(intimacy int);
"""
And having executed:
"""
INSERT VERTEX
person(name, age)
VALUES
hash("Zhangsan"):("Zhangsan", 22),
hash("Lisi"):("Lisi", 23);
INSERT EDGE
friend(intimacy)
VALUES
hash("Zhangsan")->hash("Lisi"):(1),
hash("Zhangsan")->hash("Lisi")@15:(2),
hash("Zhangsan")->hash("Lisi")@25:(3),
hash("Zhangsan")->hash("Lisi")@35:(4);
"""
# before delete get result by go
When executing query:
"""
GO FROM hash("Zhangsan") OVER friend
YIELD $^.person.name, friend.intimacy, friend._rank, friend._dst
"""
Then the result should be, in any order:
| $^.person.name | friend.intimacy | friend._rank | friend._dst |
| "Zhangsan" | 1 | 0 | hash("Lisi") |
| "Zhangsan" | 2 | 15 | hash("Lisi") |
| "Zhangsan" | 3 | 25 | hash("Lisi") |
| "Zhangsan" | 4 | 35 | hash("Lisi") |
# delete edge friend, by default only the edge with rank of 0 will be deleted
When executing query:
"""
DELETE EDGE friend hash("Zhangsan")->hash("Lisi");
"""
Then the execution should be successful
# check result
When executing query:
"""
GO FROM hash("Zhangsan") OVER friend
YIELD $^.person.name, friend.intimacy, friend._rank, friend._dst
"""
Then the result should be, in any order:
| $^.person.name | friend.intimacy | friend._rank | friend._dst |
| "Zhangsan" | 2 | 15 | hash("Lisi") |
| "Zhangsan" | 3 | 25 | hash("Lisi") |
| "Zhangsan" | 4 | 35 | hash("Lisi") |
# delete all edges with different ranks
When executing query:
"""
GO FROM hash("Zhangsan") OVER friend YIELD id($^) AS src, friend._rank AS rank, friend._dst AS dst
| DELETE EDGE friend $-.src -> $-.dst @ $-.rank;
"""
Then the execution should be successful
# check result
When executing query:
"""
GO FROM hash("Zhangsan") OVER friend
YIELD $^.person.name, friend.intimacy, friend._rank, friend._dst
"""
Then the result should be, in any order:
| $^.person.name | friend.intimacy | friend._rank | friend._dst |
Then drop the used space

Scenario: delete edges use pipe
Given load "nba_int_vid" csv data to a new space
# test delete with pipe wrong vid type
Expand Down
72 changes: 72 additions & 0 deletions tests/tck/features/delete/DeleteEdge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,78 @@ Feature: Delete string vid of edge
| "Zhangsan" | 50 | "Jack" |
Then drop the used space

Scenario: delete edges delete the edge with rank 0 by default
Given an empty graph
And create a space with following options:
| partition_num | 1 |
| replica_factor | 1 |
| vid_type | FIXED_STRING(20) |
And having executed:
"""
CREATE TAG IF NOT EXISTS person(name string, age int);
CREATE EDGE IF NOT EXISTS friend(intimacy int);
"""
And having executed:
"""
INSERT VERTEX
person(name, age)
VALUES
"Zhangsan":("Zhangsan", 22),
"Lisi":("Lisi", 23);
INSERT EDGE
friend(intimacy)
VALUES
"Zhangsan"->"Lisi":(1),
"Zhangsan"->"Lisi"@15:(2),
"Zhangsan"->"Lisi"@25:(3),
"Zhangsan"->"Lisi"@35:(4);
"""
# before delete get result by go
When executing query:
"""
GO FROM "Zhangsan" OVER friend
YIELD $^.person.name, friend.intimacy, friend._rank, friend._dst
"""
Then the result should be, in any order:
| $^.person.name | friend.intimacy | friend._rank | friend._dst |
| "Zhangsan" | 1 | 0 | "Lisi" |
| "Zhangsan" | 2 | 15 | "Lisi" |
| "Zhangsan" | 3 | 25 | "Lisi" |
| "Zhangsan" | 4 | 35 | "Lisi" |
# delete edge friend, by default only the edge with rank of 0 will be deleted
When executing query:
"""
DELETE EDGE friend "Zhangsan"->"Lisi";
"""
Then the execution should be successful
# check result
When executing query:
"""
GO FROM "Zhangsan" OVER friend
YIELD $^.person.name, friend.intimacy, friend._rank, friend._dst
"""
Then the result should be, in any order:
| $^.person.name | friend.intimacy | friend._rank | friend._dst |
| "Zhangsan" | 2 | 15 | "Lisi" |
| "Zhangsan" | 3 | 25 | "Lisi" |
| "Zhangsan" | 4 | 35 | "Lisi" |
# delete all edges with different ranks
When executing query:
"""
GO FROM "Zhangsan" OVER friend YIELD id($^) AS src, friend._rank AS rank, friend._dst AS dst
| DELETE EDGE friend $-.src -> $-.dst @ $-.rank;
"""
Then the execution should be successful
# check result
When executing query:
"""
GO FROM "Zhangsan" OVER friend
YIELD $^.person.name, friend.intimacy, friend._rank, friend._dst
"""
Then the result should be, in any order:
| $^.person.name | friend.intimacy | friend._rank | friend._dst |
Then drop the used space

Scenario: delete edges use pipe
Given load "nba" csv data to a new space
# test delete with pipe wrong vid type
Expand Down
1 change: 1 addition & 0 deletions tests/tck/features/delete/DeleteTag.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ Feature: Delete int vid of tag
"""
Then the execution should be successful
# after delete tag
# the output has one row because the vertex has multiple tags
When executing query:
"""
FETCH PROP ON player hash("Tim Duncan") YIELD player.name, player.age
Expand Down
3 changes: 2 additions & 1 deletion tests/tck/features/delete/DeleteTag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Feature: Delete string vid of tag
Then the result should be, in any order:
| id |
| "Tim Duncan" |
# delete one tag
# delete all tag
When executing query:
"""
DELETE TAG * FROM "Tim Duncan";
Expand Down Expand Up @@ -200,6 +200,7 @@ Feature: Delete string vid of tag
"""
Then the execution should be successful
# after delete tag
# the output has one row because the vertex has multiple tags
When executing query:
"""
FETCH PROP ON player "Tim Duncan" YIELD player.name, player.age
Expand Down
2 changes: 1 addition & 1 deletion tests/tck/features/delete/DeleteVertex.feature
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Feature: Delete string vid of vertex
| like._dst |
| "Kobe Bryant" |
| "Grant Hill" |
| -"Rudy Gay" |
| "Rudy Gay" |
# before delete hash id vertex to check value by go
When executing query:
"""
Expand Down
40 changes: 40 additions & 0 deletions tests/tck/features/insert/Insert.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,34 @@ Feature: Insert int vid of vertex and edge
VALUES hash("Laura"):("Laura", 8, "three", 20190901008),hash("Amber"):("Amber", 9, "four", 20180901003)
"""
Then the execution should be successful
When executing query:
"""
FETCH PROP ON person hash("Laura") YIELD person.name, person.age
"""
Then the result should be, in any order:
| person.name | person.age |
| 'Laura' | 8 |
When executing query:
"""
FETCH PROP ON student hash("Laura") YIELD student.grade, student.number
"""
Then the result should be, in any order:
| student.grade | student.number |
| 'three' | 20190901008 |
When executing query:
"""
FETCH PROP ON person hash("Amber") YIELD person.name, person.age
"""
Then the result should be, in any order:
| person.name | person.age |
| 'Amber' | 9 |
When executing query:
"""
FETCH PROP ON student hash("Amber") YIELD student.grade, student.number
"""
Then the result should be, in any order:
| student.grade | student.number |
| 'four' | 20180901003 |
# insert multi vertex one tag
When executing query:
"""
Expand Down Expand Up @@ -586,3 +614,15 @@ Feature: Insert int vid of vertex and edge
| src | dst |
| 300 | 400 |
Then drop the used space

Scenario: insert vertex with non existent tag
Given an empty graph
And create a space with following options:
| partition_num | 1 |
| replica_factor | 1 |
| vid_type | FIXED_STRING(10) |
When try to execute query:
"""
INSERT VERTEX invalid_vertex VALUES "non_existed_tag":()
"""
Then a SemanticError should be raised at runtime: No schema found
59 changes: 58 additions & 1 deletion tests/tck/features/insert/Insert.feature
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Feature: Insert string vid of vertex and edge
INSERT EDGE schoolmate(likeness, nickname) VALUES "Tom"->"Lucy":(85, "Lily")
"""
Then the execution should be successful
# insert vertex wrong type
# insert edge wrong type
When executing query:
"""
INSERT EDGE schoolmate(likeness, nickname) VALUES "Laura"->"Amber":("87", "");
Expand Down Expand Up @@ -224,6 +224,34 @@ Feature: Insert string vid of vertex and edge
"Amber":("Amber", 9, "four", 20180901003);
"""
Then the execution should be successful
When executing query:
"""
FETCH PROP ON person "Laura" YIELD person.name, person.age
"""
Then the result should be, in any order:
| person.name | person.age |
| 'Laura' | 8 |
When executing query:
"""
FETCH PROP ON student "Laura" YIELD student.grade, student.number
"""
Then the result should be, in any order:
| student.grade | student.number |
| 'three' | 20190901008 |
When executing query:
"""
FETCH PROP ON person "Amber" YIELD person.name, person.age
"""
Then the result should be, in any order:
| person.name | person.age |
| 'Amber' | 9 |
When executing query:
"""
FETCH PROP ON student "Amber" YIELD student.grade, student.number
"""
Then the result should be, in any order:
| student.grade | student.number |
| 'four' | 20180901003 |
# insert multi vertex one tag
When executing query:
"""
Expand Down Expand Up @@ -506,6 +534,22 @@ Feature: Insert string vid of vertex and edge
Then the result should be, in any order, with relax comparison:
| node |
| ('English') |
# insert Chinese character
# if the Chinese character is out of the fixed_string's size, it will be truncated,
# and no invalid char should be inserted
When executing query:
"""
INSERT VERTEX course(name) VALUES "Chinese":("中文字符")
"""
Then the execution should be successful
# check result
When executing query:
"""
FETCH PROP ON course "Chinese" YIELD vertex as node
"""
Then the result should be, in any order, with relax comparison:
| node |
| ('Chinese') |
# check result
When executing query:
"""
Expand All @@ -523,6 +567,7 @@ Feature: Insert string vid of vertex and edge
| course.name | course.introduce |
| 'Engli' | NULL |
| 'Math' | NULL |
| '中' | NULL |
When executing query:
"""
LOOKUP ON student YIELD student.name, student.age
Expand Down Expand Up @@ -630,3 +675,15 @@ Feature: Insert string vid of vertex and edge
"""
Then a ExecutionError should be raised at runtime: Storage Error: The VID must be a 64-bit integer or a string fitting space vertex id length limit.
Then drop the used space

Scenario: insert vertex with non existent tag
Given an empty graph
And create a space with following options:
| partition_num | 1 |
| replica_factor | 1 |
| vid_type | FIXED_STRING(10) |
When try to execute query:
"""
INSERT VERTEX invalid_vertex VALUES "non_existed_tag":()
"""
Then a SemanticError should be raised at runtime: No schema found
2 changes: 1 addition & 1 deletion tests/tck/features/insert/InsertEdgeOnDiffParts.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2021 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
Feature: Insert vertex and edge with if not exists
Feature: Insert edge on different parts

Scenario: insert edge with default value
Given an empty graph
Expand Down

0 comments on commit a94c6a9

Please sign in to comment.