code: def wait_for_relation(service_name, relation_name, timeout=120):
      
      start_time = time.time()
      while True:
          relation = unit_info(service_name, 'relations').get(relation_name)
          if relation is not None and relation['state'] == 'up':
              break
          if time.time() - start_time >= timeout:
              raise RuntimeError('timeout waiting for relation to be up')
          time.sleep(SLEEP_AMOUNT)
docs: Wait `timeout` seconds for a given relation to come up.