aristanetworks/robotframework-aristalibrary

Debug/Trace test enhancement

Opened this issue · 0 comments

Throughout acceptance testing I find myself doing a lot of agent debugging specifically to confirm timers, events registering (e.g. route withdrawal), state updates. In order to do this currently I use task setup/teardown to start/stop agent trace, dump everything into a file and then grep for a specific event signature (or empty string to capture everything). I thought that it would be nice to incorporate this into aristalibrary in order to avoid doing the extra setup/teardown work. If this doesn't seem like a good idea, feel free to close this issue and I'll continue using my current approach.
This is how my task looks like:

	[Setup]	Enable tracing for ${DEBUG_AGENT} ${DEBUG_SETTING}
	Sleep	${DEBUG_TIMEOUT}
	Record all occurrences of ${DEBUG_EVENT}
	[Teardown]	Disable tracing for ${DEBUG_AGENT}

And my high-level keyword definitions:

Enable tracing for ${agent} ${setting}
	Run Keyword And Ignore Error	Configure	bash timeout ${BASH_TIMEOUT} sudo rm /tmp/${TRACE_FILE}
	${trace_on}=	Create List	trace ${agent} setting ${setting}	trace ${agent} filename ${TRACE_FILE}
	${result}=	Configure	${trace_on}
	Length Should Be	${result}	2
Record all occurrences of ${event}
	${result}=	Configure	bash timeout ${BASH_TIMEOUT} grep "${event}" /tmp/${TRACE_FILE}
	Log	${result[0]['messages'][0]}
Disable tracing for ${agent}
	${trace_off}=	Create List	no trace ${agent} setting	no trace ${agent} filename
	${result}=	Configure	${trace_off}
	Length Should Be	${result}	2
	Run Keyword And Ignore Error	Configure	bash timeout ${BASH_TIMEOUT} sudo rm /tmp/${TRACE_FILE}