File tree 3 files changed +49
-0
lines changed
examples/test/multithreaded
3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """Stub module indicator to make linter configuration simpler."""
Original file line number Diff line number Diff line change
1
+ # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """Test suite for the Raw AES keyring example with multi-threading."""
4
+ from concurrent .futures import ThreadPoolExecutor , as_completed
5
+ import pytest
6
+
7
+ from ...src .raw_aes_keyring_example import encrypt_and_decrypt_with_keyring
8
+
9
+ pytestmark = [pytest .mark .examples ]
10
+
11
+
12
+ def test_encrypt_and_decrypt_with_keyring (n_threads = 10 ):
13
+ """Test function for multi-threaded encrypt and decrypt using the Raw AES Keyring example."""
14
+ with ThreadPoolExecutor (max_workers = n_threads ) as executor :
15
+ thread_futures = {executor .submit (encrypt_and_decrypt_with_keyring ): i for i in range (n_threads )}
16
+
17
+ for future in as_completed (thread_futures ):
18
+ thread_id = thread_futures [future ]
19
+ try :
20
+ result = future .result ()
21
+ print (f"Thread { thread_id } passed with result: { result } " )
22
+ except Exception as e :
23
+ raise e
Original file line number Diff line number Diff line change
1
+ # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """Test suite for the Raw RSA keyring example with multi-threading."""
4
+ from concurrent .futures import ThreadPoolExecutor , as_completed
5
+ import pytest
6
+
7
+ from ...src .raw_rsa_keyring_example import encrypt_and_decrypt_with_keyring
8
+
9
+ pytestmark = [pytest .mark .examples ]
10
+
11
+
12
+ def test_encrypt_and_decrypt_with_keyring (n_threads = 10 ):
13
+ """Test function for multi-threaded encrypt and decrypt using the Raw RSA Keyring example."""
14
+ with ThreadPoolExecutor (max_workers = n_threads ) as executor :
15
+ thread_futures = {executor .submit (encrypt_and_decrypt_with_keyring ): i for i in range (n_threads )}
16
+
17
+ for future in as_completed (thread_futures ):
18
+ thread_id = thread_futures [future ]
19
+ try :
20
+ result = future .result ()
21
+ print (f"Thread { thread_id } passed with result: { result } " )
22
+ except Exception as e :
23
+ raise e
You can’t perform that action at this time.
0 commit comments