def Check_JSON(j):
d = json.loads(j, strict=True)
+ logger.debug('got json %s' % d)
assert len(d) > 0
assert 'error' not in d
return d
current_directory = os.getcwd()
suite_name = BuiltIn().get_variable_value("${SUITE_NAME}")
test_name = BuiltIn().get_variable_value("${TEST NAME}")
+ onlyfiles = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))]
+ logger.debug('%s content before cleanup: %s' % (directory, onlyfiles))
if test_name is None:
# this is suite-level tear down
destination_directory = "%s/robot-save/%s" % (current_directory, suite_name)
os.makedirs(destination_directory)
for file in filenames.split(' '):
source_file = "%s/%s" % (directory, file)
+ logger.debug('check if we can save %s' % source_file)
if os.path.isfile(source_file):
+ logger.debug('found %s, save it' % file)
shutil.copy(source_file, "%s/%s" % (destination_directory, file))
shutil.copy(source_file, "%s/robot-save/%s.last" % (current_directory, file))
s.connect((addr, port))
s.close()
+def ping_rspamd(addr, port):
+ return str(urlopen("http://%s:%s/ping" % (addr, port)).read())
+
+def redis_check(addr, port):
+ """Attempts to open a TCP connection to specified address:port
+
+ Example:
+ | Wait Until Keyword Succeeds | 5s | 10ms | TCP Connect | localhost | 8080 |
+ """
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.settimeout(1.0) # seconds
+ s.connect((addr, port))
+ if s.sendall(b"ECHO TEST\n"):
+ result = s.recv(128)
+ return result == b'TEST\n'
+ else:
+ return False
+
def update_dictionary(a, b):
a.update(b)
return a
Should Be Equal As Integers ${result.rc} 0
Run Redis
- ${has_TMPDIR} = Evaluate 'TMPDIR'
- ${tmpdir} = Run Keyword If '${has_TMPDIR}' == 'True' Set Variable &{kwargs}[TMPDIR]
- ... ELSE Make Temporary Directory
${template} = Get File ${TESTDIR}/configs/redis-server.conf
${config} = Replace Variables ${template}
Create File ${TMPDIR}/redis-server.conf ${config}
${result} = Run Process redis-server ${TMPDIR}/redis-server.conf
Run Keyword If ${result.rc} != 0 Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
- Wait Until Keyword Succeeds 30 sec 1 sec Check Pidfile ${TMPDIR}/redis.pid
- Wait Until Keyword Succeeds 30 sec 1 sec TCP Connect ${REDIS_ADDR} ${REDIS_PORT}
+ Wait Until Keyword Succeeds 5x 1 sec Check Pidfile ${TMPDIR}/redis.pid timeout=0.5s
+ Wait Until Keyword Succeeds 5x 1 sec Redis Check ${REDIS_ADDR} ${REDIS_PORT}
${REDIS_PID} = Get File ${TMPDIR}/redis.pid
Run Keyword If '${REDIS_SCOPE}' == 'Test' Set Test Variable ${REDIS_PID}
... ELSE IF '${REDIS_SCOPE}' == 'Suite' Set Suite Variable ${REDIS_PID}
${result} = Run Process nginx -c ${TMPDIR}/nginx.conf
Run Keyword If ${result.rc} != 0 Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
- Wait Until Keyword Succeeds 30 sec 1 sec Check Pidfile ${TMPDIR}/nginx.pid
- Wait Until Keyword Succeeds 30 sec 1 sec TCP Connect ${NGINX_ADDR} ${NGINX_PORT}
+ Wait Until Keyword Succeeds 10x 1 sec Check Pidfile ${TMPDIR}/nginx.pid timeout=0.5s
+ Wait Until Keyword Succeeds 5x 1 sec TCP Connect ${NGINX_ADDR} ${NGINX_PORT}
${NGINX_PID} = Get File ${TMPDIR}/nginx.pid
Run Keyword If '${NGINX_SCOPE}' == 'Test' Set Test Variable ${NGINX_PID}
... ELSE IF '${NGINX_SCOPE}' == 'Suite' Set Suite Variable ${NGINX_PID}
Run Keyword If ${result.rc} != 0 Log ${result.stderr}
${rspamd_logpos} = Log Logs ${tmpdir}/rspamd.log 0
Should Be Equal As Integers ${result.rc} 0
- Wait Until Keyword Succeeds 30 sec 1 sec Check Pidfile ${tmpdir}/rspamd.pid
+ Wait Until Keyword Succeeds 10x 1 sec Check Pidfile ${tmpdir}/rspamd.pid timeout=0.5s
+ Wait Until Keyword Succeeds 5x 1 sec Ping Rspamd ${LOCAL_ADDR} ${PORT_NORMAL}
${rspamd_pid} = Get File ${tmpdir}/rspamd.pid
Set To Dictionary ${d} RSPAMD_LOGPOS=${rspamd_logpos} RSPAMD_PID=${rspamd_pid} TMPDIR=${tmpdir}
[Return] &{d}