mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
[test suite] corrected PUYA test. added erase/build/flash for all chips. preparations for full automatic hardware regression testing
This commit is contained in:
+5
-5
@@ -5,7 +5,7 @@ nodes=[
|
||||
'port' : '/dev/serial/by-path/pci-0000:00:14.0-usb-0:3.1:1.0-port0',
|
||||
'ip' : '192.168.13.91',
|
||||
'flash_cmd' : 'esptool.py --port {port} -b 1500000 write_flash 0x0 .pioenvs/dev_ESP8266_4096/firmware.bin --flash_size=32m -p',
|
||||
'build_cmd' : 'platformio run --environment dev_ESP8266_4096'
|
||||
'build_cmd' : 'platformio run --environment dev_ESP8266_4096 -s'
|
||||
},
|
||||
|
||||
# node 1
|
||||
@@ -14,16 +14,16 @@ nodes=[
|
||||
'port' : '/dev/serial/by-path/pci-0000:00:14.0-usb-0:3.2:1.0-port0',
|
||||
'ip' : '192.168.13.92',
|
||||
'flash_cmd' : 'esptool.py --port {port} -b 1500000 write_flash 0x0 .pioenvs/dev_ESP8266_4096/firmware.bin --flash_size=32m -p',
|
||||
'build_cmd' : 'platformio run --environment dev_ESP8266_4096'
|
||||
'build_cmd' : 'platformio run --environment dev_ESP8266_4096 -s'
|
||||
},
|
||||
|
||||
# node 2
|
||||
{
|
||||
'type' : 'ESP-01S 1Mb PUYA flash',
|
||||
'port' : '/dev/serial/by-path/pci-0000:00:14.0-usb-0:3.3:1.0-port0',
|
||||
'ip' : '192.168.13.92',
|
||||
'flash_cmd' : 'esptool.py --port {port} -b 1500000 write_flash 0x0 .pioenvs/dev_ESP8266_1024/firmware.bin --flash_size=detect -p',
|
||||
'build_cmd' : 'platformio run --environment dev_ESP8266_1024'
|
||||
'ip' : '192.168.13.93',
|
||||
'flash_cmd' : 'esptool.py --port {port} -b 115200 write_flash 0x0 .pioenvs/dev_ESP8266PUYA_1024/firmware.bin --flash_size=1MB -p',
|
||||
'build_cmd' : 'platformio run --environment dev_ESP8266PUYA_1024 -s'
|
||||
},
|
||||
|
||||
# {
|
||||
|
||||
+13
-8
@@ -29,6 +29,7 @@ class ControllerEmu:
|
||||
self.start_mqtt()
|
||||
self.start_http()
|
||||
self.start_linebased()
|
||||
self.log_enabled=True
|
||||
|
||||
|
||||
def start_mqtt(self):
|
||||
@@ -44,8 +45,9 @@ class ControllerEmu:
|
||||
|
||||
self.mqtt_messages=Queue()
|
||||
def mqtt_on_message(client, userdata, message):
|
||||
logging.getLogger("mqtt").debug("Received message '" + str(message.payload) + "' on topic '"
|
||||
+ message.topic + "' with QoS " + str(message.qos))
|
||||
if self.log_enabled:
|
||||
logging.getLogger("mqtt").debug("Received message '" + str(message.payload) + "' on topic '"
|
||||
+ message.topic + "' with QoS " + str(message.qos))
|
||||
self.mqtt_messages.put(message)
|
||||
|
||||
mqtt_client.on_message=mqtt_on_message
|
||||
@@ -66,12 +68,12 @@ class ControllerEmu:
|
||||
@bottle.post('<filename:path>')
|
||||
@bottle.get('<filename:path>')
|
||||
def urlhandler(filename):
|
||||
logging.getLogger("http").debug(bottle.request.method+" "+str(dict(bottle.request.params)))
|
||||
if self.log_enabled:
|
||||
logging.getLogger("http").debug(bottle.request.method+" "+str(dict(bottle.request.params)))
|
||||
self.http_requests.put(bottle.request.copy())
|
||||
|
||||
|
||||
|
||||
http_thread=threading.Thread(target=bottle.run, kwargs=dict(host='0.0.0.0', port=config.http_port, reloader=False))
|
||||
http_thread=threading.Thread(target=bottle.run, kwargs=dict(host='0.0.0.0', port=config.http_port, reloader=False, quiet=True))
|
||||
http_thread.daemon=True
|
||||
http_thread.start()
|
||||
|
||||
@@ -92,15 +94,18 @@ class ControllerEmu:
|
||||
|
||||
|
||||
def handle_connect(connection, client_address):
|
||||
logging.getLogger("linebased").debug("Connect from "+str(client_address))
|
||||
if self.log_enabled:
|
||||
logging.getLogger("linebased").debug("Connect from "+str(client_address))
|
||||
|
||||
fh = connection.makefile()
|
||||
for line in fh:
|
||||
line=line.rstrip()
|
||||
logging.getLogger("linebased").debug("Recv from "+str(client_address)+" :"+line)
|
||||
if self.log_enabled:
|
||||
logging.getLogger("linebased").debug("Recv from "+str(client_address)+" :"+line)
|
||||
self.linebased_lines.put( ( client_address, line ) )
|
||||
|
||||
logging.getLogger("linebased").debug("Disconnect from "+str(client_address))
|
||||
if self.log_enabled:
|
||||
logging.getLogger("linebased").debug("Disconnect from "+str(client_address))
|
||||
|
||||
def wait_accept():
|
||||
# Create a TCP/IP socket
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ Configure node 0, controller 1 as domoticz mqtt:
|
||||
"""
|
||||
return(docs)
|
||||
|
||||
parser = argparse.ArgumentParser(description='ESPEasy testing framework', epilog=get_epilog(), formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser = argparse.ArgumentParser(description='ESPEasy testing CLI', epilog=get_epilog(), formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
|
||||
# parser.add_argument('--url', default='http://localhost:8080/rpc', help='url of rpc server to connect to. default: %(default)s')
|
||||
# parser.add_argument('--user', default=None, help='user to login.')
|
||||
|
||||
@@ -8,5 +8,4 @@ import config
|
||||
|
||||
colorlog.basicConfig(level=logging.DEBUG)
|
||||
|
||||
|
||||
logging.getLogger("requests.packages.urllib3.connectionpool").setLevel(logging.ERROR)
|
||||
|
||||
+15
-2
@@ -13,7 +13,20 @@ import config
|
||||
import shelve
|
||||
import os
|
||||
from espcore import *
|
||||
import argparse
|
||||
import util
|
||||
|
||||
### parse arguments
|
||||
|
||||
parser = argparse.ArgumentParser(description='ESPEasy testing framework', formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument('--debug', action='store_true', help='enable http debugging output')
|
||||
parser.add_argument('--no-resume', action='store_true', help='dont resume testing from where we left off last time')
|
||||
parser.add_argument('--skip-power', action='store_true', help='skip tests that require powercycling.')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
if args.debug:
|
||||
util.enable_http_debug()
|
||||
|
||||
|
||||
### create node objects and espeasy objects
|
||||
@@ -22,7 +35,7 @@ node=[]
|
||||
espeasy=[]
|
||||
|
||||
for n in config.nodes:
|
||||
node.append(Node(n, "node"+str(len(node))))
|
||||
node.append(Node(n, "node"+str(len(node)), skip_power=args.skip_power))
|
||||
espeasy.append(EspEasy(node[-1]))
|
||||
|
||||
|
||||
@@ -49,7 +62,7 @@ with shelve.open("test.state") as shelve_db:
|
||||
def step(title=""):
|
||||
def step_dec(test):
|
||||
"""add test step. test can resume from every test-step"""
|
||||
if state['module'] and ( state['module'] != test.__module__ or state['name'] != test.__name__ or state['title'] != title):
|
||||
if not args.no_resume and state['module'] and ( state['module'] != test.__module__ or state['name'] != test.__name__ or state['title'] != title):
|
||||
log.debug("Skipping step "+title+": "+test.__module__ + "." + test.__name__ )
|
||||
else:
|
||||
state['module']=None
|
||||
|
||||
+21
-1
@@ -16,13 +16,14 @@ from espcore import *
|
||||
class Node():
|
||||
|
||||
|
||||
def __init__(self, config, id):
|
||||
def __init__(self, config, id, skip_power=False):
|
||||
self.log=logging.getLogger(id)
|
||||
self.log.debug("{type} has ip {ip}".format(id=id, **config))
|
||||
self._config=config
|
||||
self._id=id
|
||||
self._url="http://{ip}/".format(**self._config)
|
||||
self._serial_initialized=False
|
||||
self._skip_power=True
|
||||
|
||||
def serial_needed(self):
|
||||
"""call this at least once if you need serial stuff"""
|
||||
@@ -63,12 +64,21 @@ class Node():
|
||||
|
||||
def powercycle(self):
|
||||
"""powercycle the device"""
|
||||
if self._skip_power:
|
||||
self.log.warning("Skipping power cycle "+self._id)
|
||||
return False
|
||||
|
||||
|
||||
self.poweroff()
|
||||
self.poweron()
|
||||
return True
|
||||
|
||||
def poweroff(self):
|
||||
"""power off device"""
|
||||
|
||||
if self._skip_power:
|
||||
self.log.warning("Skipping power off "+self._id)
|
||||
return False
|
||||
|
||||
#cant yet be done automaticly unfortunatly
|
||||
self.log.info("Please power off node "+self._id)
|
||||
@@ -84,10 +94,15 @@ class Node():
|
||||
del self._serial
|
||||
|
||||
self.log.debug("Detected power off")
|
||||
return True
|
||||
|
||||
def poweron(self):
|
||||
"""power on device"""
|
||||
|
||||
if self._skip_power:
|
||||
self.log.warning("Skipping power on"+self._id)
|
||||
return False
|
||||
|
||||
self.log.info("Please power on node "+self._id)
|
||||
|
||||
done=False
|
||||
@@ -100,6 +115,7 @@ class Node():
|
||||
time.sleep(0.1)
|
||||
|
||||
self.log.debug("Detected power on")
|
||||
return True
|
||||
|
||||
def pingwifi(self, timeout=60):
|
||||
"""waits until espeasy reponds via wifi"""
|
||||
@@ -144,6 +160,7 @@ class Node():
|
||||
def build(self):
|
||||
"""compile binary"""
|
||||
|
||||
self.log.debug("Building...")
|
||||
subprocess.check_call(self._config['build_cmd'].format(**self._config), shell=True, cwd='..')
|
||||
|
||||
|
||||
@@ -152,6 +169,7 @@ class Node():
|
||||
|
||||
self.serial_needed()
|
||||
|
||||
self.log.debug("Flashing...")
|
||||
subprocess.check_call(self._config['flash_cmd'].format(**self._config), shell=True, cwd='..')
|
||||
|
||||
time.sleep(1)
|
||||
@@ -162,6 +180,7 @@ class Node():
|
||||
def serial(self):
|
||||
"""open serial terminal to esp"""
|
||||
self.serial_needed()
|
||||
self.log.debug("Opening serial terminal")
|
||||
subprocess.check_call("platformio serialports monitor --baud 115200 --port {port} --echo".format(**self._config), shell=True, cwd='..')
|
||||
# print("JA")
|
||||
# term=serial.tools.miniterm.Miniterm(self._serial)
|
||||
@@ -173,6 +192,7 @@ class Node():
|
||||
def erase(self):
|
||||
"""erase flash via serial"""
|
||||
self.serial_needed()
|
||||
self.log.debug("Erasing...")
|
||||
subprocess.check_call("esptool.py --port {port} -b 1500000 erase_flash".format(**self._config), shell=True, cwd='..')
|
||||
|
||||
|
||||
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from esptest import *
|
||||
|
||||
# hardware requirements:
|
||||
# - all nodes
|
||||
|
||||
# tests:
|
||||
# - builds, flashes and resets to factory defaults
|
||||
|
||||
# prevent confusing messages during build
|
||||
controller.log_enabled=False
|
||||
|
||||
# @step()
|
||||
# def clean():
|
||||
# subprocess.check_call("cd ..;platformio run --target clean -s", shell=True)
|
||||
|
||||
@step()
|
||||
def patch():
|
||||
subprocess.check_call("cd ../patches; ./check_puya_patch", shell=True)
|
||||
|
||||
|
||||
@step()
|
||||
def build():
|
||||
for n in node:
|
||||
n.build()
|
||||
|
||||
|
||||
@step()
|
||||
def erase():
|
||||
for n in node:
|
||||
n.erase()
|
||||
|
||||
@step()
|
||||
def flash():
|
||||
for n in node:
|
||||
n.flashserial()
|
||||
|
||||
@step()
|
||||
def wificonfig():
|
||||
for n in node:
|
||||
n.wificonfig()
|
||||
|
||||
controller.log_enabled=True
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
completed()
|
||||
+3
-1
@@ -65,7 +65,9 @@ def test():
|
||||
@step()
|
||||
def powercycle():
|
||||
"""test result on poweron"""
|
||||
node[0].powercycle()
|
||||
if not node[0].powercycle():
|
||||
return
|
||||
|
||||
results=controller.recv_domoticz_mqtt(SENSOR_TYPE_SINGLE,2001)
|
||||
test_in_range(results[0], -5,40)
|
||||
results=controller.recv_domoticz_mqtt(SENSOR_TYPE_SINGLE,2002)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
#runs all test modules
|
||||
|
||||
import glob
|
||||
import importlib
|
||||
import os
|
||||
|
||||
Reference in New Issue
Block a user