Commit da1ce52e authored by kzangeli's avatar kzangeli
Browse files

fix(mqtt): the no-docker path never ran a single command



Two defects in Start Mqtt Server Natively, either of which alone makes every MQTT
Test Purpose fail at setup with ConnectionRefusedError - a broker fault to read,
and not one.

Set Variable with more than one argument returns a LIST, not a joined string.
Run Process then handed /bin/sh the repr of that list, which is the

    /bin/sh: 1: [set -e;,: not found

in the log: the bracket and the comma are Python's. Catenate is the keyword that
joins.

And the readiness probe ends in `exec 3<>/dev/tcp/127.0.0.1/${port}`, a bash
builtin. shell=yes runs the script under /bin/sh - dash on Debian and Ubuntu -
and dash does not implement /dev/tcp, so the probe failed every time and the
keyword reported "could not be started" about a mosquitto that had started
perfectly well. Run it under bash.

Verified against a PATH with no docker on it, so the native branch is the one
taken: before, the keyword fails with exactly the error above; after, mosquitto
comes up and is listening on the port asked for.

Co-Authored-By: default avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
parent 3dd7988b
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -52,7 +52,12 @@ Start Mqtt Server Natively
    # here. The password file is copied and made world-readable because mosquitto
    # drops privileges when started as root - as it is in a container - and cannot
    # otherwise read a file owned by root.
    ${script} =    Set Variable
    # Catenate, NOT Set Variable: `Set Variable` with more than one argument
    # returns a LIST, and `Run Process` then hands /bin/sh the repr of that list -
    # which is why every MQTT test failed with
    #     /bin/sh: 1: [set -e;,: not found
    # and then "Connection refused", reading as a broker fault it is not.
    ${script} =    Catenate    SEPARATOR=${SPACE}
    ...    set -e;
    ...    d=/tmp/etsi-mosquitto-${port}; rm -rf $d; mkdir -p $d;
    ...    cp "${CURDIR}/mosquitto/mosquitto_pwd" $d/mosquitto_pwd; chmod 644 $d/mosquitto_pwd;
@@ -61,7 +66,12 @@ Start Mqtt Server Natively
    ...    mosquitto -d -c $d/mosquitto.conf;
    ...    for i in $(seq 1 40); do (exec 3<>/dev/tcp/127.0.0.1/${port}) 2>/dev/null && exit 0; sleep 0.25; done; exit 1

    ${result} =    Run Process    ${script}    shell=yes
    # bash, not `shell=yes`. Run Process's shell is /bin/sh - dash on Debian and
    # Ubuntu - and the readiness probe below ends in `exec 3<>/dev/tcp/...`, which
    # is a bash builtin that dash does not implement. Under sh the probe therefore
    # FAILS EVERY TIME, and the keyword reports "could not be started" about a
    # mosquitto that started perfectly well.
    ${result} =    Run Process    bash    -c    ${script}
    IF    ${result.rc} > 0
        Log To Console    mosquitto could not be started on port ${port} without docker
        Log To Console    ${result.stdout}