On Wed, 2010-11-17 at 09:59 -0800, Jean-Marc Eurin wrote:
> Cleaning up and using the base code for the host.
> In the profiler code, the hostid should be a hostname.
> Added some client barrier tests and unittests.

I've spot a missing import in base_barrier_unittest, which was fixed.
Commited, thanks!

http://autotest.kernel.org/changeset/4964

> Signed-off-by: Jean-Marc Eurin <[email protected]>
> 
> --- autotest/client/common_lib/base_barrier.py        2010-04-13 
> 18:12:07.000000000 -0700
> +++ autotest/client/common_lib/base_barrier.py        2010-11-12 
> 13:53:52.000000000 -0800
> @@ -5,6 +5,16 @@
>  # Default barrier TCP port.
>  DEFAULT_PORT = 11922
>  
> +def get_host_from_id(hostid):
> +    # Remove any trailing local identifier following a #.
> +    # This allows multiple members per host which is particularly
> +    # helpful in testing.
> +    if not hostid.startswith('#'):
> +        return hostid.split('#')[0]
> +    else:
> +        raise error.BarrierError(
> +            "Invalid Host id: Host Address should be specified")
> +
>  
>  class listen_server(object):
>      """
> @@ -155,17 +165,6 @@
>          self._waiting = {}  # Maps from hostname -> (client, addr) tuples.
>  
> 
> -    def _get_host_from_id(self, hostid):
> -        # Remove any trailing local identifier following a #.
> -        # This allows multiple members per host which is particularly
> -        # helpful in testing.
> -        if not hostid.startswith('#'):
> -            return hostid.split('#')[0]
> -        else:
> -            raise error.BarrierError(
> -                    "Invalid Host id: Host Address should be specified")
> -
> -
>      def _update_timeout(self, timeout):
>          if timeout is not None and self._start_time is not None:
>              self._timeout_secs = (time() - self._start_time) + timeout
> @@ -393,14 +392,14 @@
>                  remote.settimeout(30)
>                  if is_master:
>                      # Connect to all slaves.
> -                    host = self._get_host_from_id(self._members[self._seen])
> +                    host = get_host_from_id(self._members[self._seen])
>                      logging.info("calling slave: %s", host)
>                      connection = (remote, (host, self._port))
>                      remote.connect(connection[1])
>                      self._master_welcome(connection)
>                  else:
>                      # Just connect to the master.
> -                    host = self._get_host_from_id(self._masterid)
> +                    host = get_host_from_id(self._masterid)
>                      logging.info("calling master")
>                      connection = (remote, (host, self._port))
>                      remote.connect(connection[1])
> --- autotest/client/common_lib/base_barrier_unittest.py       2010-04-13 
> 18:12:07.000000000 -0700
> +++ autotest/client/common_lib/base_barrier_unittest.py       2010-11-12 
> 13:53:52.000000000 -0800
> @@ -47,15 +47,14 @@
>  
> 
>      def test_get_host_from_id(self):
> -        b = barrier.barrier('127.0.0.1#', 'testgethost', 100)
> -
> -        hostname = b._get_host_from_id('my_host')
> +        hostname = base_barrier.get_host_from_id('my_host')
>          self.assertEqual(hostname, 'my_host')
>  
> -        hostname = b._get_host_from_id('my_host#')
> +        hostname = base_barrier.get_host_from_id('my_host#')
>          self.assertEqual(hostname, 'my_host')
>  
> -        self.assertRaises(error.BarrierError, b._get_host_from_id, 
> '#my_host')
> +        self.assertRaises(error.BarrierError,
> +                          base_barrier.get_host_from_id, '#my_host')
>  
> 
>      def test_update_timeout(self):
> --- autotest/server/standalone_profiler.py    2010-04-07 10:28:28.000000000 
> -0700
> +++ autotest/server/standalone_profiler.py    2010-11-12 13:53:52.000000000 
> -0800
> @@ -9,6 +9,7 @@
>  
>  __author__ = '[email protected] (Colby Ranger)'
>  
> +import platform
>  import common
>  from autotest_lib.client.common_lib import barrier
>  
> @@ -16,7 +17,7 @@
>  _RUNTEST_PATTERN = ("job.run_test('profiler_sync', timeout_sync=%r,\n"
>                      "             timeout_start=%r, timeout_stop=%r,\n"
>                      "             hostid='%s', masterid='%s', all_ids=%r)")
> -_PROF_MASTER = "PROF_MASTER"
> +_PROF_MASTER = platform.node()
>  _PORT = 11920
>  
> 
> --- autotest/server/tests/barriertest_2client/control.srv     2010-11-04 
> 23:08:59.000000000 -0700
> +++ autotest/server/tests/barriertest_2client/control.srv     2010-11-12 
> 13:53:52.000000000 -0800
> @@ -22,13 +22,39 @@
>  host_at_objs = [autotest.Autotest(host) for host in host_objs]
>  
>  client_control_template = """
> -import logging, platform, traceback
> +import logging, platform, socket, traceback
>  try:
>      client_hostnames = %r
> -    logging.info('creating barrier')
> +    master_hostname = client_hostnames[0]
> +    client_hostname = client_hostnames[1]
> +
> +    logging.info('Testing hostname only barrier')
>      barrier = job.barrier(platform.node(), 'barriertest_2client', 120)
>      logging.info('rendezvous-ing')
> -    barrier.rendezvous(client_hostnames[0], *client_hostnames[1:])
> +    barrier.rendezvous(master_hostname, client_hostname)
> +    logging.info('done.')
> +
> +    logging.info('Testing local identifier barrier')
> +    barrier = job.barrier(platform.node() + '#id0', 'barriertest_2client', 
> 120)
> +    logging.info('rendezvous-ing')
> +    barrier.rendezvous(master_hostname + '#id0',
> +                       client_hostname + '#id0')
> +    logging.info('done.')
> +
> +    logging.info('Testing IP@ barrier')
> +    barrier = job.barrier(socket.gethostbyname(platform.node()),
> +                          'barriertest_2client', 120)
> +    logging.info('rendezvous-ing')
> +    barrier.rendezvous(socket.gethostbyname(master_hostname),
> +                       socket.gethostbyname(client_hostname))
> +    logging.info('done.')
> +
> +    logging.info('Testing IP@ barrier with ids')
> +    barrier = job.barrier(socket.gethostbyname(platform.node()) + '#42',
> +                          'barriertest_2client', 120)
> +    logging.info('rendezvous-ing')
> +    barrier.rendezvous(socket.gethostbyname(master_hostname) + '#42',
> +                       socket.gethostbyname(client_hostname) + '#42')
>      logging.info('done.')
>  except:
>      traceback.print_exc()
> _______________________________________________
> Autotest mailing list
> [email protected]
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest


_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to