Exemple #1
0
def find_default_interface_name():
    if windmill.settings['NETWORK_INTERFACE_NAME'] is not None:
        return windmill.settings['NETWORK_INTERFACE_NAME']
    target_host = urlparse.urlparse(windmill.settings['TEST_URL']).hostname
    x = ['/sbin/route', 'get', target_host]
    interface_id = [l for l in getoutput(x).splitlines()
                    if 'interface' in l][0].split(":")[-1].strip()
    all_inet = getoutput(
        [windmill.settings['NETWORKSETUP_BINARY'],
         '-listallhardwareports']).splitlines()
    try:
        i = all_inet.index(
            [l for l in all_inet if 'Device: ' + interface_id in l][0])
        interface_name = all_inet[i - 1].split(':')[-1].strip()

        # interface_name = [ l for l in all_inet if l.find(interface_id) is not -1 ][0].split('\n')[0].split(':')[-1]
        # if interface_name[0] == ' ':
        #     interface_name = interface_name.strip()
        # if interface_name[-1] == ' ':
        #     interface_name = interface_name.rstrip()
    except IndexError:
        print "ERROR: Cannot figure out interface name, please set NETWORK_INTERFACE_NAME in local settings file"
        from windmill.bin import admin_lib
        admin_lib.teardown(admin_lib.shell_objects_dict)
        sys.exit()

    # interfaces = getoutput().split('\n\n')
    # print 'interfaces::\n', '\n'.join(interfaces)
    # for line in interfaces:
    #     if not line.startswith('(') and line.find('(1)') is not -1:
    #         line = '(1)'+line.split('(1)')[-1]
    #     if line.find('Device: '+interface) is not -1:
    #         interface_name = ' '.join(line.splitlines()[0].split()[1:])

    return interface_name
Exemple #2
0
def find_default_interface_name():
    if windmill.settings['NETWORK_INTERFACE_NAME'] is not None:
        return windmill.settings['NETWORK_INTERFACE_NAME']
    target_host = urlparse.urlparse(windmill.settings['TEST_URL']).hostname
    x = ['/sbin/route', 'get', target_host]
    interface_id = [l for l in getoutput(x).splitlines() if 'interface' in l][0].split(":")[-1].strip()
    all_inet = getoutput([windmill.settings['NETWORKSETUP_BINARY'], '-listallhardwareports']).splitlines()
    try:
        i = all_inet.index([l for l in all_inet if 'Device: '+interface_id in l][0])
        interface_name = all_inet[i - 1].split(':')[-1].strip()

        # interface_name = [ l for l in all_inet if l.find(interface_id) is not -1 ][0].split('\n')[0].split(':')[-1]
        # if interface_name[0] == ' ':
        #     interface_name = interface_name.strip()
        # if interface_name[-1] == ' ':
        #     interface_name = interface_name.rstrip()
    except IndexError:
        print "ERROR: Cannot figure out interface name, please set NETWORK_INTERFACE_NAME in local settings file"
        from windmill.bin import admin_lib
        admin_lib.teardown(admin_lib.shell_objects_dict)
        sys.exit()
    
    # interfaces = getoutput().split('\n\n')
    # print 'interfaces::\n', '\n'.join(interfaces)
    # for line in interfaces:
    #     if not line.startswith('(') and line.find('(1)') is not -1:
    #         line = '(1)'+line.split('(1)')[-1]
    #     if line.find('Device: '+interface) is not -1:
    #         interface_name = ' '.join(line.splitlines()[0].split()[1:])
    
    return interface_name
Exemple #3
0
def teardown_module(module):
    """teardown_module function for functest based python tests"""
    # Incase we're in runserver mode and test were passed to the windmill command line
    if hasattr(windmill, 'settings') and windmill.settings['EXIT_ON_DONE'] and windmill.runserver_running:
        module.windmill_dict['xmlrpc_client'].stop_runserver() 
    else:
        admin_lib.teardown(module.windmill_dict)
    sleep(.25)
