[Fuego] [PATCH v2] iperf: Add test cases for command iperf.

Tim.Bird at sony.com Tim.Bird at sony.com
Wed Apr 17 05:08:59 UTC 2019


Thank you for submitting this patch.

See comments inline below.

> -----Original Message-----
> From: Wang Mingyu
> 
> This test set is used to check if the network connection is OK when iperf is
> started with server mode and client mode.
> 
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
>  tests/Functional.iperf/fuego_test.sh          | 17 +++++++++++++++++
>  tests/Functional.iperf/iperf_test.sh          |  4 ++++
>  tests/Functional.iperf/parser.py              | 20 ++++++++++++++++++++
>  tests/Functional.iperf/spec.json              |  6 ++++++
>  tests/Functional.iperf/tests/iperf_help.sh    | 13 +++++++++++++
>  tests/Functional.iperf/tests/iperf_server1.sh | 26
> ++++++++++++++++++++++++++
>  tests/Functional.iperf/tests/iperf_server2.sh | 18 ++++++++++++++++++
>  tests/Functional.iperf/tests/iperf_server3.sh | 22
> ++++++++++++++++++++++
>  tests/Functional.iperf/tests/iperf_server4.sh | 22
> ++++++++++++++++++++++
>  tests/Functional.iperf/tests/iperf_server5.sh | 20 ++++++++++++++++++++
>  tests/Functional.iperf/tests/iperf_server6.sh | 23
> +++++++++++++++++++++++
>  tests/Functional.iperf/tests/iperf_version.sh | 13 +++++++++++++
>  12 files changed, 204 insertions(+)
>  create mode 100644 tests/Functional.iperf/fuego_test.sh
>  create mode 100755 tests/Functional.iperf/iperf_test.sh
>  create mode 100644 tests/Functional.iperf/parser.py
>  create mode 100644 tests/Functional.iperf/spec.json
>  create mode 100644 tests/Functional.iperf/tests/iperf_help.sh
>  create mode 100644 tests/Functional.iperf/tests/iperf_server1.sh
>  create mode 100644 tests/Functional.iperf/tests/iperf_server2.sh
>  create mode 100644 tests/Functional.iperf/tests/iperf_server3.sh
>  create mode 100644 tests/Functional.iperf/tests/iperf_server4.sh
>  create mode 100644 tests/Functional.iperf/tests/iperf_server5.sh
>  create mode 100644 tests/Functional.iperf/tests/iperf_server6.sh
>  create mode 100644 tests/Functional.iperf/tests/iperf_version.sh
> 
> diff --git a/tests/Functional.iperf/fuego_test.sh
> b/tests/Functional.iperf/fuego_test.sh
> new file mode 100644
> index 0000000..cd42c0c
> --- /dev/null
> +++ b/tests/Functional.iperf/fuego_test.sh

This test should probably be called Functional.iperf3_server, as it tests
server functionality.  We already have Functional.iperf3 for clien-only tests
of network performance.

