mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 23:43:20 +02:00
test: ssh_*: Wait for server start before further testing commences
On slow systems, we don't want test steps involving tools like scp or ssh-keyscan to fail because the server had not come up yet. Therefore, make sure that the server is ready to accept connections before moving on to subsequent test steps.
This commit is contained in:
@@ -8,7 +8,7 @@ Verify that 'guest' user can fetch data using only the 'public' key
|
||||
import infamy
|
||||
import os
|
||||
import tempfile
|
||||
from infamy import ssh
|
||||
from infamy import ssh, until, netutil
|
||||
|
||||
USER = "guest"
|
||||
KEY = {
|
||||
@@ -72,6 +72,9 @@ with infamy.Test() as test:
|
||||
}
|
||||
})
|
||||
|
||||
with test.step("Wait until SSH server is ready to accept connections"):
|
||||
until(lambda: netutil.tcp_port_is_open(target.get_mgmt_ip(), 22))
|
||||
|
||||
with test.step("Write private key to a temporary file"):
|
||||
with tempfile.NamedTemporaryFile(delete=False, mode='w') as key_file:
|
||||
key_file.write(KEY["private"])
|
||||
|
||||
@@ -9,7 +9,9 @@ Test SSH server functionality with pre-defined key pair:
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
|
||||
import infamy
|
||||
from infamy import until, netutil
|
||||
|
||||
PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCtzyoT8/23hSyo7trLaqc6Auj5jvwhhCxUh8WIyfd5G/R9R+/wFEtGo6c6h75/GFCotFCQYvLlqHkrI0QiLYCPo0Rcxzfpy8TZGYjlyD8aYTYeXR2Oow6cjHE3ajQEEPbr5eiV/NBezg00SrCazDN4VHEXcjhl4egaKxDyG1yi98kQISY0+ehNjR/CKOBvOxHqB0N7gUnasbBiiN/iCCkCuDFKnBM6cYrUAvwP/aj+f9dq4lImJ6YpHaSjFKIa2ZFmOi20X0cb0AS1cshjSU2qf9eS2nysbmlC50X8HL9gaIeVInsWTLxEHTrd2gyBCTPO3X6oLJWW7HoB+yA9wp6xAgMBAAECggEACDNXrsaSrFmfFm7jmZikAHmR7LFlfb7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MjoXKTEeVMo6ulrEijnbCx6DgkOwq+EOUvZn0W7ly4RhDDA9W8qdBIAzAGumkCx4456Un3z8wbIVgSZB52IELCBKpbyhSWE="
|
||||
|
||||
@@ -99,6 +101,9 @@ with infamy.Test() as test:
|
||||
}
|
||||
})
|
||||
|
||||
with test.step("Wait until SSH server is ready to accept connections"):
|
||||
until(lambda: netutil.tcp_port_is_open(target.get_mgmt_ip(), 22))
|
||||
|
||||
with test.step("Verify SSH public keys"):
|
||||
_, hport1 = env.ltop.xlate("host", "data1")
|
||||
_, hport2 = env.ltop.xlate("host", "data2")
|
||||
|
||||
Reference in New Issue
Block a user