Exemple #4
0
def teardown_module(module):
    """teardown_module function for functest based python tests"""
    # Incase we're in runserver mode and test were passed to the windmill command line
    if hasattr(
            windmill, 'settings'
    ) and windmill.settings['EXIT_ON_DONE'] and windmill.runserver_running:
        module.windmill_dict['xmlrpc_client'].stop_runserver()
    else:
        admin_lib.teardown(module.windmill_dict)
    sleep(.25)
Exemple #5
0
def teardown_module(module):
    """teardown_module function for functest based python tests"""
    try:
        while functest.registry.get('browser_debugging', False):
            sleep(.25)
    except KeyboardInterrupt:
        pass
    # Incase we're in runserver mode and test were passed to the windmill command line
    if hasattr(windmill, 'settings') and windmill.settings['EXIT_ON_DONE'] and windmill.runserver_running:
        module.windmill_dict['xmlrpc_client'].stop_runserver() 
    else:
        admin_lib.teardown(module.windmill_dict)
    sleep(.25)
 def stop_windmill(self):
     # The Firefox test wrapper currently can't kill the browser (on OS X)
     # after a testrun -- see http://trac.getwindmill.com/ticket/313
     if self.is_windmill_initialized():
         try:
             teardown(self.windmill_shell)
         except (ValueError, AssertionError), exception:
             # Mozrunner mac has a bug in the teardown code that will spit this out quite regulary
             # I swallow this exception here because the global exception handler throws away the test 
             # output if this exception gets through which can easily make the entire test run unusable
             # This should be solved by mozrunner v2 in windmill 1.4 or 1.5
             # TODO: log the exception
             pass
         self._windmill_initialized = False
Exemple #7
0
 def stop_windmill(self):
     # The Firefox test wrapper currently can't kill the browser (on OS X)
     # after a testrun -- see http://trac.getwindmill.com/ticket/313
     if self.is_windmill_initialized():
         try:
             teardown(self.windmill_shell)
         except (ValueError, AssertionError), exception:
             # Mozrunner mac has a bug in the teardown code that will spit this out quite regulary
             # I swallow this exception here because the global exception handler throws away the test
             # output if this exception gets through which can easily make the entire test run unusable
             # This should be solved by mozrunner v2 in windmill 1.4 or 1.5
             # TODO: log the exception
             pass
         self._windmill_initialized = False
Exemple #8
0
  def handle(self, *args, **options):
    """
    This is a rewrite of windmill.management.commands.test_windmill
    that uses nose instead of functest.
    """
    from windmill.bin import admin_lib
    from windmill.conf import global_settings
    import nose

    self.port = options['port']

    # Setup DB
    self.setup_test_db()

    # Start a servers (django web server & Hadoop)
    server_container = ServerContainer()
    server_container.start_test_server()
    LOG.info("Server running on %d" % server_container.server_thread.port)
    self.start_helper_servers()


    # Configure windmill
    global_settings.TEST_URL = 'http://127.0.0.1:%d' % server_container.server_thread.port
    # For now, we only handle Firefox.
    global_settings.START_FIREFOX = True
    admin_lib.configure_global_settings(logging_on=False)

    # Start windmill proxy server
    windmill_obj = admin_lib.setup()

    # Run tests with nose
    nose_args = self.find_modules()
    LOG.info("Testing modules: " + repr(nose_args))
    if "--" in sys.argv:
      nose_args.extend(sys.argv[sys.argv.index("--") + 1:])
    res = nose.run(argv=nose_args)

    # Stop servers
    self.stop_helper_servers()
    server_container.stop_test_server()

    # Stop windmill
    admin_lib.teardown(windmill_obj)
    time.sleep(0.25)

    if res:
      sys.exit(0)
    else:
      sys.exit(1)
