Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rollback and write query fetch tests after server fixes #322

Open
wants to merge 3 commits into
base: 3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 72 additions & 48 deletions connection/transaction.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ Feature: Connection Transaction
| write |
| schema |

# TODO: Fix rollback
# Scenario Outline: one database, <type> transaction rollback
# When connection create database: typedb
# Given connection open <type> transaction for database: typedb
# Then transaction rollbacks
# Then transaction is open: true
# Examples:
# | type |
# | write |
# | schema |
Scenario Outline: one database, <type> transaction rollback
When connection create database: typedb
Given connection open <type> transaction for database: typedb
Then transaction rollbacks
Then transaction is open: true
Examples:
| type |
| write |
| schema |

Scenario: read transaction cannot be rollbacked
When connection create database: typedb
Expand Down Expand Up @@ -302,45 +301,70 @@ Feature: Connection Transaction
"""
Then transaction commits

# TODO: Fix rollback
# Scenario: commit after a schema transaction rollback does nothing
# Given connection create database: typedb
# Given connection open schema transaction for database: typedb
# When typeql schema query
# """
# define entity person;
# """
# When transaction rollbacks
# When transaction commits
# When connection open read transaction for database: typedb
# When typeql read query
# """
# match entity $x;
# """
# Then answer size is: 0
Scenario: commit after a schema transaction rollback does nothing
Given connection create database: typedb
Given connection open schema transaction for database: typedb
When typeql schema query
"""
define entity person;
"""
Then get answers of typeql read query
"""
match entity $x;
"""
Then answer size is: 1
Then get answers of typeql read query
"""
match entity $x;
"""
Then answer size is: 1

# TODO: Fix rollback
# Scenario: commit after a write transaction rollback does nothing
# Given connection create database: typedb
# Given connection open schema transaction for database: typedb
# Given typeql schema query
# """
# define entity person;
# """
# Given transaction commits
# Given connection open write transaction for database: typedb
# When typeql write query
# """
# insert $x isa person;
# """
# When transaction rollbacks
# When transaction commits
# When connection open read transaction for database: typedb
# When typeql read query
# """
# match $x isa person;
# """
# Then answer size is: 0
When transaction rollbacks
Then typeql read query; fails with a message containing: "empty-set for some variable"
"""
match entity $x;
"""

When transaction commits
When connection open read transaction for database: typedb
Then typeql read query; fails with a message containing: "empty-set for some variable"
"""
match entity $x;
"""

Scenario: commit after a write transaction rollback does nothing
Given connection create database: typedb
Given connection open schema transaction for database: typedb
Given typeql schema query
"""
define entity person;
"""
Given transaction commits
Given connection open write transaction for database: typedb
When typeql write query
"""
insert $x isa person;
"""
When get answers of typeql read query
"""
match $x isa person;
"""
Then answer size is: 1

When transaction rollbacks
When get answers of typeql read query
"""
match $x isa person;
"""
Then answer size is: 0

When transaction commits
When connection open read transaction for database: typedb
When get answers of typeql read query
"""
match $x isa person;
"""
Then answer size is: 0

# TODO: Uncomment when options are implemented. Decide if it needs the following tag.
# @ignore-typedb
Expand Down
122 changes: 102 additions & 20 deletions driver/driver.feature
Original file line number Diff line number Diff line change
Expand Up @@ -300,25 +300,26 @@ Feature: TypeDB Driver
Then transaction is open: false


# TODO: Fix rollbacks on the server side
# Scenario: Driver can rollback transactions of schema and write types, cannot rollback transaction of type read
# When connection open schema transaction for database: typedb
# Then transaction has type: schema
# Then transaction is open: true
# When transaction rollbacks
# Then transaction is open: false
#
# When connection open write transaction for database: typedb
# Then transaction has type: write
# Then transaction is open: true
# When transaction rollbacks
# Then transaction is open: false
#
# When connection open read transaction for database: typedb
# Then transaction has type: read
# Then transaction is open: true
# Then transaction rollbacks; fails with a message containing: "todo"
# Then transaction is open: false
Scenario: Driver can rollback transactions of schema and write types, cannot rollback transaction of type read
When connection open schema transaction for database: typedb
Then transaction has type: schema
Then transaction is open: true
When transaction rollbacks
Then transaction is open: true

When transaction closes
When connection open write transaction for database: typedb
Then transaction has type: write
Then transaction is open: true
When transaction rollbacks
Then transaction is open: true

When transaction closes
When connection open read transaction for database: typedb
Then transaction has type: read
Then transaction is open: true
Then transaction rollbacks; fails with a message containing: "Read transactions cannot be rolled back"
Then transaction is open: false


# TODO: Check options setting and retrieval
Expand Down Expand Up @@ -612,7 +613,7 @@ Feature: TypeDB Driver
Then transaction commits


Scenario: Driver processes concept document query answers correctly
Scenario: Driver processes concept document query answers from read queries correctly
Given connection open schema transaction for database: typedb
Given typeql schema query
"""
Expand Down Expand Up @@ -799,6 +800,87 @@ Feature: TypeDB Driver
"""


Scenario: Driver processes concept document query answers from write queries correctly
Given connection open schema transaction for database: typedb
Given typeql schema query
"""
define entity person owns name @card(1); attribute name, value string; attribute age @abstract;
"""
Given transaction commits
When connection open write transaction for database: typedb
When get answers of typeql write query
"""
insert $p isa person, has name "John";
fetch {
"name": $p.name,
"sub fetch": {
"all attributes": { $p.* },
}
};
"""
Then answer type is: concept documents
Then answer type is not: ok
Then answer type is not: concept rows
Then answer query type is: write
Then answer query type is not: schema
Then answer query type is not: read
Then answer size is: 1
Then answer contains document:
"""
{
"name": "John",
"sub fetch": {
"all attributes": {
"name": "John"
}
}
}
"""
When get answers of typeql write query
"""
match
attribute $a;
insert
$p1 isa person, has name "Alice";
$p2 isa person, has name "Bob";
fetch {
"Alice's name": $p1.name,
"sub fetch": {
"Bob's all": { $p2.* },
}
};
"""
Then answer type is: concept documents
Then answer type is not: ok
Then answer type is not: concept rows
Then answer query type is: write
Then answer query type is not: schema
Then answer query type is not: read
Then answer size is: 2
Then answer contains document:
"""
{
"Alice's name": "Alice",
"sub fetch": {
"Bob's all": {
"name": "Bob"
}
}
}
"""
Then answer does not contain document:
"""
{
"Alice's name": "Bob",
"sub fetch": {
"Bob's all": {
"name": "Alice"
}
}
}
"""


Scenario: Driver processes query errors correctly
Given connection open schema transaction for database: typedb
Then typeql schema query; fails
Expand Down