buildkite / lifecycled

A daemon for responding to AWS AutoScaling Lifecycle Hooks
MIT License
146 stars 34 forks source link

WIP: Add basic tests #50

Closed itsdalmo closed 6 years ago

itsdalmo commented 6 years ago

This PR based off https://github.com/buildkite/lifecycled/pull/45, hence it contains all the commits from that one. Started off writing some basic tests that at least cover cases like cleaning up queues after the listener exits etc. When testing we need to use logrus.NewNullLogger(), so I had to rewrite some code to avoid using the default/global logger in logrus - ended up with the following pattern:

Example of the log entries below:

INFO[0000] Starting listener                             instanceId=test listener=autoscaling
INFO[0000] Waiting for termination notices               instanceId=test
DEBU[0000] Creating sqs queue                            instanceId=test listener=autoscaling queue=lifecycled-test
DEBU[0000] Subscribing queue to sns topic                instanceId=test listener=autoscaling topic="arn:aws:sns:eu-west-1:#:lifecycled-example-lifecycle"
DEBU[0001] Polling sqs for messages                      instanceId=test listener=autoscaling queueURL="https://sqs.eu-west-1.amazonaws.com/#/lifecycled-test"
DEBU[0021] Polling sqs for messages                      instanceId=test listener=autoscaling queueURL="https://sqs.eu-west-1.amazonaws.com/#/lifecycled-test"
INFO[0025] Received signal: shutting down...             signal=interrupt
DEBU[0025] Deleting sns subscription                     arn="arn:aws:sns:eu-west-1:#:lifecycled-example-lifecycle:35ff34d7-edc8-4413-9065-066bcce3e3c4" instanceId=test listener=autoscaling
DEBU[0025] Deleting sqs queue                            instanceId=test listener=autoscaling queue=lifecycled-test
INFO[0026] Stopped listener                              instanceId=test listener=autoscaling

Stuff that needs fixing:

itsdalmo commented 6 years ago

Closing in favor of #52