Skip to content
Snippets Groups Projects
Commit ce29d5e1 authored by Giovanna Lazzari Miotto's avatar Giovanna Lazzari Miotto :mushroom:
Browse files

test: control: Add control script to trigger run

test: control: Support python3
parent eee9490d
Branches
No related tags found
1 merge request!105control: Synchronize run based on control state
#! /usr/bin/python2
#! /usr/bin/python3
import socket
import time
......@@ -10,21 +10,18 @@ STOP_DELAY_SECS = 20
def send_command(sock, cmd, run_no):
message = cmd + " " + str(run_no)
print "Sending message: ", message
print("Sending message: ", message)
try:
sock.sendall(message)
data = sock.recv(256)
print "Server response: ", data
sock.sendall(message.encode('utf-8'))
data = sock.recv(256).decode('utf-8')
if "ok" in data:
print "Command successful"
return True
return cmd + " command successful: received " + data
else:
return False
return cmd + " command FAILED: received " + data
except Exception as e:
print "ERROR! ", e
print("ERROR! ", e)
return False
if __name__ == "__main__":
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 8000)
......@@ -35,11 +32,11 @@ if __name__ == "__main__":
do_start = True
for current_run in range(1, MAX_RUNS + 1):
if do_start:
print "Starting run ", current_run
print("Starting run ", current_run)
send_command(sock, "start", current_run)
time.sleep(EXEC_TIME_SECS)
print "Halting run ", current_run
print("Halting run ", current_run)
send_command(sock, "stop", current_run)
time.sleep(STOP_DELAY_SECS)
......
#! /usr/bin/python3
import socket
import time
EXEC_TIME_SECS = 30
def send_command(sock, cmd, run_no):
message = cmd + " " + str(run_no)
print("Sending message: ", message)
try:
sock.sendall(message.encode('utf-8'))
data = sock.recv(256).decode('utf-8')
return "ok" in data
except Exception as e:
print("ERROR! ", e)
return False
if __name__ == "__main__":
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 8000)
sock.connect(server_address)
current_run = 1
time.sleep(2)
print("Starting run ", current_run)
if send_command(sock, "start", current_run):
print("Command successful")
else:
print("Command failed")
time.sleep(EXEC_TIME_SECS)
sock.close()
......@@ -86,9 +86,10 @@ function run_filedma_test() {
local test_failed=1
echo "${FUNCNAME}: starting SCDAQ test with ${test_id} P5 capture file"
echo "${FUNCNAME}: timeout ${timeout_secs}s ./${SCDAQ_PATH} --config ${config_file}"
python3 scripts/start_run.py &
timeout ${timeout_secs}s ./"${SCDAQ_PATH}" --config ${config_file} | uniq -uc
ret_status="${PIPESTATUS[0]}"
wait
# We expect a TIMEOUT failure because `scdaq` is not normally supposed to return.
if [[ "${ret_status}" -ne 124 ]]; then
......@@ -221,7 +222,7 @@ function main {
build_scdaq
# Test 1: time-bound operation, checks for crashes
# # Test 1: time-bound operation, checks for crashes
EXPECTS_OUTPUT=false VALIDATE_CONTENT=false run_all_tests "Test 1 (operation) - ${MAX_RUNTIME_SECS}-second runs, no output files"
exit_on_failure $?
......
......@@ -50,7 +50,7 @@
dev_TCPAutoReconnectOnFailure: "false",
// (Minimum) Logging severity: TRACE DEBUG INFO WARNING ERROR FATAL.
// Use TRACE to log everything.
log_min_severity: "TRACE",
log_min_severity: "ERROR",
threads: 8,
// Stores fixed number of orbits per file when nOrbitsPerFile > 1
// If zero, uses a fixed file size (`max_file_size`) instead
......
......@@ -50,7 +50,7 @@
dev_TCPAutoReconnectOnFailure: "false",
// (Minimum) Logging severity: TRACE DEBUG INFO WARNING ERROR FATAL.
// Use TRACE to log everything.
log_min_severity: "TRACE",
log_min_severity: "ERROR",
threads: 8,
// Stores fixed number of orbits per file when nOrbitsPerFile > 1
// If zero, uses a fixed file size (`max_file_size`) instead
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment