77import time
88import threading
99import boto3
10- < << << << HEAD
11- == == == =
1210import os
1311import urllib .request
14- > >> >> >> ca15ae9 (Add test to reproduce connection errors )
1512from datetime import datetime
1613from cassandra .cluster import Cluster
1714from cassandra_sigv4 .auth import SigV4AuthProvider
@@ -43,9 +40,6 @@ def create_short_lived_session(role_arn, region, role_session_duration=900):
4340 region_name = region
4441 )
4542
46- < << << << HEAD
47- def worker_thread (thread_id , session , endpoint , role_session_duration , results ):
48- == == == =
4943def download_starfield_certificate ():
5044 """Download the Starfield certificate at runtime."""
5145 cert_url = "https://certs.secureserver.net/repository/sf-class2-root.crt"
@@ -59,7 +53,6 @@ def download_starfield_certificate():
5953 return cert_file
6054
6155def worker_thread (thread_id , session , endpoint , role_session_duration , results , cert_file ):
62- > >> >> >> ca15ae9 (Add test to reproduce connection errors )
6356 """Worker thread that connects and queries Keyspaces."""
6457 print (f"[{ datetime .now ()} ] Thread { thread_id } : Starting" )
6558
@@ -69,11 +62,7 @@ def worker_thread(thread_id, session, endpoint, role_session_duration, results,
6962
7063 # Create SSL context
7164 ssl_context = ssl .SSLContext (ssl .PROTOCOL_TLSv1_2 )
72- << << << < HEAD
73- ssl_context .load_verify_locations ('sf-class2-root.crt' )
74- == == == =
7565 ssl_context .load_verify_locations (cert_file )
76- >> >> >> > ca15ae9 (Add test to reproduce connection errors )
7766 ssl_context .verify_mode = ssl .CERT_REQUIRED
7867
7968 # Create cluster
@@ -240,8 +229,6 @@ def run_multithreaded_test(region, endpoint, account_id, role_name, num_threads=
240229 return True
241230
242231if __name__ == "__main__" :
243- < << << << HEAD
244- == == == =
245232 # Create .gitignore if it doesn't exist to ensure cert files aren't committed
246233 gitignore_path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), ".gitignore" )
247234 if not os .path .exists (gitignore_path ):
@@ -265,33 +252,5 @@ def run_multithreaded_test(region, endpoint, account_id, role_name, num_threads=
265252
266253 args = parser .parse_args ()
267254
268- success = run_multithreaded_test (args .region , args .endpoint , args .account_id , args .role_name , args .threads , args .duration )
269- sys .exit (0 if success else 1 )
270-
271- if __name__ == "__main__" :
272- # Create .gitignore if it doesn't exist to ensure cert files aren't committed
273- gitignore_path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), ".gitignore" )
274- if not os .path .exists (gitignore_path ):
275- with open (gitignore_path , "w" ) as f :
276- f .write ("# Ignore certificate files\n *.crt\n *.crt.temp\n " )
277- else :
278- # Ensure certificate patterns are in .gitignore
279- with open (gitignore_path , "r" ) as f :
280- content = f .read ()
281- if "*.crt" not in content :
282- with open (gitignore_path , "a" ) as f :
283- f .write ("\n # Ignore certificate files\n *.crt\n *.crt.temp\n " )
284-
285- > >> >> >> ca15ae9 (Add test to reproduce connection errors )
286- parser = argparse .ArgumentParser (description = "Multi-threaded test for SigV4 signature errors" )
287- parser .add_argument ("--region" , required = True , help = "AWS region" )
288- parser .add_argument ("--endpoint" , required = True , help = "Keyspaces endpoint" )
289- parser .add_argument ("--account-id" , required = True , help = "AWS account ID for the role" )
290- parser .add_argument ("--role-name" , required = True , help = "IAM role name to assume" )
291- parser .add_argument ("--threads" , type = int , default = 5 , help = "Number of threads" )
292- parser .add_argument ("--duration" , type = int , default = 10 , help = "Test duration in minutes" )
293-
294- args = parser .parse_args ()
295-
296255 success = run_multithreaded_test (args .region , args .endpoint , args .account_id , args .role_name , args .threads , args .duration )
297256 sys .exit (0 if success else 1 )
0 commit comments