forked from apache/cassandra-dtest
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
STAR-254 add DateRange and Geo tests (#9)
* STAR-254 add tests for geo and date range types
- Loading branch information
1 parent
353b1f1
commit d15a708
Showing
2 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import logging | ||
import pytest | ||
|
||
from dtest import Tester, create_ks | ||
|
||
logger = logging.getLogger(__name__) | ||
since = pytest.mark.since | ||
|
||
|
||
@since("4.0") | ||
class TestCqlshTypes(Tester): | ||
|
||
def prepare(self, workload=None): | ||
if not self.cluster.nodelist(): | ||
self.allow_log_errors = True | ||
self.cluster.populate(1) | ||
if workload is not None: | ||
for node in self.cluster.nodelist(): | ||
node.set_workload(workload) | ||
logger.debug('About to start cluster') | ||
self.cluster.start() | ||
logger.debug('Cluster started') | ||
for node in self.cluster.nodelist(): | ||
node.watch_log_for('Starting listening for CQL clients', timeout=60) | ||
self.cluster.nodelist()[0].watch_log_for('Created default superuser') | ||
self.node = self.cluster.nodelist()[0] | ||
|
||
conn = self.patient_cql_connection(self.node) | ||
create_ks(conn, 'ks', 1) | ||
|
||
logger.debug('prepare completed') | ||
|
||
def test_point(self): | ||
self.prepare() | ||
|
||
expected = 'POINT (1.2 2.3)' | ||
self.node.run_cqlsh("CREATE TABLE ks.point_tbl (k INT PRIMARY KEY, point 'PointType');") | ||
self.node.run_cqlsh("INSERT INTO ks.point_tbl (k, point) VALUES (1, '{}')".format(expected)) | ||
result = self.node.run_cqlsh("SELECT * FROM ks.point_tbl;") | ||
assert expected in result[0], result | ||
|
||
def test_linestring(self): | ||
self.prepare() | ||
|
||
expected = 'LINESTRING (30.0 10.0, 10.0 30.0, 40.0 40.0)' | ||
self.node.run_cqlsh("CREATE TABLE ks.line_tbl (k INT PRIMARY KEY, linestring 'LineStringType');") | ||
self.node.run_cqlsh("INSERT INTO ks.line_tbl (k, linestring) VALUES (1, '{}')".format(expected)) | ||
result = self.node.run_cqlsh("SELECT * FROM ks.line_tbl;") | ||
assert expected in result[0], result | ||
|
||
def test_polygon(self): | ||
self.prepare() | ||
|
||
expected = 'POLYGON ((30.0 10.0, 40.0 40.0, 20.0 40.0, 10.0 20.0, 30.0 10.0))' | ||
self.node.run_cqlsh("CREATE TABLE ks.polygon_tbl (k INT PRIMARY KEY, polygon 'PolygonType');") | ||
self.node.run_cqlsh("INSERT INTO ks.polygon_tbl (k, polygon) VALUES (1, '{}')".format(expected)) | ||
result = self.node.run_cqlsh("SELECT * FROM ks.polygon_tbl;") | ||
assert expected in result[0], result | ||
|
||
def test_date_range(self): | ||
self.prepare() | ||
|
||
expected = '[2015-01 TO *]' | ||
self.node.run_cqlsh("CREATE TABLE ks.date_range_tbl (k INT PRIMARY KEY, date_range_tbl 'DateRangeType');") | ||
self.node.run_cqlsh("INSERT INTO ks.date_range_tbl (k, date_range_tbl) VALUES (1, '{}')".format(expected)) | ||
result = self.node.run_cqlsh("SELECT * FROM ks.date_range_tbl;") | ||
assert expected in result[0], result |