git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH 3/3] trace2: add a schema validator for trace2 events

From
Josh Steadmon <steadmon@google.com>
Date
Jun 20, 2019, 18:15 UTC
Message-ID
<20190620181536.GE42943@google.com>
In-Reply-To
<20190612191818.GB14949@sigill.intra.peff.net>
On 2019.06.12 15:18, Jeff King wrote:
Show 33 quoted lines
> On Wed, Jun 12, 2019 at 09:23:41AM -0700, Josh Steadmon wrote:
> 
> > The problem with the existing validators is that they expect each file to be a
> > complete JSON entity, whereas the trace output is one object per line. You can
> > of course loop over the lines in a shell script, but in my testing this approach
> > took multiple hours on the full test suite trace output, vs. 15 minutes for the
> > implementation in this patch.
> 
> It seems like it should be easy to turn a sequence of entities into a
> single entity, with something like:
> 
>   echo '['
>   sed 's/$/,/' <one-per-line
>   echo ']'
> 
> You could even turn a sequence of files into a single entity (which
> might be even faster to validate, since it would be one invocation for
> the entire test suite) with something like:
> 
>   echo '{'
>   for fn in $FILES; do
> 	echo "\"$fn\": "
> 	cat $fn
> 	echo ","
>   done
>   echo '}'
> 
> though I suspect the resulting error messages might not be as good.
> 
> Obviously neither of those is particularly robust if the individual JSON
> is not well-formed. But then, if we are mostly interested in testing
> whether it's well-formed and expect it to be in the normal case, that
> might be a good optimization.

Yeah, as I noted in my reply to Ævar, ~20 of the trace lines generated by the test suite are not properly encoded. So if we do something like:

  $ GIT_TRACE2_EVENT=$(pwd)/one-per-line make test
  $ (echo '[' ; sed 's/$/,/' < one-per-line ; echo ']') > list
  $ validate list

then most validators will only tell us that the file as a whole is malformed. If we validate line-by-line, then we can just count how many malformed lines we have and make sure it's within expectations.

Alternatively, we could just explicitly disable tracing on the tests that generate the malformed traces.

> 
> I also wouldn't be surprised if "jq" could do this in a more robust way.
I'll go take a look at jq.
> -Peff
Previous: Jeff KingNext: Jakub Narebski
Message 10 of 47 in “Add a JSON Schema for trace2 events”
  1. 0/3 Add a JSON Schema for trace2 eventsJosh Steadmon, Jun 11, 2019
  2. 1/3 trace2: correct trace2 field name documentationJosh Steadmon, Jun 11, 2019
  3. Junio C HamanoJun 12, 2019
  4. Josh SteadmonJun 12, 2019
  5. Jeff HostetlerJun 14, 2019
  6. 3/3 trace2: add a schema validator for trace2 eventsJosh Steadmon, Jun 11, 2019
  7. Ævar Arnfjörð BjarmasonJun 12, 2019
  8. Josh SteadmonJun 12, 2019
  9. Jeff KingJun 12, 2019
  10. Josh SteadmonJun 20, 2019
  11. Jakub NarebskiJun 21, 2019
  12. Jeff HostetlerJun 27, 2019
  13. 2/3 trace2: Add a JSON schema for trace2 eventsJosh Steadmon, Jun 11, 2019
  14. Jeff HostetlerJun 14, 2019
  15. Josh SteadmonJun 20, 2019
  16. 0/3 Add a JSON Schema for trace2 eventsJosh Steadmon, Jul 9, 2019
  17. 1/3 trace2: Add a JSON schema for trace2 eventsJosh Steadmon, Jul 9, 2019
  18. Jakub NarebskiJul 10, 2019
  19. Josh SteadmonJul 24, 2019
  20. 2/3 trace2: add a schema validator for trace2 eventsJosh Steadmon, Jul 9, 2019
  21. Jakub NarebskiJul 11, 2019
  22. Josh SteadmonJul 24, 2019
  23. 3/3 ci: run trace2 schema validation in the CI suiteJosh Steadmon, Jul 9, 2019
  24. 0/3 Add a JSON Schema for trace2 eventsJosh Steadmon, Jul 24, 2019
  25. 1/3 trace2: Add a JSON schema for trace2 eventsJosh Steadmon, Jul 24, 2019
  26. Junio C HamanoJul 25, 2019
  27. 2/3 trace2: add a schema validator for trace2 eventsJosh Steadmon, Jul 24, 2019
  28. 3/3 ci: run trace2 schema validation in the CI suiteJosh Steadmon, Jul 24, 2019
  29. SZEDER GáborJul 25, 2019
  30. Junio C HamanoJul 25, 2019
  31. Josh SteadmonJul 26, 2019
  32. SZEDER GáborJul 25, 2019
  33. Johannes SchindelinJul 26, 2019
  34. SZEDER GáborJul 26, 2019
  35. Johannes SchindelinJul 31, 2019
  36. Josh SteadmonJul 26, 2019
  37. Josh SteadmonAug 1, 2019
  38. Jonathan NiederAug 2, 2019
  39. Johannes SchindelinAug 2, 2019
  40. Jonathan NiederAug 2, 2019
  41. SZEDER GáborAug 2, 2019
  42. Jonathan NiederAug 2, 2019
  43. Johannes SchindelinAug 3, 2019
  44. SZEDER GáborAug 2, 2019
  45. Jonathan NiederAug 2, 2019
  46. SZEDER GáborAug 3, 2019
  47. SZEDER GáborAug 3, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.