gdt-dev / gdt

Go Declarative Testing
Apache License 2.0
4 stars 2 forks source link

Support taking arbitrary actions upon test failure #12

Open jaypipes opened 1 year ago

jaypipes commented 1 year ago

Users would like to be able to execute commands, collect log information, grep for errors in output and other actions when a test assertion fails.

For instance, if an application is deployed using Kubernetes and network connectivity doesn't work for the application, the test author might want to call kubectl logs in the event of a test failure.

Another example might be if you wanted to grep a log file in the event that no connectivity on a particular IP:PORT combination could be made you might do this:

tests:
 - exec: nc -z $HOST $PORT
   on:
     fail:
       exec: grep ERROR /var/log/myapp.log

The grep ERROR /var/log/myapp.log command will only be executed if there is no connectivity to $HOST:$PORT and the results of that grep will be directed to the test's output. You can use the gdt.WithDebug() function to configure additional io.Writers to direct this output to.

jaypipes commented 1 year ago

Still need to implement this for the HTTP and Kube plugins.