> @@ -0,0 +1,17 @@
> +function test_pre_check {
> +    assert_has_program iperf3

should check for 'netstat' here also.

> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/iperf_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
> +    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
> +}
> +
> +function test_run {
> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> +    ./iperf_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/tests/Functional.iperf/iperf_test.sh
> b/tests/Functional.iperf/iperf_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/tests/Functional.iperf/iperf_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> diff --git a/tests/Functional.iperf/parser.py
> b/tests/Functional.iperf/parser.py
> new file mode 100644
> index 0000000..f25a608
> --- /dev/null
> +++ b/tests/Functional.iperf/parser.py
> @@ -0,0 +1,20 @@
> +#!/usr/bin/python
> +# See common.py for description of command-line arguments
> +
> +import os, sys, collections
> +import common as plib
> +
> +measurements = {}
> +measurements = collections.OrderedDict()
> +
> +regex_string = '^ -> (.*): TEST-(.*)$'
> +matches = plib.parse_log(regex_string)
> +
> +if matches:
> +    for m in matches:
> +        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
> +
> +# split the output for each testcase
> +plib.split_output_per_testcase(regex_string, measurements)
> +
> +sys.exit(plib.process(measurements))
> diff --git a/tests/Functional.iperf/spec.json
> b/tests/Functional.iperf/spec.json
> new file mode 100644
> index 0000000..cb5fec8
> --- /dev/null
> +++ b/tests/Functional.iperf/spec.json
> @@ -0,0 +1,6 @@
> +{
> +    "testName": "Functional.iperf",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> diff --git a/tests/Functional.iperf/tests/iperf_help.sh
> b/tests/Functional.iperf/tests/iperf_help.sh
> new file mode 100644
> index 0000000..8c3c629
> --- /dev/null
> +++ b/tests/Functional.iperf/tests/iperf_help.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +#  Test command iperf3 on target.
> +#  Opiton : --help
'Opiton' should be changed to 'Option' throughout all tests.

> +
> +test="help"
> +
> +if iperf3 --help | grep "Usage"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/tests/Functional.iperf/tests/iperf_server1.sh
> b/tests/Functional.iperf/tests/iperf_server1.sh
> new file mode 100644
> index 0000000..6431159
> --- /dev/null
> +++ b/tests/Functional.iperf/tests/iperf_server1.sh
> @@ -0,0 +1,26 @@
> +#!/bin/sh
> +
> +#  Test command iperf3 on target.
> +#  Opiton : server(TCP)
Opiton -> Option

> +
> +test="server1"
> +
> +killall -KILL iperf3
> +iperf3 -s -D&
> +
> +sleep 10
> +
> +ls .
> +netstat -l > iperf-test
> +
> +sleep 10

Why is this sleep needed?

> +
> +if cat iperf-test | grep "5201"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +
> +killall -KILL iperf3
> +rm -f iperf-test
> diff --git a/tests/Functional.iperf/tests/iperf_server2.sh
> b/tests/Functional.iperf/tests/iperf_server2.sh
> new file mode 100644
> index 0000000..2e87a6f
> --- /dev/null
> +++ b/tests/Functional.iperf/tests/iperf_server2.sh
> @@ -0,0 +1,18 @@
> +#!/bin/sh
> +
> +#  Test command iperf3 on target.
> +#  Opiton : server(UDP)
Opiton -> Option
> +
> +test="server2"
'server2' is not very descriptive.  "server_UDP" would be better
> +
> +killall -KILL iperf3
> +iperf3 -s -D
> +
> +if netstat -l | grep "5201"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +
> +killall -KILL iperf3
> diff --git a/tests/Functional.iperf/tests/iperf_server3.sh
> b/tests/Functional.iperf/tests/iperf_server3.sh
> new file mode 100644
> index 0000000..fd65fd1
> --- /dev/null
> +++ b/tests/Functional.iperf/tests/iperf_server3.sh
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +
> +#  Test command iperf3 on target.
> +#  Opiton : server(TCP port 6000)
> +
> +test="server3"
> +
> +killall -KILL iperf3
> +
> +expect <<-EOF
> +spawn iperf3 -s -p 6000&
> +expect {
> + -re ".*Server listening on 6000.*" {
> +           send_user " -> $test: TEST-PASS\n"
> +          }
> + default { send_user " -> $test: TEST-FAIL\n" }  }
> +send "\n"
> +expect eof
> +EOF
> +
Can this be converted to something that doesn't use 'expect'?

Maybe like this:

iperf3 -s -p 6000 >iperf.log &
killall iperf3
if grep "Server listening on 6000" iperf.log ; then
   echo $test: TEST-PASS
else
   echo $test: TEST-FAIL
fi

> +killall -KILL iperf3
> +
> diff --git a/tests/Functional.iperf/tests/iperf_server4.sh
> b/tests/Functional.iperf/tests/iperf_server4.sh
> new file mode 100644
> index 0000000..fcc6d55
> --- /dev/null
> +++ b/tests/Functional.iperf/tests/iperf_server4.sh
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +
> +#  Test command iperf3 on target.
> +#  Opiton : -c
Opiton -> Option

> +
> +test="server4"
> +
> +killall -KILL iperf3
> +iperf3 -s -D&
> +
> +iperf3 -c 127.0.0.1 > log
> +sleep 5
> +
> +if cat log | grep "connected"

This can be:
grep "connected" log

> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +
> +killall -KILL iperf3
> +rm log
> diff --git a/tests/Functional.iperf/tests/iperf_server5.sh
> b/tests/Functional.iperf/tests/iperf_server5.sh
> new file mode 100644
> index 0000000..6082e6c
> --- /dev/null
> +++ b/tests/Functional.iperf/tests/iperf_server5.sh
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +
> +#  Test command iperf3 on target.
> +#  Opiton : -c (UDP)
Opiton -> Option:

> +
> +test="server5"
> +
> +killall -KILL iperf3
> +iperf3 -s -D&
> +
> +sleep 3
> +
> +if iperf3 -c 127.0.0.1 -u | grep "connected"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +
> +killall -KILL iperf3
> diff --git a/tests/Functional.iperf/tests/iperf_server6.sh
> b/tests/Functional.iperf/tests/iperf_server6.sh
> new file mode 100644
> index 0000000..247a22e
> --- /dev/null
> +++ b/tests/Functional.iperf/tests/iperf_server6.sh
> @@ -0,0 +1,23 @@
> +#!/bin/sh
> +
> +#  Test command iperf3 on target.
> +#  Opiton : -c(port opt)
Opiton -> Option

> +
> +test="server6"
> +
> +killall -KILL iperf3
> +iperf3 -s -D -p 6000&
> +
> +expect <<-EOF
> +spawn iperf3 -c 127.0.0.1 -p 6000&
> +expect {
> + -re ".*connected.*" {
> +           send_user " -> $test: TEST-PASS\n"
> +          }
> + default { send_user " -> $test: TEST-FAIL\n" }  }
> +send "\n"
> +expect eof
> +EOF

Can this be converted to something that doesn't use 'expect'?

> +
> +killall -KILL iperf3
> +rm log
> diff --git a/tests/Functional.iperf/tests/iperf_version.sh
> b/tests/Functional.iperf/tests/iperf_version.sh
> new file mode 100644
> index 0000000..3ab66a4
> --- /dev/null
> +++ b/tests/Functional.iperf/tests/iperf_version.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +#  Test command iperf3 on target.
> +#  Opiton : version
Opiton -> Option

> +
> +test="version"
> +
> +if iperf3 --version | grep "iperf 3.*"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> --
> 1.8.3.1

Please address my comments and re-submit.

Thanks,
 -- Tim



More information about the Fuego mailing list