lundi 29 avril 2019

Full AWS Stack System Testing in Python

I have lots of unit tests for individual components in my AWS Stack, but i'd like to do functional tests across multiple asynchronous systems.

These systems are asynchronous due to the queues they operate on. One application may take an event and generate multiple queue items in different queues to be processed downstream. Ultimately, i'd like to put an event in one end of my system and see the results at the other end of the system. I already do this manually, but there are many variations i'd like to test, and full-system regression testing for every feature release is becoming a bear to manage.

It often takes minutes for a unit of work to make it through all of the queues, streams, and processes and settle on the other side.

function testing

I do know how I could test something like this. But it's not very pretty.

def test_event():
    event = { 'user_id': 1, 'action': 'like_post', 'data': {} }

    put_event_to_queue(event)

    retry_count = 0
    success = False
    while retry_count < 3 and not success:
      time.sleep(60)

      if (is_action_in_rds()
          and is_action_in_elasticsearch()
          and is_action_in_athena()):
          success = True

      retry_count += 1

    self.assertTrue(success)

My approach would be to put something in the queue to process and check if the result exists after some arbitrary amount of time.

Would this be the standard approach? Is there a testing framework that lends itself best to this sort of testing?

Aucun commentaire:

Enregistrer un commentaire