Hi Alan,

I'm afraid you missed the mailing list. :)

Finally I have managed to show the measurement in LAVA, though the unit is still missing:

https://validation.linaro.org/dashboard/streams/anonymous/botao-sun/bundles/4204e7fc38e9c65e7ef8bff5bc3b9de2a50ba8db/bec2005b-771c-4307-9b54-6e213f894533/

https://validation.linaro.org/dashboard/attachment/791281/view

I tested the regular expression on a website and locally, it works well on both, for example:

1. Tested on a third-party website:
https://pythex.org/?regex=^%28%3FP%3Ctest_case_id%3Efio_\w%2B%29%3A\s%28%3FP%3Cresult%3E\w%2B%29\s%28%3FP%3Cmeasurement%3E[0-9.]%2B%29\s%28%3FP%3Cunits%3E\w%2B%29.*&test_string=fio_read%3A%20PASS%201105%20IOPS%0Afio_read%3A%20PASS%200%20NA%0Afio_read%3A%20FAIL%200%20NA%20-%20Command%20ran%20failed%20on%20%2Fdev%2Fsda&ignorecase=0&multiline=1&dotall=0&verbose=0

2. Tested locally:

#!/usr/bin/env python
import re

test_string_pass = testcase_name + ": PASS" + " " + iops_result + " " + "IOPS"
print test_string_pass
test_string_pass_simple = testcase_name + ": PASS" + " 0" + " NA"
print test_string_pass_simple
test_string_fail = testcase_name + ": FAIL" + " 0" + " NA" + " - Command ran failed on /dev/sda"
print test_string_fail

pattern = '^(?P<test_case_id>fio_\w+):\s(?P<result>\w+)\s(?P<measurement>[0-9.]+)\s(?P<units>\w+).*'

print re.findall(pattern, test_string_pass)
print re.findall(pattern, test_string_pass_simple)
print re.findall(pattern, test_string_fail)

The output is:

fio_read: PASS 1105 IOPS
fio_read: PASS 0 NA
fio_read: FAIL 0 NA - Command ran failed on /dev/sda
[('fio_read', 'PASS', '1105', 'IOPS')]
[('fio_read', 'PASS', '0', 'NA')]
[('fio_read', 'FAIL', '0', 'NA')]

As you can see all four groups are captured there.

Any idea?

Thanks.


Best Regards
Botao Sun


On 14 May 2014 04:57, Alan Bennett <alan.bennett@linaro.org> wrote:
Hi Botao;

  I've had the most luck using the lava test shell api "lava-test-case", have you tried it?

Senthil/LAVA team, do we have some examples of using parsers and measurements?

Alan

lava-test-case test5 --result pass --measurement 99 --units bottles
Documentation: 
https://validation.linaro.org/static/docs/writing-tests.html?recording-test-case-measurements-and-units#recording-test-case-measurements-and-units
  

---------- Forwarded message ----------
From: Botao Sun <botao.sun@linaro.org>
Date: 13 May 2014 06:52
Subject: [Linaro-validation] Measurement in LAVA.
To: Linaro Validation <linaro-validation@lists.linaro.org>


Hi,

I'm recently working on some test cases which involve the measurement, but have no idea how to handle it after several failures occurred. For example:

https://validation.linaro.org/scheduler/job/126298

<LAVA_SIGNAL_STARTRUN fio-ubuntu db652397-5831-4cc3-b2b3-1246879ac696>
echo LAVA_ACK
/root
test_case_id:fio_device_existence result:PASS
which fio
The FIO binary location is: /usr/bin/fio
test_case_id:fio_existence result:PASS
sudo fio -filename=/dev/sda -rw=read -direct=1 -iodepth 1 -thread -ioengine=psync -bs=4k -numjobs=1 -runtime=10 -group_reporting -name=fio_read > fio_read.txt 2>&1
0
The IOPS number in fio_read test is: 1104
test_case_id:fio_read result:PASS measurement:1104 units:persecond
<LAVA_SIGNAL_ENDRUN fio-ubuntu db652397-5831-4cc3-b2b3-1246879ac696>
<LAVA_DISPATCHER>2014-05-13 12:30:39 PM WARNING: Invalid measurement
<LAVA_DISPATCHER>2014-05-13 12:30:39 PM WARNING: Invalid measurement

The regular expression I'm using is:

"^test_case_id:(?P<test_case_id>fio_\\w+)\\sresult:(?P<result>(PASS|FAIL))\\s*(measurement:)*(?P<measurement>\\d*)\\s*(units:)*(?P<units>\\s*)\\s*"

which if convert it to a solid one would be:

"^test_case_id:fio_\w+\sresult:(PASS|FAIL)\s*(measurement:)*\d*\s*(units:)*\s*\s*"

And it has been tested locally which can capture following 3 different results (sample):

test_case_id:fio_read result:PASS measurement:1105 units:persecond
test_case_id:fio_read result:PASS
test_case_id:fio_read result:FAIL - Command ran failed on /dev/sda

A local test script in Python is:

#!/usr/bin/env python
import re

pattern_solid = "^test_case_id:fio_\w+\sresult:(PASS|FAIL)\s*(measurement:)*\d*\s*(units:)*\s*\s*"
testcase_name = "fio_read"
iops_result = "1105"

test_string_pass = "test_case_id:" + testcase_name + " result:PASS " + "measurement:" + iops_result + " units:persecond"
test_string_pass_simple = "test_case_id:" + testcase_name + " result:PASS"
test_string_fail = "test_case_id:" + testcase_name + " result:FAIL" + " - Command ran failed on /dev/sda"

print re.search(pattern_solid, test_string_pass)
print re.search(pattern_solid, test_string_pass_simple)
print re.search(pattern_solid, test_string_fail)

So would you provide an example about how to deal with the measurement in LAVA?

Thanks.


Best Regards
Botao Sun

_______________________________________________
linaro-validation mailing list
linaro-validation@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-validation




--

Alan Bennett, Engineering Manager, LAVA & LSK
Linaro.org │ Open source software for ARM SoCs | Follow Linaro: Facebook | Twitter | Blog
irc: akbennett | alan.bennett@linaro.org | linaro-validation@lists.linaro.org