Skip to content

Commit

Permalink
Updates old NAT forwarding test to use Affixes.
Browse files Browse the repository at this point in the history
 * Disables checking that forwarders function properly for now.
 * Partially addresses #1403
 * Thank you Monzur for reviewing!
  • Loading branch information
Name authored and Name committed Apr 14, 2014
1 parent 29a126b commit b9337c1
Showing 1 changed file with 43 additions and 39 deletions.
82 changes: 43 additions & 39 deletions trunk/integrationtests/nat/test_nat_servers_running.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@
<Purpose>
Send out emails if fewer than 10 nat servers are running
or we can not get a response from nat_check_bi_directional()
"""

import sys
import send_gmail
import integrationtestlib
import random

from repyportability import *
add_dy_support(locals())

advertise = dy_import_module('advertise.repy')
nat_forwarder_common_lib = dy_import_module('nat_forwarder_common_lib.repy')

# use repy helper to bring in advertise.repy
import repyhelper
repyhelper.translate_and_import('NATLayer_rpc.repy')

# These are the keys we'll be monitoring
nat_forwarder_keys = nat_forwarder_common_lib.NAT_FORWARDER_KEY
NAT_TEST_FAIL_NOTICE = "test_nat_servers_running FAILED"

def main():
# initialize the gmail module
Expand All @@ -30,39 +34,39 @@ def main():
integrationtestlib.log(explanation_str)
sys.exit(0)

#add Eric Kimbrel to the email notify list
integrationtestlib.notify_list.append("[email protected]")
notify_str =''


# PART 1 verify that there are at least 10 nat forwarders running
integrationtestlib.log("Looking up nat forwarders")
try:
nodes = nat_forwarder_list_lookup()
total_nodes = advertise_lookup('NATFORWARDERRUNNING')
except:
nodes = [] #make sure we fail if there was an excpetion

if len(nodes) < 10:
integrationtestlib.log('WARNING: only '+str(len(nodes))+' forwarders are avaiable')
integrationtestlib.log('WARNING: only '+str(len(total_nodes))+' forwarders are running')

notify_str += 'WARNING: test_nat_servers_running.py FAILED, only '+str(len(nodes))+' nat forwarders are avaiable!, '+str(len(total_nodes))+' are running.'


# PART 2 check that nat forwarders are responsive
integrationtestlib.log("Checking that we can talk to a nat forwarder")
try:
response = nat_check_bi_directional(getmyip(),random.randint(20000,62000))
except Exception, e:
notify_str += 'WARNING: could not a get a response from nat forwarders: '+str(e)

integrationtestlib.log('WARNING: could not get a response from nat forwarders '+str(e))

if notify_str != '':
integrationtestlib.notify(notify_str,'nat test fail notice')
# PART 1 verify that there are at least 10 nat forwarders running on
# each key

notify_str = ''
for nat_forwarder_key in nat_forwarder_keys:
integrationtestlib.log("Looking up nat forwarders for " + repr(nat_forwarder_key))
nat_forwarders = []
try:
nat_forwarders = advertise.advertise_lookup(nat_forwarder_key)
except Exception, e:
integrationtestlib.handle_exception("Got exception when looking up nat forwarders", NAT_TEST_FAIL_NOTICE)
return

if len(nat_forwarders) < 10:
notify_str += ('WARNING: only '+ str(len(nat_forwarders))
+ ' nat forwarders are advertising under the key: '
+ repr(nat_forwarder_key) + '\n'
+ "Advertising forwarders: " + str(nat_forwarders) + '\n')

if notify_str:
integrationtestlib.log(notify_str)
integrationtestlib.notify(notify_str, NAT_TEST_FAIL_NOTICE)

# # PART 2 check that nat forwarders are responsive
# TODO: Change this to use Affixes on repyV2
# integrationtestlib.log("Checking that we can talk to a nat forwarder")
# try:
# response = nat_check_bi_directional(getmyip(),random.randint(20000,62000))
# except Exception, e:
# notify_str += 'WARNING: could not a get a response from nat forwarders: '+str(e)

# integrationtestlib.log('WARNING: could not get a response from nat forwarders '+str(e))

integrationtestlib.log("Finished running nat_tests")
print "------------------------------------------------------------"

Expand Down

0 comments on commit b9337c1

Please sign in to comment.