xtf-cz / xtf

MIT License
12 stars 55 forks source link

Extend tests and description of EventList* classes to include multiline messages matching #500

Open jbliznak opened 2 years ago

jbliznak commented 2 years ago

There is a slightly non-obvious gotcha when one wants to filter Events by message and that message happens to be a multiline one

EventList events = new EventList(Arrays.asList(
        event("2020-01-01T00:00:00Z", "Pod", "1", "Created", "Normal", "message"),
        event("2020-01-01T00:00:00Z", "Pod", "5", "Created", "Normal", "message\\nmessage")));

EventList filtered = events.filter()
        .ofMessages("message.*")
        .collect();
Assertions.assertEquals(2, filtered.size());

This will fail as the second event does not match the pattern message.*. To be able to match the it one would have to write it like .ofMessages("(?s)message.*") to allow . to match newlines too (DOTALL).

Now the question is whether we want to keep this on user's choice/knowledge to use correct patterns or whether we somehow enforce the XTF to always perform DOTALL matching in this case.

The expected solution of this is one of: 1) enforce DOTALL by default, update javadocs, extend tests 2) document current behaviour ~ update javadocs, extend tests

BTW I noticed this when hitting difference between OCP3 and OCP4 behavior which resulted in hours of debugging :exploding_head:

#OCP3 event message
message=Failed to pull image "helloworld-rs-app:latest": rpc error: code = Unknown desc = repository docker.io/helloworld-rs-app not found: does not exist or no pull access

#OCP4 event message
message=Failed to pull image "helloworld-rs-app:latest": rpc error: code = Unknown desc = reading manifest latest in docker.io/library/helloworld-rs-app: errors:
denied: requested access to the resource is denied
unauthorized: authentication required