Skip to content

Commit 7c3f889

Browse files
chase-qimwasilew
authored and
mwasilew
committed
linux: add fuego multinode
Signed-off-by: Chase Qi <chase.qi@linaro.org>
1 parent 75afd5b commit 7c3f889

8 files changed

+302
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
inherit "base-board"
2+
include "base-params"
3+
4+
MACHINE=generic-arm64
5+
6+
TRANSPORT="ssh"
7+
IPADDR="dut_ipaddr"
8+
SSH_PORT="22"
9+
LOGIN="root"
10+
SSH_KEY="/fuego-rw/ssh_keys/fuego-lava"
11+
# PASSWORD="fuegotest"
12+
BOARD_TESTDIR="/root/"
13+
14+
TOOLCHAIN="arm64"
15+
ARCHITECTURE="arm64"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
inherit "base-board"
2+
include "base-params"
3+
4+
MACHINE=generic-armhf
5+
6+
TRANSPORT="ssh"
7+
IPADDR="dut_ipaddr"
8+
SSH_PORT="22"
9+
LOGIN="root"
10+
SSH_KEY="/fuego-rw/ssh_keys/fuego-lava"
11+
# PASSWORD="fuegotest"
12+
BOARD_TESTDIR="/root/"
13+
14+
TOOLCHAIN="debian-armhf"
15+
ARCHITECTURE="arm"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
inherit "base-board"
2+
include "base-params"
3+
4+
MACHINE=generic-x86_64
5+
6+
TRANSPORT="ssh"
7+
IPADDR="dut_ipaddr"
8+
SSH_PORT="22"
9+
LOGIN="root"
10+
SSH_KEY="/fuego-rw/ssh_keys/fuego-lava"
11+
# PASSWORD="fuegotest"
12+
BOARD_TESTDIR="/root/"
13+
14+
TOOLCHAIN="x86_64"
15+
ARCHITECTURE="x86_64"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
metadata:
2+
format: Lava-Test Test Definition 1.0
3+
name: fuego-dut
4+
description: "Run fuego tests with LAVA. Refer to http://fuegotest.org/"
5+
maintainer:
6+
- chase.qi@linaro.org
7+
os:
8+
- debian
9+
scope:
10+
- functional
11+
devices:
12+
- rpi3-b-32
13+
- beaglebone-black
14+
15+
params:
16+
INTERFACE: "eth0"
17+
18+
run:
19+
steps:
20+
- cd ./automated/linux/fuego-multinode/
21+
- lava-wait ssh-pub-key
22+
- ./setup-openssh-server.sh || sleep 3600
23+
- lava-send dut-ready ipaddr=$(lava-echo-ipv4 ${INTERFACE})
24+
- lava-wait host-done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
metadata:
2+
format: Lava-Test Test Definition 1.0
3+
name: fuego-host
4+
description: "Run fuego tests with LAVA. Refer to http://fuegotest.org/"
5+
maintainer:
6+
- chase.qi@linaro.org
7+
os:
8+
- debian
9+
scope:
10+
- functional
11+
devices:
12+
- docker
13+
14+
params:
15+
BOARD: "generic-armhf"
16+
TOOLCHAIN: "armhf"
17+
TEST: "Functional.hello_world"
18+
SPEC: "default"
19+
# arm64, armhf and x86_64 toolchains are included in fuego docker image
20+
# already, skip toolchain installation by default.
21+
# Refer to the below docker image description for build instructions:
22+
# https://cloud.docker.com/repository/docker/chaseqi/standalone-fuego
23+
SKIP_INSTALL: "true"
24+
# The following variables just work when only one test action defined in
25+
# LAVA test job. When more then one test defined:
26+
# Set WAIT_DUT to "true" for the first test and "false" for the rest tests.
27+
# Set HOST_DONE to "true" for the last test and "false" for the rest tests.
28+
WAIT_DUT: "true"
29+
HOST_DONE: "true"
30+
31+
run:
32+
steps:
33+
# Sent host-done signal on non-zero exit.
34+
- trap 'lava-send host-done' ERR
35+
- |
36+
# When more then on test defined, only send ssh pub key once.
37+
if [ -f /fuego-rw/ssh_keys/fuego-lava ]; then
38+
echo "SSH key pairs should be set already."
39+
else
40+
mkdir -p /fuego-rw/ssh_keys
41+
ssh-keygen -t rsa -N "" -f /fuego-rw/ssh_keys/fuego-lava -C fuego-lava
42+
# Message sent by lava-send is visible, when security is a
43+
# concern, job visibility should be set to private/group.
44+
lava-send ssh-pub-key pub_key=$(cat /fuego-rw/ssh_keys/fuego-lava.pub | awk '{print $2}')
45+
fi
46+
- cd ./automated/linux/fuego-multinode/
47+
- if "${WAIT_DUT}"; then lava-wait dut-ready; fi
48+
- ./fuego.sh -b "${BOARD}" -c "${TOOLCHAIN}" -t "${TEST}" -s "${SPEC}" -S "${SKIP_INSTALL}" || ret_val=$?
49+
- ../../utils/send-to-lava.sh ./output/result.txt
50+
- if "${HOST_DONE}"; then lava-send host-done; fi
51+
- if [ -n "${ret_val}" ] && [ "${ret_val}" -ne 0 ]; then exit 1; fi
+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/sh -ex
2+
3+
TEST_DIR=$(dirname "$(realpath "$0")")
4+
OUTPUT="${TEST_DIR}/output"
5+
RESULT_FILE="${OUTPUT}/result.txt"
6+
export RESULT_FILE
7+
BOARD="generic-armhf"
8+
TOOLCHAIN="armhf"
9+
TEST="Functional.hello_world"
10+
SPEC="default"
11+
SKIP_INSTALL="false"
12+
13+
usage() {
14+
echo "Usage: $0 [-b BOARD] [-c TOOLCHAIN] [-t TEST] [-s SPEC] [-S SKIP_INSTALL]" 1>&2
15+
exit 1
16+
}
17+
18+
while getopts "b:c:t:s:S:h" o; do
19+
case "$o" in
20+
b) BOARD="${OPTARG}" ;;
21+
c) TOOLCHAIN="${OPTARG}" ;;
22+
t) TEST="${OPTARG}" ;;
23+
s) SPEC="${OPTARG}" ;;
24+
S) SKIP_INSTALL="${OPTARG}" ;;
25+
h|*) usage ;;
26+
esac
27+
done
28+
29+
# shellcheck disable=SC1090
30+
. "${TEST_DIR}/../../lib/sh-test-lib"
31+
create_out_dir "${OUTPUT}"
32+
33+
# Install toolchain.
34+
# Refer to http://fuegotest.org/wiki/Adding_a_toolchain for supported
35+
# toolchains by the following installer.
36+
if [ "${SKIP_INSTALL}" = "true" ] || [ "${SKIP_INSTALL}" = "True" ]; then
37+
info_msg "Toolchain ${TOOLCHAIN} installation skipped."
38+
else
39+
/fuego-ro/toolchains/install_cross_toolchain.sh "${TOOLCHAIN}"
40+
fi
41+
42+
# Add board configuration.
43+
# FIXME: changes in LAVA are required to support additional docker run params.
44+
# fuego uses '--net="host"' to make fuego host accessible for DUT. The feature
45+
# is required by networking tests like NetPIPE, iperf, netperf
46+
dut_ipaddr=$(grep "ipaddr" /tmp/lava_multi_node_cache.txt | awk -F"=" '{print $NF}')
47+
board_config="/fuego-ro/boards/${BOARD}.board"
48+
if [ -f "${board_config}" ] && grep "${dut_ipaddr}" "${board_config}"; then
49+
info_msg "Board configuration already added."
50+
else
51+
sed -i "s/dut_ipaddr/${dut_ipaddr}/" "boards/${BOARD}.board"
52+
cp "boards/${BOARD}.board" /fuego-ro/boards/
53+
cat "/fuego-ro/boards/${BOARD}.board"
54+
fi
55+
56+
# Set proper permissions.
57+
chown -R jenkins.jenkins /fuego-rw/
58+
chown -R jenkins.jenkins /fuego-ro/
59+
60+
# Add Jenkins node.
61+
# Give Jenkins time to start.
62+
sleep 30
63+
if ftc list-nodes | grep "${BOARD}"; then
64+
info_msg "Node ${BOARD} already added."
65+
else
66+
ftc add-nodes -b "${BOARD}" -f
67+
fi
68+
69+
# Add test job.
70+
if ftc list-jobs | grep "${BOARD}.${SPEC}.${TEST}"; then
71+
info_msg "Test job ${BOARD}.${SPEC}.${TEST} already added."
72+
else
73+
ftc add-job -b "${BOARD}" -t "${TEST}" -s "${SPEC}"
74+
fi
75+
76+
# Run test as user jenkins.
77+
# timeout will be handled by LAVA. Set a super long time here.
78+
# TODO: support dynamic-vars
79+
ret_val=0
80+
sudo -u jenkins ftc run-test -b "${BOARD}" -t "${TEST}" -s "${SPEC}" \
81+
--precleanup true \
82+
--postcleanup false \
83+
--rebuild false \
84+
--reboot false \
85+
--timeout 1d || ret_val=$?
86+
87+
# Parse result file run.json.
88+
log_dir=$(find "/fuego-rw/logs/${TEST}/${BOARD}.${SPEC}"* -maxdepth 0 -type d | sort | tail -n 1)
89+
python "${TEST_DIR}/parser.py" -s "${log_dir}/run.json" -d "${RESULT_FILE}"
90+
91+
if [ "${ret_val}" -ne 0 ]; then
92+
exit 1
93+
else
94+
exit 0
95+
fi
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python
2+
import argparse
3+
import json
4+
import os
5+
import subprocess
6+
import sys
7+
8+
parser = argparse.ArgumentParser()
9+
parser.add_argument('-s', '--source', dest='source', required=True,
10+
help='path to fuego test result file run.json.')
11+
parser.add_argument('-d', '--dest', dest='dest', required=True,
12+
help='Path to plain test result file result.txt.')
13+
args = parser.parse_args()
14+
15+
with open(args.source) as f:
16+
data = json.load(f)
17+
18+
if 'test_sets' not in data.keys():
19+
print('test_sets NOT found in {}'.format(run_json))
20+
sys.exit(1)
21+
22+
result_lines = []
23+
for test_set in data['test_sets']:
24+
result_lines.append('lava-test-set start {}'.format(test_set['name']))
25+
26+
for test_case in test_set['test_cases']:
27+
# Functional
28+
result_line = '{} {}'.format(test_case['name'],
29+
test_case['status'].lower())
30+
result_lines.append(result_line)
31+
32+
# Benchmark
33+
if test_case.get('measurements'):
34+
for measurement in test_case['measurements']:
35+
# Use test_case_name plus measurement name as test_case_id so
36+
# that it is readable and unique.
37+
result_line = '{}_{} {} {} {}'.format(test_case['name'],
38+
measurement['name'],
39+
measurement['status'].lower(),
40+
measurement['measure'],
41+
measurement.get('unit', ''))
42+
result_lines.append(result_line)
43+
44+
result_lines.append('lava-test-set stop {}'.format(test_set['name']))
45+
46+
with open(args.dest, 'w') as f:
47+
for result_line in result_lines:
48+
print(result_line)
49+
f.write('{}\n'.format(result_line))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh -ex
2+
3+
TEST_DIR=$(dirname "$(realpath "$0")")
4+
# shellcheck disable=SC1090
5+
. "${TEST_DIR}/../../lib/sh-test-lib"
6+
7+
# On unsupported distros, installation will be skipped by default.
8+
install_deps openssh-server
9+
10+
# Add id_rsa.pub key sent by host to authorized_keys.
11+
pub_key=$(grep "pub_key" /tmp/lava_multi_node_cache.txt | awk -F"=" '{print $NF}')
12+
mkdir -p ~/.ssh/
13+
echo "ssh-rsa ${pub_key} fuego-lava" > ~/.ssh/authorized_keys
14+
chmod 600 ~/.ssh/authorized_keys
15+
16+
# Enabled root login.
17+
if ! grep "^PermitRootLogin yes" /etc/ssh/sshd_config; then
18+
# Enable root login.
19+
sed -i 's/^# *PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
20+
sed -i 's/^ *PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
21+
22+
# Restart ssh.
23+
dist_name
24+
# shellcheck disable=SC2154
25+
case "${dist}" in
26+
debian|ubuntu|fedora|centos)
27+
systemctl restart ssh
28+
systemctl status ssh
29+
;;
30+
*)
31+
warning_msg "Unknown distro: ${dist}, attempting to restart ssh..."
32+
/etc/init.d/ssh restart || true
33+
service ssh restart || true
34+
;;
35+
esac
36+
sleep 3
37+
fi
38+

0 commit comments

Comments
 (0)