updated memory tests

This commit is contained in:
proddy
2024-11-18 19:33:06 +01:00
parent c696974644
commit f840543f0f
2 changed files with 20 additions and 10 deletions

View File

@@ -27,7 +27,7 @@ def ping_until_up(ip, text):
time.sleep(1) time.sleep(1)
def run_test(skip, ip, wait, name, count, token): def run_test(skip, ip, wait, name, count, url, token):
BASE_URL = "http://" + str(ip) BASE_URL = "http://" + str(ip)
INFO_URL = BASE_URL + "/api/system/info" INFO_URL = BASE_URL + "/api/system/info"
@@ -50,6 +50,7 @@ def run_test(skip, ip, wait, name, count, token):
print() print()
end = timer() end = timer()
# set this to True if you want to use the test API
using_test = False using_test = False
if not skip: if not skip:
@@ -98,21 +99,24 @@ def run_test(skip, ip, wait, name, count, token):
# run test count times # run test count times
for i in range(count): for i in range(count):
if using_test: print("(" + str(round(end - start, 1)) +
# run test ")\t5. Running test (count #" + str(i+1) + " of " + str(count)+")...", end="")
print("(" + str(round(end - start, 1)) +
")\t5. Running test (count #" + str(i+1) + " of " + str(count)+") called '" + name + "'...", end="") # check if name start with a /
response = requests.get( if name[0] == "/":
TEST_URL, headers=GET_HEADERS, verify=False)
else:
# use URL # use URL
response = requests.get( response = requests.get(
BASE_URL + "/api/boiler/info", headers=GET_HEADERS, verify=False) BASE_URL + url, headers=GET_HEADERS, verify=False)
print("Response: ", response.json()) print("Response: ", response.json())
else:
# run a named test
response = requests.get(
TEST_URL, headers=GET_HEADERS, verify=False)
if (response.status_code != 200): if (response.status_code != 200):
print_fail("Test Failed!") print_fail("Test Failed!")
return return
print_success("Test ran successfully") print_success("Test ran successfully")
end = timer() end = timer()
@@ -162,6 +166,8 @@ parser.add_argument("-n", "--name", metavar="NAME", type=str,
default="memory", help="Name of test to run") default="memory", help="Name of test to run")
parser.add_argument("-c", "--count", metavar="COUNT", type=int, parser.add_argument("-c", "--count", metavar="COUNT", type=int,
default="1", help="number of times to run the test") default="1", help="number of times to run the test")
parser.add_argument("-u", "--url", metavar="URL", type=str,
help="custom URL")
parser.add_argument("-t", "--token", metavar="TOKEN", type=str, parser.add_argument("-t", "--token", metavar="TOKEN", type=str,
default="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg", help="Bearer Token") default="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg", help="Bearer Token")
args = parser.parse_args() args = parser.parse_args()

View File

@@ -12,7 +12,11 @@
# -i ip address of the device. default ems-esp.local. # -i ip address of the device. default ems-esp.local.
# -w wait time in seconds between each test. default 10. # -w wait time in seconds between each test. default 10.
# -c count, the number of tests to run. default 1. # -c count, the number of tests to run. default 1.
# -u url, custom URL to test against like "/api/boiler/info". optional.
# -t bearer token for the Restart command. optional. default is admin/admin's token. # -t bearer token for the Restart command. optional. default is admin/admin's token.
# -h help # -h help
python3 memory_test.py -s True -i 10.10.10.175 -w 5 -c 10 python3 memory_test.py -s True -i 10.10.10.175 -w 5 -c 30 -u "/api/boiler/info" # V3
# python3 memory_test.py -s True -i 10.10.10.175 -w 5 -c 30 -u "/api?device=boiler&cmd=info" # V2
# python3 memory_test.py -i 10.10.10.175 -n memory