Skip to content

Commit 8138dca

Browse files
committed
tests: stop using set_keyspace in test_can_register_udt_before_connecting
this test is doing multiple is using `USE` comamnd, seems like we are having same race conditions with the applying of those, and getting the following error once in a while: ``` > raise self._final_exception E cassandra.InvalidRequest: Error from server: code=2200 [Invalid query] message="Unknown field 'is_cool' in value of user defined type user" ``` in this test we'll use full qulified names of the table with the keyspace and not set_keyspsce (i.e. `USE` command) Fixes: #264
1 parent 19a099c commit 8138dca

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

Diff for: tests/integration/standard/test_udts.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
import unittest
16-
1716
from collections import namedtuple
1817
from functools import partial
1918
import six
@@ -127,17 +126,15 @@ def test_can_register_udt_before_connecting(self):
127126
CREATE KEYSPACE udt_test_register_before_connecting
128127
WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor': '1' }
129128
""")
130-
s.set_keyspace("udt_test_register_before_connecting")
131-
s.execute("CREATE TYPE user (age int, name text)")
132-
s.execute("CREATE TABLE mytable (a int PRIMARY KEY, b frozen<user>)")
129+
s.execute("CREATE TYPE udt_test_register_before_connecting.user (age int, name text)")
130+
s.execute("CREATE TABLE udt_test_register_before_connecting.mytable (a int PRIMARY KEY, b frozen<user>)")
133131

134132
s.execute("""
135133
CREATE KEYSPACE udt_test_register_before_connecting2
136134
WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor': '1' }
137135
""")
138-
s.set_keyspace("udt_test_register_before_connecting2")
139-
s.execute("CREATE TYPE user (state text, is_cool boolean)")
140-
s.execute("CREATE TABLE mytable (a int PRIMARY KEY, b frozen<user>)")
136+
s.execute("CREATE TYPE udt_test_register_before_connecting2.user (state text, is_cool boolean)")
137+
s.execute("CREATE TABLE udt_test_register_before_connecting2.mytable (a int PRIMARY KEY, b frozen<user>)")
141138

142139
# now that types are defined, shutdown and re-create Cluster
143140
c.shutdown()
@@ -150,19 +147,18 @@ def test_can_register_udt_before_connecting(self):
150147
c.register_user_type("udt_test_register_before_connecting2", "user", User2)
151148

152149
s = c.connect(wait_for_all_pools=True)
150+
c.control_connection.wait_for_schema_agreement()
153151

154-
s.set_keyspace("udt_test_register_before_connecting")
155-
s.execute("INSERT INTO mytable (a, b) VALUES (%s, %s)", (0, User1(42, 'bob')))
156-
result = s.execute("SELECT b FROM mytable WHERE a=0")
152+
s.execute("INSERT INTO udt_test_register_before_connecting.mytable (a, b) VALUES (%s, %s)", (0, User1(42, 'bob')))
153+
result = s.execute("SELECT b FROM udt_test_register_before_connecting.mytable WHERE a=0")
157154
row = result[0]
158155
self.assertEqual(42, row.b.age)
159156
self.assertEqual('bob', row.b.name)
160157
self.assertTrue(type(row.b) is User1)
161158

162159
# use the same UDT name in a different keyspace
163-
s.set_keyspace("udt_test_register_before_connecting2")
164-
s.execute("INSERT INTO mytable (a, b) VALUES (%s, %s)", (0, User2('Texas', True)))
165-
result = s.execute("SELECT b FROM mytable WHERE a=0")
160+
s.execute("INSERT INTO udt_test_register_before_connecting2.mytable (a, b) VALUES (%s, %s)", (0, User2('Texas', True)))
161+
result = s.execute("SELECT b FROM udt_test_register_before_connecting2.mytable WHERE a=0")
166162
row = result[0]
167163
self.assertEqual('Texas', row.b.state)
168164
self.assertEqual(True, row.b.is_cool)

0 commit comments

Comments
 (0)