@@ -41,7 +41,6 @@ def make_query_plan(self, working_keyspace=None, query=None):
4141
4242
4343# This doesn't work well with Windows clock granularity
44- @notwindows
4544@requiressimulacron
4645class SpecExecTest (unittest .TestCase ):
4746
@@ -54,10 +53,16 @@ def setUpClass(cls):
5453 cls .cluster = Cluster (protocol_version = PROTOCOL_VERSION , compression = False )
5554 cls .session = cls .cluster .connect (wait_for_all_pools = True )
5655
57- spec_ep_brr = ExecutionProfile (load_balancing_policy = BadRoundRobinPolicy (), speculative_execution_policy = ConstantSpeculativeExecutionPolicy (.01 , 20 ))
58- spec_ep_rr = ExecutionProfile (speculative_execution_policy = ConstantSpeculativeExecutionPolicy (.01 , 20 ))
59- spec_ep_rr_lim = ExecutionProfile (load_balancing_policy = BadRoundRobinPolicy (), speculative_execution_policy = ConstantSpeculativeExecutionPolicy (.01 , 1 ))
60- spec_ep_brr_lim = ExecutionProfile (load_balancing_policy = BadRoundRobinPolicy (), speculative_execution_policy = ConstantSpeculativeExecutionPolicy (0.4 , 10 ))
56+ spec_ep_brr = ExecutionProfile (load_balancing_policy = BadRoundRobinPolicy (),
57+ speculative_execution_policy = ConstantSpeculativeExecutionPolicy (1 , 6 ),
58+ request_timeout = 12 )
59+ spec_ep_rr = ExecutionProfile (speculative_execution_policy = ConstantSpeculativeExecutionPolicy (.5 , 10 ),
60+ request_timeout = 12 )
61+ spec_ep_rr_lim = ExecutionProfile (load_balancing_policy = BadRoundRobinPolicy (),
62+ speculative_execution_policy = ConstantSpeculativeExecutionPolicy (0.5 , 1 ),
63+ request_timeout = 12 )
64+ spec_ep_brr_lim = ExecutionProfile (load_balancing_policy = BadRoundRobinPolicy (),
65+ speculative_execution_policy = ConstantSpeculativeExecutionPolicy (4 , 10 ))
6166
6267 cls .cluster .add_execution_profile ("spec_ep_brr" , spec_ep_brr )
6368 cls .cluster .add_execution_profile ("spec_ep_rr" , spec_ep_rr )
@@ -88,14 +93,14 @@ def test_speculative_execution(self):
8893 @test_category metadata
8994 """
9095 query_to_prime = "INSERT INTO test3rf.test (k, v) VALUES (0, 1);"
91- prime_query (query_to_prime , then = {"delay_in_ms" : 4000 })
96+ prime_query (query_to_prime , then = {"delay_in_ms" : 10000 })
9297
9398 statement = SimpleStatement (query_to_prime , is_idempotent = True )
9499 statement_non_idem = SimpleStatement (query_to_prime , is_idempotent = False )
95100
96101 # This LBP should repeat hosts up to around 30
97102 result = self .session .execute (statement , execution_profile = 'spec_ep_brr' )
98- self .assertEqual (21 , len (result .response_future .attempted_hosts ))
103+ self .assertEqual (7 , len (result .response_future .attempted_hosts ))
99104
100105 # This LBP should keep host list to 3
101106 result = self .session .execute (statement , execution_profile = 'spec_ep_rr' )
@@ -110,11 +115,11 @@ def test_speculative_execution(self):
110115 self .assertEqual (1 , len (result .response_future .attempted_hosts ))
111116
112117 # Default policy with non_idem query
113- result = self .session .execute (statement_non_idem )
118+ result = self .session .execute (statement_non_idem , timeout = 12 )
114119 self .assertEqual (1 , len (result .response_future .attempted_hosts ))
115120
116121 # Should be able to run an idempotent query against default execution policy with no speculative_execution_policy
117- result = self .session .execute (statement )
122+ result = self .session .execute (statement , timeout = 12 )
118123 self .assertEqual (1 , len (result .response_future .attempted_hosts ))
119124
120125 # Test timeout with spec_ex
@@ -147,17 +152,18 @@ def test_speculative_and_timeout(self):
147152
148153 @test_category metadata
149154 """
150- prime_query ("INSERT INTO test3rf.test (k, v) VALUES (0, 1);" , then = NO_THEN )
155+ query_to_prime = "INSERT INTO testkeyspace.testtable (k, v) VALUES (0, 1);"
156+ prime_query (query_to_prime , then = NO_THEN )
151157
152- statement = SimpleStatement ("INSERT INTO test3rf.test (k, v) VALUES (0, 1);" , is_idempotent = True )
158+ statement = SimpleStatement (query_to_prime , is_idempotent = True )
153159
154160 # An OperationTimedOut is placed here in response_future,
155161 # that's why we can't call session.execute,which would raise it, but
156162 # we have to directly wait for the event
157163 response_future = self .session .execute_async (statement , execution_profile = 'spec_ep_brr_lim' ,
158- timeout = 2.2 )
159- response_future ._event .wait (4 )
164+ timeout = 14 )
165+ response_future ._event .wait (16 )
160166 self .assertIsInstance (response_future ._final_exception , OperationTimedOut )
161167
162- # This is because 2.2 / 0. 4 + 1 = 6
163- self .assertEqual (len (response_future .attempted_hosts ), 6 )
168+ # This is because 14 / 4 + 1 = 4
169+ self .assertEqual (len (response_future .attempted_hosts ), 4 )
0 commit comments