From 040f0b51d138cf9347bc84930cf1b38810a0a36b Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 12:55:04 +0530 Subject: [PATCH 01/18] testing api connection error in all version --- .github/workflows/python.yml | 4 ++- test.py | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 test.py diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e3ea46d..ca62327 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -17,7 +17,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10] + python-version: [3, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.12] steps: - uses: actions/checkout@v2 @@ -31,3 +31,5 @@ jobs: python3 setup.py install - name: Run Tests run: python3 -m unittest + - name: Run order Test + run: python3 test.py diff --git a/test.py b/test.py new file mode 100644 index 0000000..bab1138 --- /dev/null +++ b/test.py @@ -0,0 +1,50 @@ +import razorpay +import logging +import http.client as http_client +import time +import random +import os + + +# Enable HTTP debugging +# http_client.HTTPConnection.debuglevel = 1 +# logging.basicConfig() +# logging.getLogger().setLevel(logging.DEBUG) +# requests_log = logging.getLogger("requests.packages.urllib3") +# requests_log.setLevel(logging.DEBUG) +# requests_log.propagate = True + +api_key = os.getenv('RZP_API_KEY') +api_secret = os.getenv('RZP_API_SECRET') + +if not api_key or not api_secret: + raise ValueError("Please set RZP_API_KEY and RZP_API_SECRET environment variables") + +client = razorpay.Client(auth=(api_key, api_secret)) + + +for i in range(15): + try: + x = client.order.create({ + "amount": 50000, + "currency": "INR", + "receipt": f"receipt#{i+1}", + "partial_payment":False, + "notes": { + "key1": "value3", + "key2": "value2" + } + }) + + print(f"Request {i+1}/15 at {time.strftime('%Y-%m-%d %H:%M:%S')}: {x}") + + except Exception as e: + print(f"Error in request {i+1}/15: {e}") + + # Random delay between 1-5 seconds (skip delay after last request) + if i < 14: + delay = random.uniform(1, 5) + print(f"Waiting {delay:.1f} seconds...") + time.sleep(delay) + +print("Completed all 15 requests!") From 2c213bece0d6f19fca215725ac189571eb90ec2e Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:03:16 +0530 Subject: [PATCH 02/18] testing api connection error in all version --- .github/workflows/python.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index ca62327..4427089 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -32,4 +32,7 @@ jobs: - name: Run Tests run: python3 -m unittest - name: Run order Test + env: + RZP_API_KEY: ${{ secrets.RZP_API_KEY }} + RZP_API_SECRET: ${{ secrets.RZP_API_SECRET }} run: python3 test.py From 47ee7d622d1f7a961257d9e5d8aae29bac7e19cc Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:15:30 +0530 Subject: [PATCH 03/18] update python.yml --- .github/workflows/python.yml | 2 +- order_connect.py | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 order_connect.py diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 4427089..238a497 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -35,4 +35,4 @@ jobs: env: RZP_API_KEY: ${{ secrets.RZP_API_KEY }} RZP_API_SECRET: ${{ secrets.RZP_API_SECRET }} - run: python3 test.py + run: python3 order_connect.py diff --git a/order_connect.py b/order_connect.py new file mode 100644 index 0000000..bab1138 --- /dev/null +++ b/order_connect.py @@ -0,0 +1,50 @@ +import razorpay +import logging +import http.client as http_client +import time +import random +import os + + +# Enable HTTP debugging +# http_client.HTTPConnection.debuglevel = 1 +# logging.basicConfig() +# logging.getLogger().setLevel(logging.DEBUG) +# requests_log = logging.getLogger("requests.packages.urllib3") +# requests_log.setLevel(logging.DEBUG) +# requests_log.propagate = True + +api_key = os.getenv('RZP_API_KEY') +api_secret = os.getenv('RZP_API_SECRET') + +if not api_key or not api_secret: + raise ValueError("Please set RZP_API_KEY and RZP_API_SECRET environment variables") + +client = razorpay.Client(auth=(api_key, api_secret)) + + +for i in range(15): + try: + x = client.order.create({ + "amount": 50000, + "currency": "INR", + "receipt": f"receipt#{i+1}", + "partial_payment":False, + "notes": { + "key1": "value3", + "key2": "value2" + } + }) + + print(f"Request {i+1}/15 at {time.strftime('%Y-%m-%d %H:%M:%S')}: {x}") + + except Exception as e: + print(f"Error in request {i+1}/15: {e}") + + # Random delay between 1-5 seconds (skip delay after last request) + if i < 14: + delay = random.uniform(1, 5) + print(f"Waiting {delay:.1f} seconds...") + time.sleep(delay) + +print("Completed all 15 requests!") From cecfd5967150cb3e7aae8cd9872e3e4fa08143bc Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:19:14 +0530 Subject: [PATCH 04/18] delete test.py --- test.py | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 test.py diff --git a/test.py b/test.py deleted file mode 100644 index bab1138..0000000 --- a/test.py +++ /dev/null @@ -1,50 +0,0 @@ -import razorpay -import logging -import http.client as http_client -import time -import random -import os - - -# Enable HTTP debugging -# http_client.HTTPConnection.debuglevel = 1 -# logging.basicConfig() -# logging.getLogger().setLevel(logging.DEBUG) -# requests_log = logging.getLogger("requests.packages.urllib3") -# requests_log.setLevel(logging.DEBUG) -# requests_log.propagate = True - -api_key = os.getenv('RZP_API_KEY') -api_secret = os.getenv('RZP_API_SECRET') - -if not api_key or not api_secret: - raise ValueError("Please set RZP_API_KEY and RZP_API_SECRET environment variables") - -client = razorpay.Client(auth=(api_key, api_secret)) - - -for i in range(15): - try: - x = client.order.create({ - "amount": 50000, - "currency": "INR", - "receipt": f"receipt#{i+1}", - "partial_payment":False, - "notes": { - "key1": "value3", - "key2": "value2" - } - }) - - print(f"Request {i+1}/15 at {time.strftime('%Y-%m-%d %H:%M:%S')}: {x}") - - except Exception as e: - print(f"Error in request {i+1}/15: {e}") - - # Random delay between 1-5 seconds (skip delay after last request) - if i < 14: - delay = random.uniform(1, 5) - print(f"Waiting {delay:.1f} seconds...") - time.sleep(delay) - -print("Completed all 15 requests!") From 09e3ba577b7dde6c83d876b1e7acd23c63090736 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:28:55 +0530 Subject: [PATCH 05/18] added python version --- .github/workflows/python.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 238a497..0db1af8 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -31,6 +31,8 @@ jobs: python3 setup.py install - name: Run Tests run: python3 -m unittest + - name: Print Python Version + run: python3 --version - name: Run order Test env: RZP_API_KEY: ${{ secrets.RZP_API_KEY }} From 3e765762ae384bb457239ed842389b98fd2877cb Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:32:54 +0530 Subject: [PATCH 06/18] remove v3 --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 0db1af8..8ce831b 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -17,7 +17,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.12] + python-version: [3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.12] steps: - uses: actions/checkout@v2 From e992ecab4c4bd086e3d72dd6dbb5a4f0492fb148 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:37:31 +0530 Subject: [PATCH 07/18] specify versions --- .github/workflows/python.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 8ce831b..b790055 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -23,6 +23,8 @@ jobs: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} - name: Install dependencies run: | pip install setuptools From 897036d23c3431ce012cf2d92619952a04f30018 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:40:35 +0530 Subject: [PATCH 08/18] specify versions --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index b790055..81dbbba 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -17,7 +17,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.12] + python-version: [3.5.10, 3.6.15, 3.7.*, 3.8.*, 3.9.*, 3.10.*, 3.12.*] steps: - uses: actions/checkout@v2 From 47e72057e1c6296873520d2a0dde50852b777bab Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:41:28 +0530 Subject: [PATCH 09/18] specify versions --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 81dbbba..7a14948 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -17,7 +17,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.5.10, 3.6.15, 3.7.*, 3.8.*, 3.9.*, 3.10.*, 3.12.*] + python-version: [3.5.*, 3.6.*, 3.7.*, 3.8.*, 3.9.*, 3.10.*, 3.12.*] steps: - uses: actions/checkout@v2 From 1c3bea0fb5254c2f09b94156a53316abfe2ff11b Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:45:32 +0530 Subject: [PATCH 10/18] updated dependency --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7a14948..81794db 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -20,9 +20,9 @@ jobs: python-version: [3.5.*, 3.6.*, 3.7.*, 3.8.*, 3.9.*, 3.10.*, 3.12.*] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies From ac94188d461f450e15d5649e237014b7067d05d1 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:51:44 +0530 Subject: [PATCH 11/18] updated dependency --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 81794db..7cce9c4 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -17,7 +17,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.5.*, 3.6.*, 3.7.*, 3.8.*, 3.9.*, 3.10.*, 3.12.*] + python-version: [3.5.10, 3.6.15, 3.7.17, 3.8.18, 3.9.23, 3.10.18, 3.12.11] steps: - uses: actions/checkout@v4 From 46bd05c4bfcc1359fe8ede62e97602c51c93b7bc Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 13:56:04 +0530 Subject: [PATCH 12/18] updated dependency --- .github/workflows/python.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7cce9c4..ed102f6 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -14,17 +14,12 @@ on: jobs: deploy: runs-on: ubuntu-latest # nosemgrep : semgrep.dev/s/swati31196:github_provided_runner - strategy: - max-parallel: 4 - matrix: - python-version: [3.5.10, 3.6.15, 3.7.17, 3.8.18, 3.9.23, 3.10.18, 3.12.11] - steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: "3.12.11" - name: Install dependencies run: | pip install setuptools From a4c571345aecbbdf83e7abe5d4d7b38410421a49 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Sat, 26 Jul 2025 14:01:02 +0530 Subject: [PATCH 13/18] updated dependency --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index ed102f6..e67d598 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.12.11" + python-version: "3.12.0" - name: Install dependencies run: | pip install setuptools From ba753bf32acc6c9637eec1e16745716580b59526 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Mon, 4 Aug 2025 11:28:27 +0530 Subject: [PATCH 14/18] parallel calls test --- .github/workflows/python.yml | 2 +- run_parallel_orders.sh | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100755 run_parallel_orders.sh diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e67d598..d693be4 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -34,4 +34,4 @@ jobs: env: RZP_API_KEY: ${{ secrets.RZP_API_KEY }} RZP_API_SECRET: ${{ secrets.RZP_API_SECRET }} - run: python3 order_connect.py + run: bash run_parallel_orders.sh diff --git a/run_parallel_orders.sh b/run_parallel_orders.sh new file mode 100755 index 0000000..c74fcc1 --- /dev/null +++ b/run_parallel_orders.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Create logs directory if it doesn't exist +mkdir -p logs + +# Clear any existing log files +rm -f logs/order_*.log + +echo "Starting 10 parallel instances of order_connect.py..." +echo "Logs will be saved in the 'logs' folder" +echo "================================================" + +# Array to store process IDs +pids=() + +# Start 10 parallel processes +for i in {1..10}; do + echo "Starting instance $i..." + python3 order_connect.py > logs/order_instance_$i.log 2>&1 & + pids+=($!) +done + +echo "All 10 instances started. PIDs: ${pids[@]}" +echo "Waiting for all processes to complete..." + +# Wait for all background processes to complete +for pid in "${pids[@]}"; do + wait $pid + echo "Process $pid completed" +done + +echo "================================================" +echo "All instances completed!" +echo "Check the logs folder for individual instance outputs:" +ls -la logs/ + +# Optional: Create a summary log +echo "Creating summary log..." +echo "Summary of all parallel order creation attempts" > logs/summary.log +echo "Generated at: $(date)" >> logs/summary.log +echo "================================================" >> logs/summary.log + +for i in {1..10}; do + echo "" >> logs/summary.log + echo "=== Instance $i ===" >> logs/summary.log + if [ -f "logs/order_instance_$i.log" ]; then + cat logs/order_instance_$i.log >> logs/summary.log + else + echo "Log file not found for instance $i" >> logs/summary.log + fi +done + +echo "Summary log created at logs/summary.log" +echo "Individual logs available at logs/order_instance_[1-10].log" + +# Display summary log content in terminal +echo "" +echo "================================================" +echo "SUMMARY LOG CONTENT:" +echo "================================================" +cat logs/summary.log \ No newline at end of file From 03ea440d31b771441edb2e04842bc9cfecd4305e Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Tue, 5 Aug 2025 11:34:25 +0530 Subject: [PATCH 15/18] check new changes --- razorpay/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/razorpay/client.py b/razorpay/client.py index ea6cf08..ade4d41 100644 --- a/razorpay/client.py +++ b/razorpay/client.py @@ -1,9 +1,9 @@ import os import json import requests -import pkg_resources +import importlib.metadata -from pkg_resources import DistributionNotFound +from importlib.metadata import PackageNotFoundError from types import ModuleType @@ -84,7 +84,7 @@ def _update_user_agent_header(self, options): def _get_version(self): version = "" try: # nosemgrep : gitlab.bandit.B110 - version = pkg_resources.require("razorpay")[0].version + version = importlib.metadata.version("razorpay") except DistributionNotFound: # pragma: no cover pass return version From 16e6146fa3b0ff5d0a7bb3fd75e922e954e81680 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Tue, 5 Aug 2025 11:58:19 +0530 Subject: [PATCH 16/18] added backward compatiblity for get version --- razorpay/client.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/razorpay/client.py b/razorpay/client.py index ade4d41..9993717 100644 --- a/razorpay/client.py +++ b/razorpay/client.py @@ -84,8 +84,20 @@ def _update_user_agent_header(self, options): def _get_version(self): version = "" try: # nosemgrep : gitlab.bandit.B110 - version = importlib.metadata.version("razorpay") - except DistributionNotFound: # pragma: no cover + # Try importlib.metadata first (modern approach) + try: + import importlib.metadata + from importlib.metadata import PackageNotFoundError + version = importlib.metadata.version("razorpay") + except ImportError: + # Fall back to pkg_resources + import pkg_resources + from pkg_resources import DistributionNotFound + version = pkg_resources.require("razorpay")[0].version + except (PackageNotFoundError, DistributionNotFound, NameError): # pragma: no cover + # PackageNotFoundError: importlib.metadata couldn't find the package + # DistributionNotFound: pkg_resources couldn't find the package + # NameError: in case the exception classes aren't defined due to import issues pass return version From 4a1aee7c3909c782bbe100a9c03c5f79e8def12f Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Thu, 7 Aug 2025 09:44:44 +0530 Subject: [PATCH 17/18] changed payment api --- order_connect.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/order_connect.py b/order_connect.py index bab1138..f2bc0c3 100644 --- a/order_connect.py +++ b/order_connect.py @@ -25,16 +25,7 @@ for i in range(15): try: - x = client.order.create({ - "amount": 50000, - "currency": "INR", - "receipt": f"receipt#{i+1}", - "partial_payment":False, - "notes": { - "key1": "value3", - "key2": "value2" - } - }) + x = client.payment.fetch("pay_R2IbWHkb3nGCa9") print(f"Request {i+1}/15 at {time.strftime('%Y-%m-%d %H:%M:%S')}: {x}") From a42fa11ea27ea9caab26b1207596fda98ce9a9ce Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Thu, 7 Aug 2025 10:10:49 +0530 Subject: [PATCH 18/18] added bash file --- run_parallel_orders.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/run_parallel_orders.sh b/run_parallel_orders.sh index c74fcc1..e58a133 100755 --- a/run_parallel_orders.sh +++ b/run_parallel_orders.sh @@ -10,6 +10,10 @@ echo "Starting 10 parallel instances of order_connect.py..." echo "Logs will be saved in the 'logs' folder" echo "================================================" +# Record start time +start_time=$(date +%s) +start_time_readable=$(date) + # Array to store process IDs pids=() @@ -29,8 +33,24 @@ for pid in "${pids[@]}"; do echo "Process $pid completed" done +# Record end time +end_time=$(date +%s) +end_time_readable=$(date) + +# Calculate execution time and RPS +execution_time=$((end_time - start_time)) +total_requests=150 # 10 instances * 15 requests each +rps=$(echo "scale=2; $total_requests / $execution_time" | bc -l) + echo "================================================" echo "All instances completed!" +echo "Execution Summary:" +echo "- Start time: $start_time_readable" +echo "- End time: $end_time_readable" +echo "- Total execution time: ${execution_time} seconds" +echo "- Total requests: $total_requests" +echo "- Requests per second (RPS): $rps" +echo "================================================" echo "Check the logs folder for individual instance outputs:" ls -la logs/ @@ -39,6 +59,13 @@ echo "Creating summary log..." echo "Summary of all parallel order creation attempts" > logs/summary.log echo "Generated at: $(date)" >> logs/summary.log echo "================================================" >> logs/summary.log +echo "EXECUTION STATISTICS:" >> logs/summary.log +echo "- Start time: $start_time_readable" >> logs/summary.log +echo "- End time: $end_time_readable" >> logs/summary.log +echo "- Total execution time: ${execution_time} seconds" >> logs/summary.log +echo "- Total requests: $total_requests (10 instances × 15 requests each)" >> logs/summary.log +echo "- Requests per second (RPS): $rps" >> logs/summary.log +echo "================================================" >> logs/summary.log for i in {1..10}; do echo "" >> logs/summary.log