*** Settings *** Library OperatingSystem Library Process Resource ../common.robot Suite Setup Setup Suite Suite Teardown Cleanup Suite *** Variables *** ${lab-name} maglevd-test ${lab-file} maglevd-lab/maglevd.clab.yml ${config-file} maglevd-lab/maglev.yaml ${runtime} docker ${GRPC_PORT} 9091 *** Test Cases *** Deploy maglevd-test lab ${rc} ${output} = Run And Return Rc And Output ... ${CLAB_BIN} --runtime ${runtime} deploy -t ${CURDIR}/${lab-file} Log ${output} Should Be Equal As Integers ${rc} 0 Start maglevd ${handle} = Start Process ${MAGLEVD} ... --config ${CURDIR}/${config-file} ... --grpc-addr :${GRPC_PORT} ... --log-level debug ... alias=maglevd stdout=${EXECDIR}/tests/out/maglevd.log ... stderr=STDOUT Set Suite Variable ${MAGLEVD_HANDLE} ${handle} Sleep 3s Wait for nginx containers and probes to converge All backends reach up state [Template] Backend Should Be Up nginx1 nginx2 nginx3 Health checks are reaching all backends [Template] Probe Count Should Be Positive nginx1 nginx2 nginx3 Pause backend stops probing Maglevc set backend nginx1 pause Backend Should Have State nginx1 paused Sleep 1s ${before} = Get Probe Count nginx1 Sleep 2s Wait to confirm no new probes arrive ${after} = Get Probe Count nginx1 Should Be True ${after} == ${before} ... Probe count for nginx1 grew while paused: ${before} → ${after} Resume backend restarts probing Maglevc set backend nginx1 resume ${before} = Get Probe Count nginx1 Sleep 2s Wait for resumed probes to accumulate ${after} = Get Probe Count nginx1 Should Be True ${after} > ${before} ... Probe count for nginx1 did not grow after resume: ${before} → ${after} Wait Until Keyword Succeeds 5s 500ms ... Backend Should Be Up nginx1 Disable backend stops probing Maglevc set backend nginx2 disable Backend Should Have State nginx2 removed Backend Should Be Disabled nginx2 Sleep 1s ${before} = Get Probe Count nginx2 Sleep 2s Wait to confirm probes stopped ${after} = Get Probe Count nginx2 Should Be True ${after} == ${before} ... Probe count for nginx2 grew while disabled: ${before} → ${after} Enable backend restarts probing Maglevc set backend nginx2 enable ${before} = Get Probe Count nginx2 Sleep 2s Wait for re-enabled probes to accumulate ${after} = Get Probe Count nginx2 Should Be True ${after} > ${before} ... Probe count for nginx2 did not grow after enable: ${before} → ${after} Wait Until Keyword Succeeds 5s 500ms ... Backend Should Be Up nginx2 *** Keywords *** Setup Suite ${arch} = Run go env GOARCH Set Suite Variable ${ARCH} ${arch} Set Suite Variable ${MAGLEVD} ${EXECDIR}/build/${ARCH}/maglevd Set Suite Variable ${MAGLEVC} ${EXECDIR}/build/${ARCH}/maglevc Cleanup Suite Run Keyword And Ignore Error Terminate Process maglevd kill=true Run ${CLAB_BIN} --runtime ${runtime} destroy -t ${CURDIR}/${lab-file} --cleanup Maglevc [Documentation] Run a maglevc command and return its output. [Arguments] ${cmd} ${rc} ${output} = Run And Return Rc And Output ... ${MAGLEVC} --server\=localhost:${GRPC_PORT} --color\=false ${cmd} Log ${output} Should Be Equal As Integers ${rc} 0 RETURN ${output} Backend Should Be Up [Arguments] ${name} ${output} = Maglevc show backends ${name} Should Match Regexp ${output} state\\s+up Backend Should Have State [Arguments] ${name} ${expected_state} ${output} = Maglevc show backends ${name} Should Match Regexp ${output} state\\s+${expected_state} Backend Should Be Disabled [Arguments] ${name} ${output} = Maglevc show backends ${name} Should Match Regexp ${output} enabled\\s+false Get Probe Count [Documentation] Return the number of HTTP health-check requests seen in a backend's nginx log. [Arguments] ${name} ${output} = Run docker logs clab-${lab-name}-${name} 2>/dev/null | grep -c "GET /" || echo 0 ${count} = Convert To Integer ${output.strip()} RETURN ${count} Probe Count Should Be Positive [Arguments] ${name} ${count} = Get Probe Count ${name} Should Be True ${count} > 0 ... No health-check requests found in nginx logs for ${name}