Merge pull request #338 from kishkaru/fix_jenkins

Jenkins stabilization fixes
This commit is contained in:
Kishan Karunaratne
2015-05-27 16:04:28 -07:00
3 changed files with 37 additions and 17 deletions

View File

@@ -13,9 +13,10 @@
# limitations under the License.
from datetime import datetime, timedelta
import json
import json, six, sys, traceback, logging
from uuid import uuid4
import six
from cassandra import WriteTimeout
from cassandra.cqlengine.models import Model, ValidationError
import cassandra.cqlengine.columns as columns
@@ -23,10 +24,10 @@ from cassandra.cqlengine.management import sync_table, drop_table
from tests.integration.cqlengine import is_prepend_reversed
from tests.integration.cqlengine.base import BaseCassEngTestCase
log = logging.getLogger(__name__)
class TestSetModel(Model):
partition = columns.UUID(primary_key=True, default=uuid4)
int_set = columns.Set(columns.Integer, required=False)
text_set = columns.Set(columns.Text, required=False)
@@ -124,7 +125,14 @@ class TestSetColumn(BaseCassEngTestCase):
"""
Tests that big collections are detected and raise an exception.
"""
TestSetModel.create(text_set={str(uuid4()) for i in range(65535)})
while True:
try:
TestSetModel.create(text_set={str(uuid4()) for i in range(65535)})
break
except WriteTimeout:
ex_type, ex, tb = sys.exc_info()
log.warn("{0}: {1} Backtrace: {2}".format(ex_type.__name__, ex, traceback.extract_tb(tb)))
del tb
with self.assertRaises(ValidationError):
TestSetModel.create(text_set={str(uuid4()) for i in range(65536)})
@@ -235,7 +243,14 @@ class TestListColumn(BaseCassEngTestCase):
"""
Tests that big collections are detected and raise an exception.
"""
TestListModel.create(text_list=[str(uuid4()) for i in range(65535)])
while True:
try:
TestListModel.create(text_list=[str(uuid4()) for i in range(65535)])
break
except WriteTimeout:
ex_type, ex, tb = sys.exc_info()
log.warn("{0}: {1} Backtrace: {2}".format(ex_type.__name__, ex, traceback.extract_tb(tb)))
del tb
with self.assertRaises(ValidationError):
TestListModel.create(text_list=[str(uuid4()) for i in range(65536)])
@@ -410,7 +425,14 @@ class TestMapColumn(BaseCassEngTestCase):
"""
Tests that big collections are detected and raise an exception.
"""
TestMapModel.create(text_map={str(uuid4()): i for i in range(65535)})
while True:
try:
TestMapModel.create(text_map={str(uuid4()): i for i in range(65535)})
break
except WriteTimeout:
ex_type, ex, tb = sys.exc_info()
log.warn("{0}: {1} Backtrace: {2}".format(ex_type.__name__, ex, traceback.extract_tb(tb)))
del tb
with self.assertRaises(ValidationError):
TestMapModel.create(text_map={str(uuid4()): i for i in range(65536)})

View File

@@ -306,23 +306,23 @@ class UserDefinedTypeTests(BaseCassEngTestCase):
if PROTOCOL_VERSION < 4:
raise unittest.SkipTest("Protocol v4 datatypes in UDTs require native protocol 4+, currently using: {0}".format(PROTOCOL_VERSION))
class AllDatatypes(UserType):
class Allv4Datatypes(UserType):
a = columns.Date()
b = columns.SmallInt()
c = columns.Time()
d = columns.TinyInt()
class AllDatatypesModel(Model):
class Allv4DatatypesModel(Model):
id = columns.Integer(primary_key=True)
data = columns.UserDefinedType(AllDatatypes)
data = columns.UserDefinedType(Allv4Datatypes)
sync_table(AllDatatypesModel)
sync_table(Allv4DatatypesModel)
input = AllDatatypes(a=Date(date(1970, 1, 1)), b=32523, c=Time(time(16, 47, 25, 7)), d=123)
AllDatatypesModel.create(id=0, data=input)
input = Allv4Datatypes(a=Date(date(1970, 1, 1)), b=32523, c=Time(time(16, 47, 25, 7)), d=123)
Allv4DatatypesModel.create(id=0, data=input)
self.assertEqual(1, AllDatatypesModel.objects.count())
output = AllDatatypesModel.objects().first().data
self.assertEqual(1, Allv4DatatypesModel.objects.count())
output = Allv4DatatypesModel.objects().first().data
for i in range(ord('a'), ord('a') + 3):
self.assertEqual(input[chr(i)], output[chr(i)])

View File

@@ -89,8 +89,6 @@ class TypeTests(unittest.TestCase):
for expected, actual in zip(params, results):
self.assertEqual(expected, actual)
c.shutdown()
def test_can_insert_blob_type_as_bytearray(self):
"""
Tests that blob type in Cassandra maps to bytearray in Python