github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/_utils/check_ticker_interval (about)

     1  #!/usr/bin/env python2
     2  import sys
     3  
     4  
     5  def check_worker_ticker_interval(log_path, min_interval):
     6      """
     7      check the time interval between dm-worker updates when the queue is empty
     8  
     9      log_path: dm-worker-log path
    10      min_interval: min interval
    11      """
    12      logs = []
    13      with open(log_path, "r") as f:
    14          for line in f.readlines():
    15              if len(logs) == 2:
    16                  break
    17              if "no job in queue, update lag to zero" in line:
    18                  logs.append(line)
    19      ts1 = logs[0].split('"current ts"=')[1].split("]")[0]
    20      ts2 = logs[1].split('"current ts"=')[1].split("]")[0]
    21      if int(ts2) -int(ts1) <= int(min_interval):
    22          raise Exception(
    23              "check_worker_ticker_interval failed ts1={} ts2={} min_interval={}".format(
    24                  ts1, ts2, min_interval
    25              )
    26          )
    27  
    28  
    29  if __name__ == "__main__":
    30      check_worker_ticker_interval(sys.argv[1], sys.argv[2])