Skip to content

Test scripts shouldn't grep log strings #4388

@AkihiroSuda

Description

@AkihiroSuda

The log strings change day by day; the test scripts shouldn't expect the log strings to be greppable.

Instead they should use limactl ls --json or limactl watch --json (to be designed and implemented) to obtain proper JSON objects

lima/hack/test-templates.sh

Lines 335 to 367 in 68be6f2

if [[ -n ${CHECKS["ssh-over-vsock"]} ]]; then
if [[ "$(limactl ls "${NAME}" --yq .vmType)" == "vz" ]]; then
INFO "Testing SSH over vsock"
set -x
INFO "Testing .ssh.overVsock=true configuration"
limactl stop "${NAME}"
# Detection of the SSH server on VSOCK may fail; however, a failing log indicates that controlling detection via the environment variable works as expected.
if ! limactl start --set '.ssh.overVsock=true' "${NAME}" 2>&1 | grep -i -E "(started vsock forwarder|Failed to detect SSH server on vsock)"; then
set +x
diagnose "${NAME}"
ERROR ".ssh.overVsock=true did not enable vsock forwarder"
exit 1
fi
INFO 'Testing .ssh.overVsock=null configuration'
limactl stop "${NAME}"
# Detection of the SSH server on VSOCK may fail; however, a failing log indicates that controlling detection via the environment variable works as expected.
if ! limactl start --set '.ssh.overVsock=null' "${NAME}" 2>&1 | grep -i -E "(started vsock forwarder|Failed to detect SSH server on vsock)"; then
set +x
diagnose "${NAME}"
ERROR ".ssh.overVsock=null did not enable vsock forwarder"
exit 1
fi
INFO "Testing .ssh.overVsock=false configuration"
limactl stop "${NAME}"
if ! limactl start --set '.ssh.overVsock=false' "${NAME}" 2>&1 | grep -i "skipping detection of SSH server on vsock port"; then
set +x
diagnose "${NAME}"
ERROR ".ssh.overVsock=false did not disable vsock forwarder"
exit 1
fi
set +x
fi
fi

if ($test{mode} eq "ignore") {
$test{log_msg} = "Not forwarding TCP $remote";
}
else {
$test{log_msg} = "Forwarding TCP from $remote to $local";
}

while (<$log>) {
$seen{$1}++ if /(Forwarding TCP from .*? to ((\d.*?|\[.*?\]):\d+|\/[^"]+))/;
$seen{$1}++ if /(Not forwarding TCP .*?:\d+)/;
$failed_to_listen_tcp{$2}=$1 if /(failed to listen tcp: listen tcp (.*?:\d+):[^"]+)/;
}

(Probably more)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/clilimactl CLI user experiencearea/testTests and CI

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions