+ now require runtime tests to generate unittest result that is somewhat fresh

+ add runtime test for webpass needing to be set
This commit is contained in:
Kevin Froman 2020-01-29 22:56:47 -06:00
parent 6624a80c68
commit 8a3f84097a
12 changed files with 115 additions and 17 deletions

View file

@ -1,13 +1,15 @@
"""
Onionr - Private P2P Communication
"""Onionr - Private P2P Communication.
Test Onionr as it is running
Test Onionr as it is running
"""
import os
import logger
from onionrutils import epoch
from . import uicheck, inserttest, stresstest
from . import ownnode
from .webpasstest import webpass_test
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -27,9 +29,12 @@ RUN_TESTS = [uicheck.check_ui,
inserttest.insert_bin_test,
ownnode.test_tor_adder,
ownnode.test_own_node,
stresstest.stress_test_block_insert
stresstest.stress_test_block_insert,
webpass_test
]
SUCCESS_FILE = os.path.dirname(os.path.realpath(__file__)) + '/../../tests/runtime-result.txt'
class OnionrRunTestManager:
def __init__(self):
@ -40,6 +45,11 @@ class OnionrRunTestManager:
cur_time = epoch.get_epoch()
logger.info(f"Doing runtime tests at {cur_time}")
try:
os.remove(SUCCESS_FILE)
except FileNotFoundError:
pass
try:
for i in RUN_TESTS:
last = i
@ -47,3 +57,9 @@ class OnionrRunTestManager:
logger.info("[RUNTIME TEST] " + last.__name__ + " passed")
except (ValueError, AttributeError):
logger.error(last.__name__ + ' failed')
else:
ep = str(epoch.get_epoch())
logger.info(f'All runtime tests passed at {ep}')
with open(SUCCESS_FILE, 'w') as f:
f.write(ep)

View file

@ -29,10 +29,9 @@ def test_own_node(test_manager):
if config.get('general.security_level', 0) > 0:
return
own_tor_address = gettransports.get()[0]
print(socks_port)
if 'this is an onionr node' \
not in basicrequests.do_get_request(own_tor_address,
port=socks_port).lower():
not in basicrequests.do_get_request('http://' + own_tor_address,
port=socks_port, ignoreAPI=True).lower():
logger.warn('Own node not reachable in test')
raise ValueError
@ -47,7 +46,6 @@ def test_tor_adder(test_manager):
raise ValueError('No Tor node address created yet')
if hs not in gettransports.get():
print(hs in gettransports.get(), 'meme')
logger.error('gettransports Tor not same as file: %s %s' %
(hs, gettransports.get()))
raise ValueError('gettransports Tor not same as file')

View file

@ -5,5 +5,5 @@ def check_ui(test_manager):
result = localcommand.local_command(point)
if not result: raise ValueError
result = result.lower()
if not 'script' in result:
if 'script' not in result:
raise ValueError(f'uicheck failed on {point}')

View file

@ -0,0 +1,11 @@
import requests
from onionrutils import localcommand
def webpass_test(test_manager):
if requests.get('http://' + localcommand.get_hostname() + '/ping') == \
'pong!':
raise ValueError
if localcommand.local_command('ping') != 'pong!':
raise ValueError('Could not ping with normal localcommand in webpasstest')