mirror of
https://github.com/nasa/trick.git
synced 2024-12-21 14:07:51 +00:00
Updated tests to auto start server.
This commit is contained in:
parent
765b1a3a73
commit
ff3dcd4315
@ -5,6 +5,9 @@ from pprint import pprint
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
from time import sleep
|
||||
import shutil
|
||||
import datetime
|
||||
|
||||
from requests.api import get
|
||||
|
||||
@ -14,13 +17,33 @@ params = Params()
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def build_sim():
|
||||
path_to_sim = os.path.join(os.environ.get("TRICK_HOME", None), "trick_sims", "Cannon", "SIM_cannon_numeric")
|
||||
cmd = f'echo "cd {path_to_sim} && ./S_main_Linux_9.3_x86_64.exe RUN_test/input.py &" | /bin/bash'
|
||||
input_folder = "RUN_test"
|
||||
# test_input_file = f"tmp_input_for_test_{datetime.datetime.now()}.py"
|
||||
test_input_file = f"tmp_input_for_test.py"
|
||||
with open(os.path.join(path_to_sim, input_folder, test_input_file), "w") as f:
|
||||
f.write( \
|
||||
f"""web.server.enable = True
|
||||
web.server.debug = False
|
||||
web.server.ssl_enable = {params.get_ssl_enable()}
|
||||
web.server.path_to_ssl_cert = '{params.get_ssl_cert_path()}'
|
||||
web.server.port = {params.get_port()}
|
||||
|
||||
trick.var_server_set_port({params.get_var_server_port()})
|
||||
|
||||
exec(open("Modified_data/realtime.py").read())
|
||||
exec(open("Modified_data/cannon.dr").read())""")
|
||||
cmd = f'echo "cd {path_to_sim} && ./S_main_Linux_9.3_x86_64.exe {os.path.join(input_folder, test_input_file)} &" | /bin/bash'
|
||||
print("....................Running:", cmd)
|
||||
p = subprocess.run(cmd, shell=True)
|
||||
subprocess.run(cmd, shell=True)
|
||||
while True:
|
||||
p = subprocess.run(f"echo \"netstat -tulpan | grep {params.get_port()}\" | /bin/bash", capture_output=True, shell=True)
|
||||
print(f"Checking for port output: {p.stdout}")
|
||||
sleep(.1) #We sleep to use less recourses
|
||||
if p.stdout != b"":
|
||||
break
|
||||
yield
|
||||
os.system("pgrep S_ | xargs kill -9")
|
||||
|
||||
|
||||
os.remove(os.path.join(path_to_sim, input_folder, test_input_file))
|
||||
|
||||
def test_alloc_info():
|
||||
url = params.get_url("api/http/alloc_info")
|
||||
|
@ -36,7 +36,7 @@ async def test_time(time_path):
|
||||
async with websockets.connect(time_path, ssl=ssl_context) as websocket:
|
||||
await websocket.send("LOCAL")
|
||||
count = 0
|
||||
while count < 10:
|
||||
while count < 2:
|
||||
message = await websocket.recv()
|
||||
test_format = "Time: %H:%M Date: %m/%d/%Y\n" #Not checking seconds.
|
||||
time = datetime.datetime.strftime(datetime.datetime.strptime(message, "Time: %H:%M:%S Date: %m/%d/%Y\n"), test_format)
|
||||
|
Loading…
Reference in New Issue
Block a user