HomeClusterLabs Projects

Refactor: CTS: Improve regexes in cts-cli.

Description

Refactor: CTS: Improve regexes in cts-cli.

Several regexes in the big block were causing the crm_verify tests to
take a very long time. I think this is because they used multiple ".*"
patterns on a very large piece of input (crm_mon.xml) resulting in a lot
of backtracking.

Additionally, various regexes were written in a particular style because
they were written for sed, and sed has different regex support on
different platforms. However, now we are using python which should be
the same everywhere.

Thus, make various improvements to the regexes:

  • [0-9][0-9]* can just be [0-9]+
  • Various places that use a star could really use a plus, because we know there is going to be something there. For instance, "@crm_feature_set=[0-9.]*" could use a plus instead.
  • The function name/file name/line number tuple strings always start at the beginning of a line, so we can get rid of the leading ".*". In addition, they are always just replaced with the name of the function which we already know, so get rid of the capturing and reference.
  • Add a space to the regex that grabs crm* command line tool names so it doesn't match a bunch more stuff in the input line. This was causing crm_verify's request line to be truncated both at the beginning and ending. However...
  • For any request lines that have -X '...' on them, get rid of everything between the single quotes and just replace it with a couple dots to indicate something goes there. With the previous fix, several requests now include the entire contents of crm_mon.xml which is very big and makes everything else very slow.
  • Trim off the path on files passed as --xml-file= since that will vary based on where it's run.

It's become too complicated to merge these regex fixes back in with the
original commits that introduced them, so I'm including them and the
changes to the crm_verify regression output in this commit.

Details

Provenance
clumensAuthored on Aug 9 2024, 5:03 PM
Parents
rP8e0851cb91bf: Build: rpm: Require python3-psutil for running tests.
Branches
Unknown
Tags
Unknown