Skip to content

Commit 1e8856e

Browse files
committed
e2e-tests: Send journal via TCP if host doesn't support VSOCK yet
systemd only supports sending the journal via VSOCK since v256. In the GitHub CI the newest Ubuntu release we can use on the runners (both GitHub-hosted or self-hosted) is 24.04, which has systemd 255.
1 parent e081a57 commit 1e8856e

File tree

5 files changed

+64
-18
lines changed

5 files changed

+64
-18
lines changed

authd-oidc-brokers/e2e-tests/resources/authd/Journal.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,26 @@
1010
HOST_CID = 2 # 2 always refers to the host
1111
PORT = 55000
1212

13+
def libvirt_host_ip() -> str:
14+
# Get the bridge name for the default libvirt network
15+
bridge = ExecUtils.check_output(
16+
["virsh", "net-info", "default"],
17+
text=True,
18+
).split("Bridge:")[1].split()[0]
19+
20+
# Get the IPv4 address assigned to that bridge
21+
ip = ExecUtils.check_output(
22+
["ip", "-4", "addr", "show", bridge],
23+
text=True,
24+
)
25+
26+
host_ip = next(
27+
line.split()[1].split("/")[0]
28+
for line in ip.splitlines()
29+
if line.strip().startswith("inet ")
30+
)
31+
return host_ip
32+
1333
@library
1434
class Journal:
1535
process = None
@@ -28,10 +48,16 @@ async def start_receiving_journal(self) -> None:
2848
self.output_dir = os.path.join(output_dir, suite_name, "journal")
2949
os.makedirs(self.output_dir, exist_ok=True)
3050

51+
if os.getenv("SYSTEMD_SUPPORTS_VSOCK"):
52+
listen_address = f"vsock:{HOST_CID}:{PORT}"
53+
else:
54+
host_ip = libvirt_host_ip()
55+
listen_address = f"{host_ip}:{PORT}"
56+
3157
self.process = ExecUtils.Popen(
3258
[
3359
"/lib/systemd/systemd-journal-remote",
34-
f"--listen-raw=vsock:{HOST_CID}:{PORT}",
60+
f"--listen-raw={listen_address}",
3561
f"--output={self.output_dir}"
3662
],
3763
)

authd-oidc-brokers/e2e-tests/run-tests.sh

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ if [ -n "${RERUNFAILED:-}" ] && [ -z "${PREVIOUS_TEST_RUN_DIR}" ]; then
113113
exit 1
114114
fi
115115

116+
systemd_ver=$(systemctl --version | awk 'NR==1 {print $2}')
117+
if dpkg --compare-versions "$systemd_ver" "ge" "256"; then
118+
SYSTEMD_SUPPORTS_VSOCK=1
119+
fi
120+
116121
ROBOT_ARGS=()
117122
if [ -n "${RERUNFAILED:-}" ]; then
118123
echo "Rerunning failed tests from previous run in ${PREVIOUS_TEST_RUN_DIR}"
@@ -163,19 +168,21 @@ for test_file in $TESTS_TO_RUN; do
163168
ln -s "${test_file}" tests
164169
done
165170

166-
E2E_USER="$E2E_USER" \
167-
E2E_PASSWORD="$E2E_PASSWORD" \
168-
TOTP_SECRET="$TOTP_SECRET" \
169-
BROKER="$BROKER" \
170-
RELEASE="$RELEASE" \
171-
VNC_PORT="$VNC_PORT" \
172-
robot \
173-
--loglevel DEBUG \
174-
--pythonpath "${YARF_DIR}/yarf/rf_libraries/libraries/vnc" \
175-
--outputdir "${OUTPUT_DIR}" \
176-
"${ROBOT_ARGS[@]}" \
177-
"$@" \
178-
tests \
179-
|| test_result=$?
171+
env \
172+
E2E_USER="$E2E_USER" \
173+
E2E_PASSWORD="$E2E_PASSWORD" \
174+
TOTP_SECRET="$TOTP_SECRET" \
175+
BROKER="$BROKER" \
176+
RELEASE="$RELEASE" \
177+
VNC_PORT="$VNC_PORT" \
178+
SYSTEMD_SUPPORTS_VSOCK="${SYSTEMD_SUPPORTS_VSOCK:-}" \
179+
robot \
180+
--loglevel DEBUG \
181+
--pythonpath "${YARF_DIR}/yarf/rf_libraries/libraries/vnc" \
182+
--outputdir "${OUTPUT_DIR}" \
183+
"${ROBOT_ARGS[@]}" \
184+
"$@" \
185+
tests \
186+
|| test_result=$?
180187

181188
exit "${test_result:-0}"

authd-oidc-brokers/e2e-tests/vm/cloud-init-template-noble.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ write_files:
9494
9595
[Service]
9696
Type=simple
97-
ExecStart=/bin/bash -o pipefail -c 'journalctl -b --lines=all -o export -f | socat - VSOCK-CONNECT:2:55000'
97+
ExecStart=/bin/bash -o pipefail -c 'journalctl -b --lines=all -o export -f | socat - ${SOCAT_ADDRESS}'
9898
OOMScoreAdjust=-1000
9999
Restart=always
100100
RestartSec=1

authd-oidc-brokers/e2e-tests/vm/cloud-init-template-questing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ write_files:
6969
- path: /etc/systemd/journald.conf.d/00-forward-to-vsock.conf
7070
content: |
7171
[Journal]
72-
ForwardToSocket=vsock:2:55000
72+
ForwardToSocket=${JOURNAL_FORWARD_SOCKET}
7373
7474
runcmd:
7575
# Disable apport

authd-oidc-brokers/e2e-tests/vm/provision-ubuntu.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,21 @@ if [ ! -f "${CLOUD_INIT_ISO}" ]; then
146146
CLOUD_INIT_DIR="$(mktemp -d)"
147147
trap 'rm -rf ${CLOUD_INIT_DIR}' EXIT
148148

149+
systemd_ver=$(systemctl --version | awk 'NR==1 {print $2}')
150+
if dpkg --compare-versions "$systemd_ver" "ge" "256"; then
151+
JOURNAL_FORWARD_SOCKET="vsock:2:55000"
152+
SOCAT_ADDRESS="VSOCK-CONNECT:2:55000"
153+
else
154+
iface=$(virsh net-info default | awk '/Bridge:/ {print $2}')
155+
ip=$(ip -4 addr show "${iface}" | awk '/inet / {print $2}' | cut -d/ -f1)
156+
JOURNAL_FORWARD_SOCKET="${ip}:55000"
157+
SOCAT_ADDRESS="TCP:${ip}:55000"
158+
fi
159+
149160
SSH_PUBLIC_KEY=$(cat "${SSH_PUBLIC_KEY_FILE}") \
150-
envsubst < "${CLOUD_INIT_TEMPLATE}" > "${CLOUD_INIT_DIR}/user-data"
161+
JOURNAL_FORWARD_SOCKET="${JOURNAL_FORWARD_SOCKET}" \
162+
SOCAT_ADDRESS="${SOCAT_ADDRESS}" \
163+
envsubst < "${CLOUD_INIT_TEMPLATE}" > "${CLOUD_INIT_DIR}/user-data"
151164

152165
cloud-localds "${CLOUD_INIT_ISO}" "${CLOUD_INIT_DIR}/user-data"
153166
else

0 commit comments

Comments
 (0)