<commit_before>"""
<Program Name>
  test_time_tcp.py

<Started>
  Jul 26, 2009

<Author>
  <NAME>

<Purpose>
  Send out emails if fewer than 5 timeservers are running
"""

import sys
import send_gmail
import integrationtestlib

# use repy helper to bring in tcp_time.repy
import repyhelper

repyhelper.translate_and_import('tcp_time.repy')
repyhelper.translate_and_import('ntp_time.repy')

def main():
  # initialize the gmail module
  success,explanation_str = send_gmail.init_gmail()
  if not success:
    integrationtestlib.log(explanation_str)
    sys.exit(0)


  notify_str = ''

  #add <NAME> to the email notify list
  integrationtestlib.notify_list.append("<EMAIL>")
    
  integrationtestlib.log("Starting test_time_tcp.py...")  
  
  # get the time 5 times and make sure they are reasonably close
  test_start = getruntime()
  times = []
  for i in range (5):
    try:
      tcp_time_updatetime(12345)
      times.append(time_gettime())
    except Exception,e:
      pass
  test_stop1 = getruntime()

  
  if len(times) < 4:  # more than one attempt failed
    notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts'

  diff = max(times) - min(times)
  if diff > (test_stop1 - test_start):  
    integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff))
    notify_str += ' WARNING large descrepancy between tcp times: '+str(diff)
    
  
  try:
    ntp_time_updatetime(12345)
    ntp_t = time_gettime()
  except Exception,e:
    fail_test(str(e))
  
  test_stop2 = getruntime()
  diff = ntp_t - max(times)
  if diff > (2 + test_stop2 - test_stop1):
    exceedby = diff - (test_stop2-test_stop1)
    integrationtestlib.log('WARING large descrepancy between ntp and tcp times')
    notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby)

  
  if notify_str != '':
    integrationtestlib.notify(notify_str, "test_time_tcp test failed")  
  else:
    integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed")
  print "......................................................\n"

  


if __name__ == '__main__':
  main()<commit_msg>increased allowabe time diff to lower erroneous test failures<commit_after>"""
<Program Name>
  test_time_tcp.py

<Started>
  Jul 26, 2009

<Author>
  <NAME>

<Purpose>
  Send out emails if fewer than 5 timeservers are running
"""

import sys
import send_gmail
import integrationtestlib

# use repy helper to bring in tcp_time.repy
import repyhelper

repyhelper.translate_and_import('tcp_time.repy')
repyhelper.translate_and_import('ntp_time.repy')

def main():
  # initialize the gmail module
  success,explanation_str = send_gmail.init_gmail()
  if not success:
    integrationtestlib.log(explanation_str)
    sys.exit(0)


  notify_str = ''

  #add <NAME> to the email notify list
  integrationtestlib.notify_list.append("<EMAIL>")
    
  integrationtestlib.log("Starting test_time_tcp.py...")  
  
  # get the time 5 times and make sure they are reasonably close
  test_start = getruntime()
  times = []
  for i in range (5):
    try:
      tcp_time_updatetime(12345)
      times.append(time_gettime())
    except Exception,e:
      pass
  test_stop1 = getruntime()

  
  if len(times) < 4:  # more than one attempt failed
    notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts'

  diff = max(times) - min(times)
  if diff > (test_stop1 - test_start):  
    integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff))
    notify_str += ' WARNING large descrepancy between tcp times: '+str(diff)
    
  
  try:
    ntp_time_updatetime(12345)
    ntp_t = time_gettime()
  except Exception,e:
    fail_test(str(e))
  
  test_stop2 = getruntime()
  diff = ntp_t - max(times)
  if diff > (8 + test_stop2 - test_stop1):
    exceedby = diff - (test_stop2-test_stop1)
    integrationtestlib.log('WARING large descrepancy between ntp and tcp times')
    notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby)

  
  if notify_str != '':
    integrationtestlib.notify(notify_str, "test_time_tcp test failed")  
  else:
    integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed")
  print "......................................................\n"

  


if __name__ == '__main__':
  main()
{'fraction_non_alphanumeric': 0.12267657992565056, 'fraction_numerical': 0.013940520446096654, 'mean_word_length': 3.300699300699301, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6423941', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1406, 'n_words': 387}