|
| 1 | +# This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +# file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 4 | + |
| 5 | +# These tests are dedicated to test the required cluster functionality of TypeDB drivers. |
| 6 | +# NOTE: This file should be run only against cluster deployments with 3 replicas. |
| 7 | + |
| 8 | +#noinspection CucumberUndefinedStep |
| 9 | +Feature: Driver Cluster |
| 10 | + |
| 11 | + Background: Open connection, verify cluster setup |
| 12 | + Given typedb starts |
| 13 | + Given connection opens with default authentication |
| 14 | + Given connection is open: true |
| 15 | + |
| 16 | + ########### |
| 17 | + # REPLICA # |
| 18 | + ########### |
| 19 | + |
| 20 | + Scenario: Driver can discover replicas in a cluster |
| 21 | + Then connection has 3 replicas |
| 22 | + Then connection primary replica exists |
| 23 | + Then connection get replica(127.0.0.1:11729) exists |
| 24 | + Then connection get replica(127.0.0.1:21729) exists |
| 25 | + Then connection get replica(127.0.0.1:31729) exists |
| 26 | + |
| 27 | + |
| 28 | + Scenario: Driver can query replica terms |
| 29 | + Then connection has 3 replicas |
| 30 | + Then connection get replica(127.0.0.1:11729) has term |
| 31 | + Then connection get replica(127.0.0.1:21729) has term |
| 32 | + Then connection get replica(127.0.0.1:31729) has term |
| 33 | + |
| 34 | + |
| 35 | + Scenario: Driver can inspect replica roles |
| 36 | + Then connection has 3 replicas |
| 37 | + Then connection replicas have roles: |
| 38 | + | primary | |
| 39 | + | secondary | |
| 40 | + | secondary | |
| 41 | + |
| 42 | + ################## |
| 43 | + # DRIVER OPTIONS # |
| 44 | + ################## |
| 45 | + |
| 46 | + @ignore-typedb-http-driver |
| 47 | + Scenario: Driver discovers all replicas even when connecting to single server |
| 48 | + When connection closes |
| 49 | + When connection opens to single server with default authentication |
| 50 | + Then connection is open: true |
| 51 | + Then connection has 3 replicas |
| 52 | + Then connection primary replica exists |
| 53 | + |
| 54 | + |
| 55 | + # TODO: Test that primary_failover_retries actually works by simulating failover |
| 56 | + @ignore-typedb-http-driver |
| 57 | + Scenario: Driver can configure failover retries |
| 58 | + When connection closes |
| 59 | + When set driver option primary_failover_retries to: 5 |
| 60 | + When connection opens with default authentication |
| 61 | + Then connection is open: true |
| 62 | + |
| 63 | + |
| 64 | + # TODO: Test that replica_discovery_attempts actually works by limiting discovery |
| 65 | + @ignore-typedb-http-driver |
| 66 | + Scenario: Driver can configure replica discovery attempts |
| 67 | + When connection closes |
| 68 | + When set driver option replica_discovery_attempts to: 10 |
| 69 | + When connection opens with default authentication |
| 70 | + Then connection is open: true |
| 71 | + Then connection has 3 replicas |
| 72 | + |
| 73 | + ####################### |
| 74 | + # CONSISTENCY - READS # |
| 75 | + ####################### |
| 76 | + |
| 77 | + @ignore-typedb-http-driver |
| 78 | + Scenario Outline: Driver can open read transaction with <consistency> consistency |
| 79 | + Given connection create database: typedb |
| 80 | + Given connection open schema transaction for database: typedb |
| 81 | + Given typeql schema query |
| 82 | + """ |
| 83 | + define entity person; |
| 84 | + """ |
| 85 | + Given transaction commits |
| 86 | + When set transaction option read_consistency_level to: <consistency> |
| 87 | + When connection open read transaction for database: typedb |
| 88 | + Then transaction is open: true |
| 89 | + Then transaction has type: read |
| 90 | + When get answers of typeql read query |
| 91 | + """ |
| 92 | + match entity $x; |
| 93 | + """ |
| 94 | + Then answer size is: 1 |
| 95 | + When transaction closes |
| 96 | + Examples: |
| 97 | + | consistency | |
| 98 | + | strong | |
| 99 | + | eventual | |
| 100 | + | replica(127.0.0.1:21729) | |
| 101 | + | replica(127.0.0.1:11729) | |
| 102 | + |
| 103 | + ######################## |
| 104 | + # CONSISTENCY - WRITES # |
| 105 | + ######################## |
| 106 | + |
| 107 | + @ignore-typedb-http-driver |
| 108 | + Scenario Outline: Driver schema and write transactions succeed regardless of consistency option (<consistency>) |
| 109 | + Given connection create database: typedb |
| 110 | + When set transaction option read_consistency_level to: <consistency> |
| 111 | + When connection open schema transaction for database: typedb |
| 112 | + Then transaction is open: true |
| 113 | + Then transaction has type: schema |
| 114 | + Then typeql schema query |
| 115 | + """ |
| 116 | + define entity person; |
| 117 | + """ |
| 118 | + When transaction commits |
| 119 | + When connection open write transaction for database: typedb |
| 120 | + Then transaction is open: true |
| 121 | + Then transaction has type: write |
| 122 | + Then typeql write query |
| 123 | + """ |
| 124 | + insert $p isa person; |
| 125 | + """ |
| 126 | + When transaction commits |
| 127 | + When connection open read transaction for database: typedb |
| 128 | + When get answers of typeql read query |
| 129 | + """ |
| 130 | + match $x isa person; |
| 131 | + """ |
| 132 | + Then answer size is: 1 |
| 133 | + Examples: |
| 134 | + | consistency | |
| 135 | + | strong | |
| 136 | + | eventual | |
| 137 | + | replica(127.0.0.1:21729) | |
| 138 | + | replica(127.0.0.1:11729) | |
| 139 | + |
| 140 | + ################################### |
| 141 | + # DATABASE CONSISTENCY OPERATIONS # |
| 142 | + ################################### |
| 143 | + |
| 144 | + @ignore-typedb-http-driver |
| 145 | + Scenario Outline: Database operations work with <consistency> consistency |
| 146 | + When set database operation consistency to: <consistency> |
| 147 | + Given connection has 0 databases |
| 148 | + When connection create database: consistency-test-db |
| 149 | + Then connection has 1 database |
| 150 | + When connection create database: typedb |
| 151 | + Then connection has 2 databases |
| 152 | + Then connection has databases: |
| 153 | + | consistency-test-db | |
| 154 | + | typedb | |
| 155 | + Then connection has database: consistency-test-db |
| 156 | + When connection delete database: consistency-test-db |
| 157 | + Then connection has 1 database |
| 158 | + When connection delete database: typedb |
| 159 | + Then connection has 0 databases |
| 160 | + Examples: |
| 161 | + | consistency | |
| 162 | + | strong | |
| 163 | + | eventual | |
| 164 | + | replica(127.0.0.1:21729) | |
| 165 | + | replica(127.0.0.1:11729) | |
0 commit comments