Ensure workers include cmd->id in control replies to avoid 'unknown request id 0' warnings. Update functional control tests and make RSPAMD_TMPDIR visible to child suites.
struct rspamd_fuzzy_storage_ctx *ctx = ud;
struct rspamd_control_reply rep;
- rep.reply.fuzzy_sync.status = 0;
+ memset(&rep, 0, sizeof(rep));
rep.type = RSPAMD_CONTROL_FUZZY_SYNC;
+ rep.id = cmd->id;
+ rep.reply.fuzzy_sync.status = 0;
if (ctx->backend && worker->index == 0) {
rspamd_fuzzy_process_updates_queue(ctx, local_db_name, FALSE);
ev_tstamp now = ev_now(ctx->event_loop);
rspamd_inet_addr_t *addr = NULL;
+ memset(&rep, 0, sizeof(rep));
rep.type = RSPAMD_CONTROL_FUZZY_BLOCKED;
+ rep.id = cmd->id;
rep.reply.fuzzy_blocked.status = 0;
if (cmd->cmd.fuzzy_blocked.af == AF_INET) {
memset(&rep, 0, sizeof(rep));
rep.type = RSPAMD_CONTROL_RELOAD;
+ rep.id = cmd->id;
if ((ctx->backend = rspamd_fuzzy_backend_create(ctx->event_loop,
worker->cf->options, rspamd_main->cfg,
memset(&rep, 0, sizeof(rep));
rep.type = RSPAMD_CONTROL_FUZZY_STAT;
+ rep.id = cmd->id;
rspamd_snprintf(tmppath, sizeof(tmppath), "%s%c%s-XXXXXXXXXX",
rspamd_main->cfg->temp_dir, G_DIR_SEPARATOR, "fuzzy-stat");
msg_info("recompiling hyperscan expressions after receiving reload command");
memset(&rep, 0, sizeof(rep));
rep.type = RSPAMD_CONTROL_RECOMPILE;
+ rep.id = cmd->id;
rep.reply.recompile.status = 0;
/* We write reply before actual recompilation as it takes a lot of time */
memset(&rep, 0, sizeof(rep));
rep.type = RSPAMD_CONTROL_WORKERS_SPAWNED;
+ rep.id = cmd->id;
rep.reply.workers_spawned.status = 0;
/* Write reply */
struct ev_loop *event_loop;
struct rspamd_async_session *session;
enum rspamd_control_type cmd;
+ uint64_t cmd_id;
int cbref;
int fd;
};
memset(&rep, 0, sizeof(rep));
rep.type = cbd->cmd;
+ rep.id = cbd->cmd_id;
if (write(cbd->fd, &rep, sizeof(rep)) != sizeof(rep)) {
msg_err_pool("cannot write reply to the control socket: %s",
cbd);
cbd->session = session;
cbd->fd = fd;
+ cbd->cmd_id = cmd->id;
lua_pushcfunction(L, &rspamd_lua_traceback);
err_idx = lua_gettop(L);
--- /dev/null
+*** Settings ***
+Library ${RSPAMD_TESTDIR}/lib/rspamd.py
+Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
+Variables ${RSPAMD_TESTDIR}/lib/vars.py
+
+*** Test Cases ***
+CONTROL STAT
+ [Documentation] Test control socket stat command
+ ${result} = Run Control Command stat ${RSPAMD_TMPDIR}/rspamd.sock
+ Should Be Equal As Integers ${result.rc} 0
+ Should Contain ${result.stdout} workers
+ Should Contain ${result.stdout} total
+
+CONTROL STAT JSON
+ [Documentation] Test control socket stat command with JSON output
+ ${result} = Run Control Command JSON stat ${RSPAMD_TMPDIR}/rspamd.sock
+ Should Be Equal As Integers ${result.rc} 0
+ Should Contain ${result.stdout} "workers"
+ Should Contain ${result.stdout} "total"
+
+CONTROL RERESOLVE
+ [Documentation] Test control socket reresolve command
+ ${result} = Run Control Command reresolve ${RSPAMD_TMPDIR}/rspamd.sock
+ Should Be Equal As Integers ${result.rc} 0
+
+CONTROL FUZZY SYNC
+ [Documentation] Test control socket fuzzy_sync command
+ ${result} = Run Control Command fuzzy_sync ${RSPAMD_TMPDIR}/rspamd.sock
+ Should Be Equal As Integers ${result.rc} 0
+
+CONTROL COMPOSITES STATS
+ [Documentation] Test control socket composites_stats command
+ ${result} = Run Control Command composites_stats ${RSPAMD_TMPDIR}/rspamd.sock
+ Should Be Equal As Integers ${result.rc} 0
+ Should Contain ${result.stdout} checked_slow
+
+CONTROL COMPOSITES STATS JSON
+ [Documentation] Test control socket composites_stats command with JSON output
+ ${result} = Run Control Command JSON composites_stats ${RSPAMD_TMPDIR}/rspamd.sock
+ Should Be Equal As Integers ${result.rc} 0
+ Should Contain ${result.stdout} checked_slow
+
+CONTROL MULTIPLE COMMANDS
+ [Documentation] Test multiple control socket commands in sequence to verify ID matching
+ ${result1} = Run Control Command stat ${RSPAMD_TMPDIR}/rspamd.sock
+ Should Be Equal As Integers ${result1.rc} 0
+ ${result2} = Run Control Command reresolve ${RSPAMD_TMPDIR}/rspamd.sock
+ Should Be Equal As Integers ${result2.rc} 0
+ ${result3} = Run Control Command composites_stats ${RSPAMD_TMPDIR}/rspamd.sock
+ Should Be Equal As Integers ${result3.rc} 0
+ ${result4} = Run Control Command stat ${RSPAMD_TMPDIR}/rspamd.sock
+ Should Be Equal As Integers ${result4.rc} 0
Set Directory Ownership ${RSPAMD_TMPDIR} ${RSPAMD_USER} ${RSPAMD_GROUP}
# Export ${RSPAMD_TMPDIR} to appropriate scope according to ${RSPAMD_SCOPE}
- Export Scoped Variables ${RSPAMD_SCOPE} RSPAMD_TMPDIR=${RSPAMD_TMPDIR}
+ IF '${RSPAMD_SCOPE}' == 'Test'
+ Set Test Variable ${RSPAMD_TMPDIR}
+ ELSE IF '${RSPAMD_SCOPE}' == 'Suite'
+ Set Suite Variable ${RSPAMD_TMPDIR}
+ # Needed for child suites (e.g. directory suites with per-file .robot suites)
+ Set Global Variable ${RSPAMD_TMPDIR}
+ ELSE IF '${RSPAMD_SCOPE}' == 'Global'
+ Set Global Variable ${RSPAMD_TMPDIR}
+ ELSE
+ Fail message="Don't know what to do with scope: ${RSPAMD_SCOPE}"
+ END
Run Rspamd check_port=${check_port}
Log ${result.stdout}
Sleep 0.1s Try give fuzzy storage time to sync
+Run Control Command
+ [Documentation] Run a control socket command and return the result
+ [Arguments] ${command} ${socket}
+ ${result} = Run Process ${RSPAMADM} control -s
+ ... ${socket} ${command} timeout=10s
+ Log ${result.stdout}
+ Log ${result.stderr}
+ [Return] ${result}
+
+Run Control Command JSON
+ [Documentation] Run a control socket command and return JSON result
+ [Arguments] ${command} ${socket}
+ ${result} = Run Process ${RSPAMADM} control -j -s
+ ... ${socket} ${command} timeout=10s
+ Log ${result.stdout}
+ Log ${result.stderr}
+ [Return] ${result}
+
Run Dummy Http
${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py -pf /tmp/dummy_http.pid
... stderr=/tmp/dummy_http.log stdout=/tmp/dummy_http.log