added offset test for lan block list and improved run time tests to be random order and have better iterative output
This commit is contained in:
parent
05ea54cd28
commit
4696e7be3f
@ -6,6 +6,7 @@ import os
|
||||
|
||||
import logger
|
||||
from onionrutils import epoch
|
||||
from onionrcrypto.cryptoutils.randomshuffle import random_shuffle
|
||||
|
||||
from . import uicheck, inserttest, stresstest
|
||||
from . import ownnode
|
||||
@ -50,6 +51,7 @@ class OnionrRunTestManager:
|
||||
self.run_date: int = 0
|
||||
|
||||
def run_tests(self):
|
||||
tests = random_shuffle(RUN_TESTS)
|
||||
cur_time = epoch.get_epoch()
|
||||
logger.info(f"Doing runtime tests at {cur_time}")
|
||||
|
||||
@ -58,13 +60,18 @@ class OnionrRunTestManager:
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
done_count: int = 0
|
||||
total_to_do: int = len(tests)
|
||||
|
||||
try:
|
||||
for i in RUN_TESTS:
|
||||
for i in tests:
|
||||
last = i
|
||||
logger.info("[RUNTIME TEST] " + last.__name__ + " started",
|
||||
terminal=True, timestamp=True)
|
||||
i(self)
|
||||
logger.info("[RUNTIME TEST] " + last.__name__ + " passed",
|
||||
done_count += 1
|
||||
logger.info("[RUNTIME TEST] " + last.__name__ +
|
||||
f" passed {done_count}/{total_to_do}",
|
||||
terminal=True, timestamp=True)
|
||||
except (ValueError, AttributeError):
|
||||
logger.error(last.__name__ + ' failed assertions', terminal=True)
|
||||
|
@ -3,20 +3,34 @@ import requests
|
||||
from lan.getip import best_ip
|
||||
|
||||
from onionrblocks import insert, onionrblockapi
|
||||
from gevent import sleep
|
||||
from coredb import blockmetadb
|
||||
from onionrutils.epoch import get_epoch
|
||||
import logger
|
||||
|
||||
def test_lan_server(testmanager):
|
||||
|
||||
start_time = get_epoch()
|
||||
for i in range(1024, 65536):
|
||||
try:
|
||||
if requests.get(f"http://{best_ip}:{i}/ping").text == 'pong!':
|
||||
bl = insert('test data')
|
||||
sleep(10)
|
||||
bl2 = insert('test data2')
|
||||
l = requests.get(f"http://{best_ip}:{i}/blist/0").text
|
||||
if bl not in l or bl2 not in l:
|
||||
sleep(30)
|
||||
bl3 = insert('test data3')
|
||||
l = requests.get(f"http://{best_ip}:{i}/blist/0").text.split('\n')
|
||||
if bl not in l or bl2 not in l or bl3 not in l:
|
||||
logger.error('blocks not in blist ' + '-'.join(l), terminal=True)
|
||||
raise ValueError
|
||||
time = blockmetadb.get_block_date(bl3) - 1
|
||||
l = requests.get(f"http://{best_ip}:{i}/blist/{time}").text.split('\n')
|
||||
|
||||
if (bl in l and bl2 in l and bl3 in l) or len(l) == 0:
|
||||
logger.error('Failed to get appopriate time' + '-'.join(l), terminal=True)
|
||||
raise ValueError
|
||||
if onionrblockapi.Block(bl).raw != requests.get(f"http://{best_ip}:{i}/get/{bl}").content:
|
||||
raise ValueError
|
||||
|
||||
|
||||
break
|
||||
|
||||
except requests.exceptions.ConnectionError:
|
||||
|
Loading…
Reference in New Issue
Block a user