本文整理汇总了Python中assertions.assert_one函数的典型用法代码示例。如果您正苦于以下问题:Python assert_one函数的具体用法?Python assert_one怎么用?Python assert_one使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_one函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: rename_test
def rename_test(self):
session = self.prepare(start_rpc=True)
node = self.cluster.nodelist()[0]
host, port = node.network_interfaces['thrift']
client = get_thrift_client(host, port)
client.transport.open()
cfdef = CfDef()
cfdef.keyspace = 'ks'
cfdef.name = 'test'
cfdef.column_type = 'Standard'
cfdef.comparator_type = 'CompositeType(Int32Type, Int32Type, Int32Type)'
cfdef.key_validation_class = 'UTF8Type'
cfdef.default_validation_class = 'UTF8Type'
client.set_keyspace('ks')
client.system_add_column_family(cfdef)
session.execute("INSERT INTO ks.test (key, column1, column2, column3, value) VALUES ('foo', 4, 3, 2, 'bar')")
time.sleep(1)
session.execute("ALTER TABLE test RENAME column1 TO foo1 AND column2 TO foo2 AND column3 TO foo3")
assert_one(session, "SELECT foo1, foo2, foo3 FROM test", [4, 3, 2])
开发者ID:steveandwang,项目名称:cassandra-dtest,代码行数:25,代码来源:cql_tests.py
示例2: query_all_new_column_test
def query_all_new_column_test(self):
"""
Test that a materialized view created with a 'SELECT *' works as expected when adding a new column
@expected_result The new column is present in the view.
"""
session = self.prepare(user_table=True)
self._insert_data(session)
assert_one(
session,
"SELECT * FROM users_by_state WHERE state = 'TX' AND username = 'user1'",
['TX', 'user1', 1968, 'f', '[email protected]', None]
)
session.execute("ALTER TABLE users ADD first_name varchar;")
results = session.execute("SELECT * FROM users_by_state WHERE state = 'TX' AND username = 'user1'")
self.assertEqual(len(results), 1)
self.assertTrue(hasattr(results[0], 'first_name'), 'Column "first_name" not found')
assert_one(
session,
"SELECT * FROM users_by_state WHERE state = 'TX' AND username = 'user1'",
['TX', 'user1', 1968, None, 'f', '[email protected]', None]
)
开发者ID:emolsson,项目名称:cassandra-dtest,代码行数:26,代码来源:materialized_views_test.py
示例3: index_test
def index_test(self):
"""
Smoke test CQL statements related to indexes:
- CREATE a table
- CREATE an index on that table
- INSERT 10 values into the table
- SELECT from the table over the indexed value and assert the expected values come back
- drop the index
- assert SELECTing over the indexed value raises an InvalidRequest
# TODO run SELECTs to make sure each statement works
"""
session = self.prepare()
session.execute("CREATE TABLE test3 (k int PRIMARY KEY, v1 int, v2 int)")
table_meta = UpdatingTableMetadataWrapper(session.cluster, ks_name='ks', table_name='test3')
session.execute("CREATE INDEX testidx ON test3 (v1)")
self.assertIn('testidx', table_meta.indexes)
for i in range(0, 10):
session.execute("INSERT INTO test3 (k, v1, v2) VALUES ({i}, {i}, {i})".format(i=i))
assert_one(session, "SELECT * FROM test3 WHERE v1 = 0", [0, 0, 0])
session.execute("DROP INDEX testidx")
self.assertNotIn('testidx', table_meta.indexes)
开发者ID:alipourm,项目名称:cassandra-dtest,代码行数:26,代码来源:cql_tests.py
示例4: compaction_test
def compaction_test(self):
cluster = self.cluster
cluster.populate(3).start()
[node1,node2,node3] = cluster.nodelist()
cursor = self.patient_cql_connection(node1)
self.create_ks(cursor, 'ks', 3)
cursor.execute("create table tab(key int PRIMARY KEY, val int);")
node3.stop()
for x in range(0, 100):
cursor.execute("insert into tab(key,val) values(" + str(x) + ",0)")
node1.flush()
node3.start()
if cluster.version() >= "3.0":
node3.repair()
else:
node3.nodetool("repair -par -inc")
for x in range(0, 150):
cursor.execute("insert into tab(key,val) values(" + str(x) + ",1)")
node1.flush()
node2.flush()
node3.flush()
node3.nodetool('compact')
for x in range(0, 150):
assert_one(cursor, "select val from tab where key =" + str(x), [1])
开发者ID:slivne,项目名称:cassandra-dtest,代码行数:31,代码来源:incremental_repair_test.py
示例5: stop_commit_failure_policy_test
def stop_commit_failure_policy_test(self):
""" Test the stop_commit commitlog failure policy """
self.prepare(configuration={
'commit_failure_policy': 'stop_commit'
})
self.session1.execute("""
INSERT INTO test (key, col1) VALUES (2, 2);
""")
self._provoke_commitlog_failure()
failure = self.node1.grep_log("Failed .+ commit log segments. Commit disk failure policy is stop_commit; terminating thread")
debug(failure)
self.assertTrue(failure, "Cannot find the commitlog failure message in logs")
self.assertTrue(self.node1.is_running(), "Node1 should still be running")
# Cannot write anymore after the failure
with self.assertRaises((OperationTimedOut, WriteTimeout)):
self.session1.execute("""
INSERT INTO test (key, col1) VALUES (2, 2);
""")
# Should be able to read
assert_one(
self.session1,
"SELECT * FROM test where key=2;",
[2, 2]
)
开发者ID:dkua,项目名称:cassandra-dtest,代码行数:28,代码来源:commitlog_test.py
示例6: udf_with_udt_test
def udf_with_udt_test(self):
"""
Test UDFs that operate on non-frozen UDTs.
@jira_ticket CASSANDRA-7423
@since 3.6
"""
session = self.prepare()
session.execute("create type test (a text, b int);")
session.execute("create function funk(udt test) called on null input returns int language java as 'return Integer.valueOf(udt.getInt(\"b\"));';")
if LooseVersion(self.cluster.version()) >= LooseVersion('3.6'):
frozen_vals = (False, True)
else:
frozen_vals = (True,)
for frozen in frozen_vals:
debug("Using {} UDTs".format("frozen" if frozen else "non-frozen"))
table_name = "tab_frozen" if frozen else "tab"
column_type = "frozen<test>" if frozen else "test"
session.execute("create table {} (key int primary key, udt {});".format(table_name, column_type))
session.execute("insert into %s (key, udt) values (1, {a: 'un', b:1});" % (table_name,))
session.execute("insert into %s (key, udt) values (2, {a: 'deux', b:2});" % (table_name,))
session.execute("insert into %s (key, udt) values (3, {a: 'trois', b:3});" % (table_name,))
assert_one(session, "select sum(funk(udt)) from {}".format(table_name), [6])
assert_invalid(session, "drop type test;")
开发者ID:c-kodman,项目名称:cassandra-dtest,代码行数:29,代码来源:user_functions_test.py
示例7: rename_test
def rename_test(self):
"""
Check that a thrift-created table can be renamed via CQL:
- create a table via the thrift interface
- INSERT a row via CQL
- ALTER the name of the table via CQL
- SELECT from the table and assert the values inserted are there
"""
session = self.prepare(start_rpc=True)
node = self.cluster.nodelist()[0]
host, port = node.network_interfaces['thrift']
client = get_thrift_client(host, port)
client.transport.open()
cfdef = CfDef()
cfdef.keyspace = 'ks'
cfdef.name = 'test'
cfdef.column_type = 'Standard'
cfdef.comparator_type = 'CompositeType(Int32Type, Int32Type, Int32Type)'
cfdef.key_validation_class = 'UTF8Type'
cfdef.default_validation_class = 'UTF8Type'
client.set_keyspace('ks')
client.system_add_column_family(cfdef)
session.execute("INSERT INTO ks.test (key, column1, column2, column3, value) VALUES ('foo', 4, 3, 2, 'bar')")
session.execute("ALTER TABLE test RENAME column1 TO foo1 AND column2 TO foo2 AND column3 TO foo3")
assert_one(session, "SELECT foo1, foo2, foo3 FROM test", [4, 3, 2])
开发者ID:alipourm,项目名称:cassandra-dtest,代码行数:30,代码来源:cql_tests.py
示例8: test_read_old_sstables_after_upgrade
def test_read_old_sstables_after_upgrade(self):
""" from 2.1 the location of sstables changed (CASSANDRA-5202), but existing sstables continue
to be read from the old location. Verify that this works for index sstables as well as regular
data column families (CASSANDRA-9116)
"""
cluster = self.cluster
# Forcing cluster version on purpose
cluster.set_install_dir(version="2.0.12")
if "memtable_allocation_type" in cluster._config_options:
cluster._config_options.__delitem__("memtable_allocation_type")
cluster.populate(1).start()
[node1] = cluster.nodelist()
session = self.patient_cql_connection(node1)
self.create_ks(session, "index_upgrade", 1)
session.execute("CREATE TABLE index_upgrade.table1 (k int PRIMARY KEY, v int)")
session.execute("CREATE INDEX ON index_upgrade.table1(v)")
session.execute("INSERT INTO index_upgrade.table1 (k,v) VALUES (0,0)")
query = "SELECT * FROM index_upgrade.table1 WHERE v=0"
assert_one(session, query, [0, 0])
# Upgrade to the 2.1.x version
node1.drain()
node1.watch_log_for("DRAINED")
node1.stop(wait_other_notice=False)
debug("Upgrading to current version")
self.set_node_to_current_version(node1)
node1.start(wait_other_notice=True)
[node1] = cluster.nodelist()
session = self.patient_cql_connection(node1)
debug(cluster.cassandra_version())
assert_one(session, query, [0, 0])
开发者ID:emolsson,项目名称:cassandra-dtest,代码行数:35,代码来源:secondary_indexes_test.py
示例9: query_new_column_test
def query_new_column_test(self):
"""
Test that a materialized view created with 'SELECT <col1, ...>' works as expected when adding a new column
@expected_result The new column is not present in the view.
"""
session = self.prepare(user_table=True)
session.execute(("CREATE MATERIALIZED VIEW users_by_state2 AS SELECT username FROM users "
"WHERE STATE IS NOT NULL AND USERNAME IS NOT NULL PRIMARY KEY (state, username)"))
self._insert_data(session)
assert_one(
session,
"SELECT * FROM users_by_state2 WHERE state = 'TX' AND username = 'user1'",
['TX', 'user1']
)
session.execute("ALTER TABLE users ADD first_name varchar;")
results = session.execute("SELECT * FROM users_by_state2 WHERE state = 'TX' AND username = 'user1'")
self.assertEqual(len(results), 1)
self.assertFalse(hasattr(results[0], 'first_name'), 'Column "first_name" found in view')
assert_one(
session,
"SELECT * FROM users_by_state2 WHERE state = 'TX' AND username = 'user1'",
['TX', 'user1']
)
开发者ID:emolsson,项目名称:cassandra-dtest,代码行数:29,代码来源:materialized_views_test.py
示例10: drop_column_and_restart_test
def drop_column_and_restart_test(self):
"""
Simply insert data in a table, drop a column involved in the insert and restart the node afterwards.
This ensures that the dropped_columns system table is properly flushed on the alter or the restart
fails as in CASSANDRA-11050.
@jira_ticket CASSANDRA-11050
"""
session = self.prepare()
session.execute("USE ks")
session.execute("CREATE TABLE t (k int PRIMARY KEY, c1 int, c2 int)")
session.execute("INSERT INTO t (k, c1, c2) VALUES (0, 0, 0)")
session.execute("ALTER TABLE t DROP c2")
assert_one(session, "SELECT * FROM t", [0, 0])
self.cluster.stop()
self.cluster.start()
session = self.patient_cql_connection(self.cluster.nodelist()[0])
session.execute("USE ks")
assert_one(session, "SELECT * FROM t", [0, 0])
开发者ID:alipourm,项目名称:cassandra-dtest,代码行数:25,代码来源:schema_test.py
示例11: multiple_repair_test
def multiple_repair_test(self):
cluster = self.cluster
cluster.populate(3).start()
node1, node2, node3 = cluster.nodelist()
session = self.patient_cql_connection(node1)
self.create_ks(session, 'ks', 3)
self.create_cf(session, 'cf', read_repair=0.0, columns={'c1': 'text', 'c2': 'text'})
debug("insert data")
insert_c1c2(session, keys=range(1, 50), consistency=ConsistencyLevel.ALL)
node1.flush()
debug("bringing down node 3")
node3.flush()
node3.stop(gently=False)
debug("inserting additional data into node 1 and 2")
insert_c1c2(session, keys=range(50, 100), consistency=ConsistencyLevel.TWO)
node1.flush()
node2.flush()
debug("restarting and repairing node 3")
node3.start(wait_for_binary_proto=True)
if cluster.version() >= "2.2":
node3.repair()
else:
node3.nodetool("repair -par -inc")
# wait stream handlers to be closed on windows
# after session is finished (See CASSANDRA-10644)
if is_win:
time.sleep(2)
debug("stopping node 2")
node2.stop(gently=False)
debug("inserting data in nodes 1 and 3")
insert_c1c2(session, keys=range(100, 150), consistency=ConsistencyLevel.TWO)
node1.flush()
node3.flush()
debug("start and repair node 2")
node2.start(wait_for_binary_proto=True)
if cluster.version() >= "2.2":
node2.repair()
else:
node2.nodetool("repair -par -inc")
debug("replace node and check data integrity")
node3.stop(gently=False)
node5 = Node('node5', cluster, True, ('127.0.0.5', 9160), ('127.0.0.5', 7000), '7500', '0', None, ('127.0.0.5', 9042))
cluster.add(node5, False)
node5.start(replace_address='127.0.0.3', wait_other_notice=True)
assert_one(session, "SELECT COUNT(*) FROM ks.cf LIMIT 200", [149])
开发者ID:WorksApplications,项目名称:cassandra-dtest,代码行数:59,代码来源:incremental_repair_test.py
示例12: multiple_repair_test
def multiple_repair_test(self):
cluster = self.cluster
cluster.populate(3).start()
[node1, node2, node3] = cluster.nodelist()
cursor = self.patient_cql_connection(node1)
self.create_ks(cursor, 'ks', 3)
self.create_cf(cursor, 'cf', read_repair=0.0, columns={'c1': 'text', 'c2': 'text'})
debug("insert data")
for x in range(1, 50):
insert_c1c2(cursor, x, ConsistencyLevel.ALL)
node1.flush()
debug("bringing down node 3")
node3.flush()
node3.stop(gently=False)
debug("inserting additional data into node 1 and 2")
for y in range(50, 100):
insert_c1c2(cursor, y, ConsistencyLevel.TWO)
node1.flush()
node2.flush()
debug("restarting and repairing node 3")
node3.start()
if cluster.version() >= "3.0":
node3.repair()
else:
node3.nodetool("repair -par -inc")
debug("stopping node 2")
node2.stop(gently=False)
debug("inserting data in nodes 1 and 3")
for z in range(100, 150):
insert_c1c2(cursor, z, ConsistencyLevel.TWO)
node1.flush()
node3.flush()
debug("start and repair node 2")
node2.start()
if cluster.version() >= "3.0":
node2.repair()
else:
node2.nodetool("repair -par -inc")
debug("replace node and check data integrity")
node3.stop(gently=False)
node5 = Node('node5', cluster, True, ('127.0.0.5', 9160), ('127.0.0.5', 7000), '7500', '0', None, ('127.0.0.5',9042))
cluster.add(node5, False)
node5.start(replace_address = '127.0.0.3', wait_other_notice=True)
assert_one(cursor, "SELECT COUNT(*) FROM ks.cf LIMIT 200", [149])
开发者ID:slivne,项目名称:cassandra-dtest,代码行数:57,代码来源:incremental_repair_test.py
示例13: interrupt_build_process_test
def interrupt_build_process_test(self):
"""Test that an interupted MV build process is resumed as it should"""
session = self.prepare(options={'hinted_handoff_enabled': False})
node1, node2, node3 = self.cluster.nodelist()
session.execute("CREATE TABLE t (id int PRIMARY KEY, v int, v2 text, v3 decimal)")
debug("Inserting initial data")
for i in xrange(10000):
session.execute(
"INSERT INTO t (id, v, v2, v3) VALUES ({v}, {v}, 'a', 3.0) IF NOT EXISTS".format(v=i)
)
debug("Create a MV")
session.execute(("CREATE MATERIALIZED VIEW t_by_v AS SELECT * FROM t "
"WHERE v IS NOT NULL AND id IS NOT NULL PRIMARY KEY (v, id)"))
debug("Stop the cluster. Interrupt the MV build process.")
self.cluster.stop()
debug("Restart the cluster")
self.cluster.start(wait_for_binary_proto=True)
session = self.patient_cql_connection(node1)
session.execute("USE ks")
debug("MV shouldn't be built yet.")
assert_none(session, "SELECT * FROM t_by_v WHERE v=10000;")
debug("Wait and ensure the MV build resumed. Waiting up to 2 minutes.")
start = time.time()
while True:
try:
result = session.execute("SELECT count(*) FROM t_by_v;")
self.assertNotEqual(result[0].count, 10000)
except AssertionError:
debug("MV build process is finished")
break
elapsed = (time.time() - start) / 60
if elapsed > 2:
break
time.sleep(5)
debug("Verify all data")
result = session.execute("SELECT count(*) FROM t_by_v;")
self.assertEqual(result[0].count, 10000)
for i in xrange(10000):
assert_one(
session,
"SELECT * FROM t_by_v WHERE v = {}".format(i),
[i, i, 'a', 3.0],
cl=ConsistencyLevel.ALL
)
开发者ID:emolsson,项目名称:cassandra-dtest,代码行数:55,代码来源:materialized_views_test.py
示例14: simple_repair_test
def simple_repair_test(self):
"""
Test that a materialized view are consistent after a simple repair.
"""
session = self.prepare(rf=3, options={'hinted_handoff_enabled': False})
node1, node2, node3 = self.cluster.nodelist()
session.execute("CREATE TABLE t (id int PRIMARY KEY, v int, v2 text, v3 decimal)")
session.execute(("CREATE MATERIALIZED VIEW t_by_v AS SELECT * FROM t "
"WHERE v IS NOT NULL AND id IS NOT NULL PRIMARY KEY (v, id)"))
session.cluster.control_connection.wait_for_schema_agreement()
debug('Shutdown node2')
node2.stop(wait_other_notice=True)
for i in xrange(1000):
session.execute("INSERT INTO t (id, v, v2, v3) VALUES ({v}, {v}, 'a', 3.0)".format(v=i))
self._replay_batchlogs()
debug('Verify the data in the MV with CL=ONE')
for i in xrange(1000):
assert_one(
session,
"SELECT * FROM t_by_v WHERE v = {}".format(i),
[i, i, 'a', 3.0]
)
debug('Verify the data in the MV with CL=ALL. All should be unavailable.')
for i in xrange(1000):
statement = SimpleStatement(
"SELECT * FROM t_by_v WHERE v = {}".format(i),
consistency_level=ConsistencyLevel.ALL
)
assert_unavailable(
session.execute,
statement
)
debug('Start node2, and repair')
node2.start(wait_other_notice=True, wait_for_binary_proto=True)
node1.repair()
debug('Verify the data in the MV with CL=ONE. All should be available now.')
for i in xrange(1000):
assert_one(
session,
"SELECT * FROM t_by_v WHERE v = {}".format(i),
[i, i, 'a', 3.0],
cl=ConsistencyLevel.ONE
)
开发者ID:emolsson,项目名称:cassandra-dtest,代码行数:54,代码来源:materialized_views_test.py
示例15: default_aggregate_test
def default_aggregate_test(self):
session = self.prepare()
session.execute("create table nums (key int primary key, val double);")
for x in range(1, 10):
session.execute("INSERT INTO nums (key, val) VALUES (%d, %d)" % (x, float(x)))
assert_one(session, "SELECT min(key) FROM nums", [1])
assert_one(session, "SELECT max(val) FROM nums", [9.0])
assert_one(session, "SELECT sum(key) FROM nums", [45])
assert_one(session, "SELECT avg(val) FROM nums", [5.0])
assert_one(session, "SELECT count(*) FROM nums", [9])
开发者ID:lvsanche,项目名称:cassandra-dtest,代码行数:12,代码来源:user_functions_test.py
示例16: assert_bootstrap_state
def assert_bootstrap_state(tester, node, expected_bootstrap_state):
"""
Assert that a node is on a given bootstrap state
@param tester The dtest.Tester object to fetch the exclusive connection to the node
@param node The node to check bootstrap state
@param expected_bootstrap_state Bootstrap state to expect
Examples:
assert_bootstrap_state(self, node3, 'COMPLETED')
"""
session = tester.patient_exclusive_cql_connection(node)
assert_one(session, "SELECT bootstrapped FROM system.local WHERE key='local'", [expected_bootstrap_state])
开发者ID:alipourm,项目名称:cassandra-dtest,代码行数:12,代码来源:bootstrap_test.py
示例17: drop_column_queries_test
def drop_column_queries_test(self):
session = self.prepare()
session.execute("USE ks")
session.execute("CREATE TABLE cf (key int PRIMARY KEY, c1 int, c2 int)")
session.execute("CREATE INDEX ON cf(c2)")
# insert some data.
session.execute("INSERT INTO cf (key, c1, c2) VALUES (0, 1, 2)")
session.execute("INSERT INTO cf (key, c1, c2) VALUES (1, 2, 3)")
session.execute("INSERT INTO cf (key, c1, c2) VALUES (2, 3, 4)")
# drop and readd c1.
session.execute("ALTER TABLE cf DROP c1")
session.execute("ALTER TABLE cf ADD c1 int")
# add another row.
session.execute("INSERT INTO cf (key, c1, c2) VALUES (3, 4, 5)")
# test that old (pre-drop) c1 values aren't returned and new ones are.
assert_all(session, "SELECT c1 FROM cf", [[None], [None], [None], [4]], ignore_order=True)
assert_all(session, "SELECT * FROM cf", [[0, None, 2], [1, None, 3], [2, None, 4], [3, 4, 5]], ignore_order=True)
assert_one(session, "SELECT c1 FROM cf WHERE key = 0", [None])
assert_one(session, "SELECT c1 FROM cf WHERE key = 3", [4])
assert_one(session, "SELECT * FROM cf WHERE c2 = 2", [0, None, 2])
assert_one(session, "SELECT * FROM cf WHERE c2 = 5", [3, 4, 5])
开发者ID:alipourm,项目名称:cassandra-dtest,代码行数:31,代码来源:schema_test.py
示例18: multi_table_batch_for_10554_test
def multi_table_batch_for_10554_test(self):
""" Test a batch on 2 tables having different columns, restarting the node afterwards, to reproduce CASSANDRA-10554 """
session = self.prepare()
# prepare() adds users and clicks but clicks is a counter table, so adding a random other table for this test.
session.execute("""
CREATE TABLE dogs (
dogid int PRIMARY KEY,
dogname text,
);
""")
session.execute("""
BEGIN BATCH
INSERT INTO users (id, firstname, lastname) VALUES (0, 'Jack', 'Sparrow')
INSERT INTO dogs (dogid, dogname) VALUES (0, 'Pluto')
APPLY BATCH
""")
assert_one(session, "SELECT * FROM users", [0, 'Jack', 'Sparrow'])
assert_one(session, "SELECT * FROM dogs", [0, 'Pluto'])
# Flush and restart the node as it's how 10554 reproduces
node1 = self.cluster.nodelist()[0]
node1.flush()
node1.stop()
node1.start(wait_for_binary_proto=True)
session = self.patient_cql_connection(node1, keyspace='ks')
assert_one(session, "SELECT * FROM users", [0, 'Jack', 'Sparrow'])
assert_one(session, "SELECT * FROM dogs", [0, 'Pluto'])
开发者ID:alipourm,项目名称:cassandra-dtest,代码行数:33,代码来源:batch_test.py
示例19: conditional_updates_on_static_columns_with_null_values_batch_test
def conditional_updates_on_static_columns_with_null_values_batch_test(self):
session = self.prepare(3)
table_name = "lwt_on_static_columns_with_null_batch"
session.execute("""
CREATE TABLE {table_name} (a int, b int, s int static, d text, PRIMARY KEY (a, b))
""".format(table_name=table_name))
for i in range(1, 7):
session.execute("INSERT INTO {table_name} (a, b) VALUES ({i}, {i})".format(table_name=table_name, i=i))
self._validate_non_existing_or_null_values_batch(table_name, session)
for operator in [">", "<", ">=", "<=", "="]:
assert_one(session, """
BEGIN BATCH
INSERT INTO {table_name} (a, b, s, d) values (3, 3, 40, 'a')
UPDATE {table_name} SET s = 30 WHERE a = 3 IF s {operator} 5;
APPLY BATCH""".format(table_name=table_name, operator=operator), [False])
assert_one(session, "SELECT * FROM {table_name} WHERE a = 3".format(table_name=table_name), [3, 3, None, None])
assert_one(session, """
BEGIN BATCH
INSERT INTO {table_name} (a, b, s, d) values (6, 6, 70, 'a')
UPDATE {table_name} SET s = 60 WHERE a = 6 IF s IN (1,2,3)
APPLY BATCH""".format(table_name=table_name), [False])
assert_one(session, "SELECT * FROM {table_name} WHERE a = 6".format(table_name=table_name), [6, 6, None, None])
开发者ID:alipourm,项目名称:cassandra-dtest,代码行数:29,代码来源:cql_tests.py
示例20: ignore_failure_policy_test
def ignore_failure_policy_test(self):
"""
Test the ignore commitlog failure policy
"""
self.prepare(configuration={
'commit_failure_policy': 'ignore'
})
self._provoke_commitlog_failure()
failure = self.node1.grep_log("ERROR \[COMMIT-LOG-ALLOCATOR\].+Failed .+ commit log segments")
self.assertTrue(failure, "Cannot find the commitlog failure message in logs")
self.assertTrue(self.node1.is_running(), "Node1 should still be running")
# on Windows, we can't delete the segments if they're chmod to 0 so they'll still be available for use by CLSM,
# and we can still create new segments since os.chmod is limited to stat.S_IWRITE and stat.S_IREAD to set files
# as read-only. New mutations will still be allocated and WriteTimeouts will not be raised. It's sufficient that
# we confirm that a) the node isn't dead (stop) and b) the node doesn't terminate the thread (stop_commit)
query = "INSERT INTO test (key, col1) VALUES (2, 2);"
if is_win():
# We expect this to succeed
self.session1.execute(query)
self.assertFalse(self.node1.grep_log("terminating thread"), "thread was terminated but CL error should have been ignored.")
self.assertTrue(self.node1.is_running(), "Node1 should still be running after an ignore error on CL")
else:
with self.assertRaises((OperationTimedOut, WriteTimeout)):
self.session1.execute(query)
# Should not exist
assert_none(self.session1, "SELECT * FROM test where key=2;")
# bring back the node commitlogs
self._change_commitlog_perms(stat.S_IWRITE | stat.S_IREAD | stat.S_IEXEC)
self.session1.execute("""
INSERT INTO test (key, col1) VALUES (3, 3);
""")
assert_one(
self.session1,
"SELECT * FROM test where key=3;",
[3, 3]
)
time.sleep(2)
assert_one(
self.session1,
"SELECT * FROM test where key=2;",
[2, 2]
)
开发者ID:c-kodman,项目名称:cassandra-dtest,代码行数:48,代码来源:commitlog_test.py
注:本文中的assertions.assert_one函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论