EEM QA: what were they (not) doing?

When I was writing the applet that should stop accidental scheduled router reloads, I wanted to use the action string match command to perform pattern matching on the output of the show reload command. Somehow the applet didn’t want to work as expected, so I checked the documentation on Cisco’s web site.

Reading the command description, I should have realized the whole thing must be broken. It looks like the documentation writer was fast asleep; even someone with a major in classical philosophy and zero exposure to networking should be able to spot the glaring logical inconsistencies.

Judging by the quality of the documentation, I started wondering if someone mixed up the order of parameters, so I swapped the pattern and the string. No luck. Totally fed up, I spent 30 seconds cut-and-pasting together a short test case:

event manager applet CheckMatchCommand
event none
action 1.0 string match "a" "a"
action 1.1 puts "match: -a- versus -a- result: $_string_result"
action 2.0 string match "aa" "a"
action 2.1 puts "match: -aa- versus -a- result: $_string_result"
action 3.0 string match "a" "aa"
action 3.1 puts "match: -a- versus -aa- result: $_string_result"
action 4.0 string match "a." "aa"
action 4.1 puts "match: -a.- versus -aa- result: $_string_result"
action 5.0 string match "aa" "a."
action 5.1 puts "match: -aa- versus -a.- result: $_string_result"
action 6.0 string match "." "a"
action 6.1 puts "match: -.- versus -a- result: $_string_result"
action 7.0 string match "a" "."
action 7.1 puts "match: -a- versus -.- result: $_string_result"

Here are the results:

EEM#show version | inc IOS Software
Cisco IOS Software, 7200 Software (C7200-ADVIPSERVICESK9-M), Version 15.0(1)M4
EEM#event man run CheckMatchCommand
match: -a- versus -a- result: 1
match: -aa- versus -a- result: 0
match: -a- versus -aa- result: 0
match: -a.- versus -aa- result: 0
match: -aa- versus -a.- result: 0
match: -.- versus -a- result: 0
match: -a- versus -.- result: 0

As you can see, the string match command has nothing to do with pattern matching. It’s a simple string comparison, returning 1 if the two strings are equal and 0 if they are not.

Faced with such a huge discrepancy between documentation and actual behavior, one is forced to ask: what was the QA team doing? Did anyone ever test this feature? And last but not least: does this mean that nobody is using EEM 3.0 features or writing EEM applets? EEM 3.0 is almost two years old; such an obvious bug should have been reported and fixed by now.

5 comments:

  1. Since this is glaring, could it be an issue with the specific IOS you are using? Perhaps a bug or a regression of sorts? I have no actual evidence to support this, it was just an initial thought that came to mind.
  2. Yeah, even the ESM documentation is hard to read/interpret. Take a look here: https://learningnetwork.cisco.com/thread/24923
  3. All the engineers I've worked with - everyone thinks EEM is cool. NO ONE is using it.
  4. The string match command does pattern matching. Instead of reading Cisco web site you just need Tcl manual page for string command. Your test cases are all wrong (at least regarding pattern syntax). There are proper tests:

    % string match "a*" "aba"
    1
    % string match "a*b?z" "aeb1z"
    1
    % string match "a*b?z" "aeb1zz"
    0
  5. agreed with Oleg.

    Here is description:

    string match pattern string
    See if pattern matches string; return 1 if it does, 0 if it doesn't. Matching is done in a fashion similar to that used by the C-shell. For the two strings to match, their contents must be identical except that the following special sequences may appear in pattern:

    *
    Matches any sequence of characters in string, including a null string.

    ?
    Matches any single character in string.

    [chars]
    Matches any character in the set given by chars. If a sequence of the form x-y appears in chars, then any character between x and y, inclusive, will match.

    \x
    Matches the single character x. This provides a way of avoiding the special interpretation of the characters *?[]\ in pattern.
Add comment
Sidebar