Merge ~liaou3/checkbox-iiotg/+git/checkbox-provider-intliotg:refactor_tsn_time_based_shaper into ~checkbox-dev/checkbox-iiotg/+git/checkbox-provider-intliotg:master

Proposed by Vincent Liao
Status: Merged
Approved by: Vincent Liao
Approved revision: 5b5f4bc62db58dfc6467fb0db54023edf72cc15e
Merged at revision: ca7f0efaca94ef2b5ab7d6f5120fb4b4353d6260
Proposed branch: ~liaou3/checkbox-iiotg/+git/checkbox-provider-intliotg:refactor_tsn_time_based_shaper
Merge into: ~checkbox-dev/checkbox-iiotg/+git/checkbox-provider-intliotg:master
Diff against target: 114 lines (+55/-13)
3 files modified
bin/tsn_time_based_shaper.sh (+49/-0)
units/tsn/jobs.pxu (+5/-12)
units/tsn/test-plan.pxu (+1/-1)
Reviewer Review Type Date Requested Status
Patrick Liu (community) Approve
Rick Wu Approve
PeiYao Chang Needs Fixing
StanleyHuang Pending
Review via email: mp+455032@code.launchpad.net

Commit message

Modify: Make time based shaper automated

To post a comment you must log in.
Revision history for this message
PeiYao Chang (baconyao) wrote :

Please see my in-line comment

review: Needs Fixing
Revision history for this message
Vincent Liao (liaou3) wrote :

@baconyao
Please see my reply

Revision history for this message
Rick Wu (rickwu4444) wrote :

LGTM

review: Approve
Revision history for this message
Patrick Liu (patliu) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/tsn_time_based_shaper.sh b/bin/tsn_time_based_shaper.sh
2new file mode 100755
3index 0000000..6106700
4--- /dev/null
5+++ b/bin/tsn_time_based_shaper.sh
6@@ -0,0 +1,49 @@
7+#!/bin/bash
8+
9+set -e
10+
11+timeout=$1
12+eth_interface=$2
13+server_user=$3
14+server_ip=$4
15+server_pwd=$5
16+server_eth_interface=$6
17+
18+echo "## Clearing previous queue discipline configuration..."
19+echo "## You will get errors if there's no previous configuration, but you could ignore it."
20+tc qdisc del dev "$eth_interface" root || true
21+echo ""
22+
23+echo "## Setting time schedule..."
24+tc qdisc add dev "$eth_interface" handle 8001: parent root mqprio num_tc 4 map 0 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 queues 1@0 1@1 1@2 1@3 hw 0
25+tc qdisc replace dev "$eth_interface" parent 8001:4 etf offload clockid CLOCK_TAI delta 500000
26+echo ""
27+
28+echo "## Showing qdisc settings..."
29+tc qdisc show dev "$eth_interface"
30+echo ""
31+
32+echo "## Start sending and receiving udp packets..."
33+out=$(mktemp)
34+timeout "$timeout" udp_tai -c 3 -i "$eth_interface" -P 1000000 -p 90 -d 600000 > /dev/null &
35+(sshpass -p "u" ssh -o StrictHostKeyChecking=no "$server_user"@"$server_ip" "echo $server_pwd | sudo -S tcpdump -G $timeout -Q in -ttt -ni $server_eth_interface --time-stamp-precision=nano -j adapter_unsynced port 7788 -c 20000") | tee "$out"
36+
37+echo "## Checking result..."
38+lines=$(tail -n 10000 "$out")
39+count=0
40+while read -r line
41+do
42+ interval=$(echo "$line" | awk '{print $1}' | awk -F "." '{print $2}')
43+ if [ "$interval" -gt 1000500 ] || [ "$interval" -lt 999500 ]; then
44+ count=$((count+1))
45+ fi
46+done <<< "$lines"
47+
48+echo "In the last 10000 packets there are $count packets are not within 1000000+/-500 ns interval."
49+echo "Pass condition: Less than 5% packets not within the required interval"
50+if [ $count -lt 500 ]; then
51+ echo "PASS"
52+else
53+ echo "FAIL"
54+ exit 1
55+fi
56diff --git a/units/tsn/jobs.pxu b/units/tsn/jobs.pxu
57index de2cbae..719da83 100644
58--- a/units/tsn/jobs.pxu
59+++ b/units/tsn/jobs.pxu
60@@ -267,13 +267,14 @@ command:
61 unit: template
62 template-resource: tsn/tsn-devices
63 template-unit: job
64-id: tsn/time-based-shaping/udp-packet-time-check-{interface}
65+template-engine: jinja2
66+id: tsn/time-based-shaping/udp-packet-time-check-{{ interface }}
67 category_id: tsn
68-_summary: Check the packet time intervals
69+_summary: UDP packet time intervals check
70 depends:
71 tsn/tsn-detected
72 tsn/testing-snap-install-check
73-plugin: user-interact-verify
74+plugin: shell
75 user: root
76 _purpose:
77 To check if the system can transmit udp packet precisely at 1 ms intervals
78@@ -283,15 +284,7 @@ environ:
79 TSN_SERVER_PWD
80 TSN_SERVER_INTERFACE
81 command:
82- tc qdisc del dev {interface} root
83- tc qdisc add dev {interface} handle 8001: parent root mqprio num_tc 4 map 0 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 queues 1@0 1@1 1@2 1@3 hw 0
84- tc qdisc replace dev {interface} parent 8001:4 etf offload clockid CLOCK_TAI delta 500000
85- tc qdisc show dev {interface}
86- timeout 30 udp_tai -c 3 -i {interface} -P 1000000 -p 90 -d 600000 > /dev/null &
87- timeout 30 sshpass -p "u" ssh -o StrictHostKeyChecking=no "$TSN_SERVER_USER"@"$TSN_SERVER_IP" "echo "$TSN_SERVER_PWD" | sudo -S tcpdump -Q in -ttt -ni "$TSN_SERVER_INTERFACE" --time-stamp-precision=nano -j adapter_unsynced port 7788 -c 20000"
88-_verification:
89- Is the packets are being transmitted every 1000000ns (+/-500ns)?
90- If > 95% of packets match this criteria the test is successful.
91+ tsn_time_based_shaper.sh 30 {{ interface }} "$TSN_SERVER_USER" "$TSN_SERVER_IP" "$TSN_SERVER_PWD" "$TSN_SERVER_INTERFACE"
92
93 unit: template
94 template-resource: tsn/tsn-devices
95diff --git a/units/tsn/test-plan.pxu b/units/tsn/test-plan.pxu
96index 025bb18..3978ad2 100644
97--- a/units/tsn/test-plan.pxu
98+++ b/units/tsn/test-plan.pxu
99@@ -18,7 +18,6 @@ include:
100 tsn/test-env-setup-for-.*
101 tsn/testing-snap-install-check
102 nested_part:
103- tsn-time-based-shaping
104 tsn-ieee802.1qbv
105
106 id: tsn-automated
107@@ -34,6 +33,7 @@ nested_part:
108 tsn-ieee802.1as-2011
109 tsn-ieee802.1qav
110 tsn-ieee802.1qbu
111+ tsn-time-based-shaping
112
113 id: tsn-ieee802.1as-2011
114 _name: Time Sensitive Networking Test Plan for IEEE 802.1AS-2011

Subscribers

People subscribed via source and target branches