Here are the examples of the python api pytest.mark.vnodes taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
0
View Complete Implementation : counter_test.py
Copyright Apache License 2.0
Author : apache
Copyright Apache License 2.0
Author : apache
@pytest.mark.vnodes
def test_counter_leader_with_partial_view(self):
"""
Test leader election with a starting node.
Testing that nodes do not elect as mutation leader a node with a partial view on the cluster.
Note that byteman rules can be syntax checked via the following command:
sh ./bin/bytemancheck.sh -cp ~/path_to/apache-castandra-3.0.14-SNAPSHOT.jar ~/path_to/rule.btm
@jira_ticket CastANDRA-13043
"""
cluster = self.cluster
cluster.populate(3, use_vnodes=True, install_byteman=True)
nodes = cluster.nodelist()
# Have node 1 and 3 cheat a bit during the leader election for a counter mutation; note that cheating
# takes place iff there is an actual chance for node 2 to be picked.
if cluster.version() < '4.0':
nodes[0].update_startup_byteman_script('./byteman/pre4.0/election_counter_leader_favor_node2.btm')
nodes[2].update_startup_byteman_script('./byteman/pre4.0/election_counter_leader_favor_node2.btm')
else:
nodes[0].update_startup_byteman_script('./byteman/4.0/election_counter_leader_favor_node2.btm')
nodes[2].update_startup_byteman_script('./byteman/4.0/election_counter_leader_favor_node2.btm')
cluster.start(wait_for_binary_proto=True)
session = self.patient_cql_connection(nodes[0])
create_ks(session, 'ks', 3)
create_cf(session, 'cf', validation="CounterColumnType", columns={'c': 'counter'})
# Now stop the node and restart but first install a rule to slow down how fast node 2 will update the list
# nodes that are alive
nodes[1].stop(wait=True, wait_other_notice=False)
nodes[1].update_startup_byteman_script('./byteman/gossip_alive_callback_sleep.btm')
nodes[1].start(no_wait=True, wait_other_notice=False)
# Until node 2 is fully alive try to force other nodes to pick him as mutation leader.
# If CastANDRA-13043 is fixed, they will not. Otherwise they will do, but since we are slowing down how
# fast node 2 updates the list of nodes that are alive, it will just have a partial view on the cluster
# and thus will raise an 'UnavailableException' exception.
nb_attempts = 50000
for i in range(0, nb_attempts):
# Change the name of the counter for the sake of randomization
q = SimpleStatement(
query_string="UPDATE ks.cf SET c = c + 1 WHERE key = 'counter_%d'" % i,
consistency_level=ConsistencyLevel.QUORUM
)
session.execute(q)
0
View Complete Implementation : replace_address_test.py
Copyright Apache License 2.0
Author : apache
Copyright Apache License 2.0
Author : apache
@flaky
@pytest.mark.vnodes
def test_multi_dc_replace_with_rf1(self):
"""
Test that multi-dc replace works when rf=1 on each dc
"""
self._setup(n=[1, 1])
yaml_config = """
# Create the keyspace and table
keyspace: keyspace1
keyspace_definition: |
CREATE KEYSPACE keyspace1 WITH replication = {'clast': 'NetworkTopologyStrategy', 'dc1': 1, 'dc2': 1};
table: users
table_definition:
CREATE TABLE users (
username text,
first_name text,
last_name text,
email text,
PRIMARY KEY(username)
) WITH compaction = {'clast':'SizeTieredCompactionStrategy'};
insert:
parsations: fixed(1)
batchtype: UNLOGGED
queries:
read:
cql: select * from users where username = ?
fields: samerow
"""
with tempfile.NamedTemporaryFile(mode='w+') as stress_config:
stress_config.write(yaml_config)
stress_config.flush()
self.query_node.stress(['user', 'profile=' + stress_config.name, 'n=10k', 'no-warmup',
'ops(insert=1)', '-rate', 'threads=5'])
# need to sleep for a bit to try and let things catch up as we frequently do a lot of
# GC after the stress invocation above causing the next step of the test to timeout.
# and then flush to make sure we really are fully caught up
time.sleep(30)
# Save initial data
table_name = 'keyspace1.users'
initial_data = self._fetch_initial_data(table=table_name, cl=ConsistencyLevel.TWO)
self._stop_node_to_replace(table=table_name)
self._do_replace(data_center='dc2')
astert_bootstrap_state(self, self.replacement_node, 'COMPLETED')
# Check that keyspace was replicated from dc1 to dc2
astert not self.replacement_node.grep_log("Unable to find sufficient sources for streaming range")
self._verify_data(initial_data, table=table_name, cl=ConsistencyLevel.LOCAL_ONE)