Exemple #9
0
  def handle(self, *args, **options):
    """
    This is a rewrite of windmill.management.commands.test_windmill
    that uses nose instead of functest.
    """
    from windmill.bin import admin_lib
    from windmill.conf import global_settings
    import nose

    self.port = options['port']

    # Setup DB
    self.setup_test_db()

    # Start a servers (django web server & Hadoop)
    server_container = ServerContainer()
    server_container.start_test_server()
    LOG.info("Server running on %d" % server_container.server_thread.port)
    self.start_helper_servers()


    # Configure windmill
    global_settings.TEST_URL = 'http://127.0.0.1:%d' % server_container.server_thread.port
    # For now, we only handle Firefox.
    global_settings.START_FIREFOX = True
    admin_lib.configure_global_settings(logging_on=False)

    # Start windmill proxy server
    windmill_obj = admin_lib.setup()

    # Run tests with nose
    nose_args = self.find_modules()
    LOG.info("Testing modules: " + repr(nose_args))
    if "--" in sys.argv:
      nose_args.extend(sys.argv[sys.argv.index("--") + 1:])
    res = nose.run(argv=nose_args)

    # Stop servers
    self.stop_helper_servers()
    server_container.stop_test_server()

    # Stop windmill
    admin_lib.teardown(windmill_obj)
    time.sleep(0.25)

    if res:
      sys.exit(0)
    else:
      sys.exit(1)
Exemple #10
0
def teardown_module(module):
    """teardown_module function for functest based python tests"""
    try:
        while functest.registry.get('browser_debugging', False):
            sleep(.25)
    except KeyboardInterrupt:
        pass
    # Incase we're in runserver mode and test were passed to the windmill command line
    if hasattr(
            windmill, 'settings'
    ) and windmill.settings['EXIT_ON_DONE'] and windmill.runserver_running:
        module.windmill_dict['xmlrpc_client'].stop_runserver()
    else:
        admin_lib.teardown(module.windmill_dict)
    sleep(.25)
Exemple #11
0
 def teardown(self, tests):
     """teardown_module function for functest based python tests"""
     import windmill
     if getattr(windmill, "js_framework_active", False) is True:
         sys.stdout.write('\n'); sys.stdout.flush();
         if tests["testFailureCount"] is not 0:
             for k, v in tests.items():
                 if type(v) is dict and v.get(u'result') is False:
                     print "Failed: "+k
             windmill.test_has_failed = True
         total_string = "Total Tests Run: "+str(tests["testCount"])+" "
         total_string += "Total Passed: "+str(tests["testCount"] - tests["testFailureCount"])+" "
         total_string += "Total Failed: "+str(tests["testFailureCount"])
         print total_string
         
     if windmill.settings['EXIT_ON_DONE']:
         from windmill.bin import admin_lib    
         admin_lib.teardown(admin_lib.shell_objects_dict)
         windmill.runserver_running = False
         sleep(.25)
Exemple #12
0
    def teardown(self, tests):
        """teardown_module function for functest based python tests"""
        import windmill
        if getattr(windmill, "js_framework_active", False) is True:
            sys.stdout.write('\n')
            sys.stdout.flush()
            if tests["testFailureCount"] is not 0:
                for k, v in tests.items():
                    if type(v) is dict and v.get(u'result') is False:
                        print "Failed: " + k
                windmill.test_has_failed = True
            total_string = "Total Tests Run: " + str(tests["testCount"]) + " "
            total_string += "Total Passed: " + str(
                tests["testCount"] - tests["testFailureCount"]) + " "
            total_string += "Total Failed: " + str(tests["testFailureCount"])
            print total_string

        if windmill.settings['EXIT_ON_DONE']:
            from windmill.bin import admin_lib
            admin_lib.teardown(admin_lib.shell_objects_dict)
            windmill.runserver_running = False
            sleep(.25)
Exemple #13
0
 def tearDown(self):
     from windmill.bin.admin_lib import teardown
     teardown(self.windmill_shell_objects)
Exemple #14
0
 def tearDown(self):
     from windmill.bin.admin_lib import teardown
     teardown(self.windmill_shell_objects)