Skip to content

Commit ad8aa9f

Browse files
authored
Read AP and iperf3 server from database (#54)
1 parent bbecb63 commit ad8aa9f

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

.github/workflows/wireless-performance-autotest.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
jq '.results[] | select(.device_role.slug == "wifi-dut") | {
3131
name: .name,
3232
serial: .serial,
33+
site_id: (.site.id // empty),
3334
device_type: .device_type.model,
3435
device_class: .custom_fields.class,
3536
device_ip: .primary_ip.address
@@ -70,6 +71,35 @@ jobs:
7071
shell: bash
7172
run: |
7273
74+
# extract site ID
75+
SITE_ID=${{ matrix.json.site_id }}
76+
77+
# Fetch JSON from NetBox
78+
DATA=$(curl -s -H "Authorization: Token ${{ secrets.NETBOX_TOKEN }}" \
79+
-H "Accept: application/json; indent=4" \
80+
"https://stuff.armbian.com/netbox/api/dcim/sites/?limit=500&name__empty=false&id=${SITE_ID}")
81+
82+
count=$(echo "$DATA" | jq '.results | length')
83+
if [[ "$count" -eq 0 ]]; then
84+
echo "::error::Site id $SITE_ID not found in NetBox"
85+
exit 1
86+
fi
87+
88+
# Extract fields from the first (and only) result
89+
name=$(echo "$DATA" | jq -r '.results[0].name')
90+
location=$(echo "$DATA" | jq -r '.results[0].region.name')
91+
access_point=$(echo "$DATA" | jq -r '.results[0].custom_fields.access_point')
92+
access_point_password=$(echo "$DATA" | jq -r '.results[0].custom_fields.access_point_password')
93+
iperf_server=$(echo "$DATA" | jq -r '.results[0].custom_fields.iperf_server')
94+
95+
# Export to GitHub environment
96+
echo "SITE_NAME=$name" >> "$GITHUB_ENV"
97+
echo "SITE_LOCATION=$location" >> "$GITHUB_ENV"
98+
echo "ACCESS_POINT=$access_point" >> "$GITHUB_ENV"
99+
echo "ACCESS_POINT_PASSWORD=$access_point_password" >> "$GITHUB_ENV"
100+
echo "IPERF_SERVER=$iperf_server" >> "$GITHUB_ENV"
101+
echo "SITE_ID=$SITE_ID" >> "$GITHUB_ENV"
102+
73103
# extract IP address and device name
74104
DEVICE=wlx$(echo '${{ matrix.json.serial }}' | sed 's/://g')
75105
IP_ADDR=$(echo '${{ matrix.json.device_ip }}' | cut -d'/' -f1)
@@ -115,10 +145,10 @@ jobs:
115145
dhcp6: true
116146
macaddress: "${{ matrix.json.serial }}"
117147
access-points:
118-
"${ACCESS_POINT}":
148+
"${{ env.ACCESS_POINT }}":
119149
auth:
120150
key-management: "psk"
121-
password: "password"
151+
password: "${{ env.ACCESS_POINT_PASSWORD }}"
122152
EOT
123153
124154
- name: "Enable wireless adapter on ${{ env.IP_ADDR }}"
@@ -167,8 +197,8 @@ jobs:
167197
ssh ci@${{ env.IP_ADDR }} "sudo iw dev ${{ env.DEVICE }} link | tail -n +2 | sed 's/^\t*//' | head -n -3 | sed '1d'" > test/${{ env.DEVICE }}-info.log
168198
169199
# Run iperf test in both directions
170-
ssh ci@${{ env.IP_ADDR }} "iperf3 -R -c 10.0.60.10 -B ${{ env.CLIENTIP }}" > test/${{ env.DEVICE }}-tx.log
171-
ssh ci@${{ env.IP_ADDR }} "iperf3 -c 10.0.60.10 -B ${{ env.CLIENTIP }}" > test/${{ env.DEVICE }}-rx.log
200+
ssh ci@${{ env.IP_ADDR }} "iperf3 -R -c ${{ env.IPERF_SERVER }} -B ${{ env.CLIENTIP }}" > test/${{ env.DEVICE }}-tx.log
201+
ssh ci@${{ env.IP_ADDR }} "iperf3 -c ${{ env.IPERF_SERVER }} -B ${{ env.CLIENTIP }}" > test/${{ env.DEVICE }}-rx.log
172202
173203
# Extract the sender and receiver speeds
174204
tx_speed=$(cat test/${{ env.DEVICE }}-tx.log | grep "sender" | awk '{print $7}')

0 commit comments

Comments
 (0)