I would decouple the logic which deals with inserting the ad from the timer part, hiding the latter behind an interface (and the same for the DB). Then (using e.g. dependency injection) I can replace the regular timer with a mock timer which fires "immediately" (or after any desired interval) in the unit test, so I can assert that the ad (supplied via the mock DB interface) is inserted properly into the output.
This would be the unit testing part; I would still try to put together some integration test to verify that the whole system works as expected. But after having unit tested the logic thoroughly, the integration test may be shallower, just verifying the few most basic use cases.