/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_server.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-12 18:05:15 UTC
  • mto: (4371.4.5 vila-better-heads)
  • mto: This revision was merged to the branch mainline in revision 4449.
  • Revision ID: john@arbash-meinel.com-20090612180515-t0cwbjsnve094oik
Add a failing test for handling nodes that are in the same linear chain.

It fails because the ancestry skipping causes us to miss the fact that the two nodes
are actually directly related. We could check at the beginning, as the 
code used to do, but I think that will be incomplete for the more-than-two
heads cases.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
31
31
import urlparse
32
32
 
33
33
from bzrlib import transport
34
 
from bzrlib.tests import test_server
35
34
from bzrlib.transport import local
36
35
 
37
36
 
319
318
        self.test_case_server = test_case_server
320
319
        self._home_dir = test_case_server._home_dir
321
320
 
322
 
    def stop_server(self):
 
321
    def tearDown(self):
323
322
         """Called to clean-up the server.
324
323
 
325
324
         Since the server may be (surely is, even) in a blocking listen, we
348
347
             # 'Socket is not connected' can also occur on OSX, with a
349
348
             # "regular" ENOTCONN (when something went wrong during test case
350
349
             # setup leading to self.setUp() *not* being called but
351
 
             # self.stop_server() still being called -- vila20081106
 
350
             # self.tearDown() still being called -- vila20081106
352
351
             if not len(e.args) or e.args[0] not in (errno.ENOTCONN, 10057):
353
352
                 raise
354
353
         # Let the server properly close the socket
383
382
        # lying around.
384
383
        self.daemon_threads = True
385
384
 
386
 
    def process_request_thread(self, request, client_address):
387
 
        SocketServer.ThreadingTCPServer.process_request_thread(
388
 
            self, request, client_address)
389
 
        # Under some circumstances (as in bug #383920), we need to force the
390
 
        # shutdown as python delays it until gc occur otherwise and the client
391
 
        # may hang.
392
 
        try:
393
 
            # The request process has been completed, the thread is about to
394
 
            # die, let's shutdown the socket if we can.
395
 
            request.shutdown(socket.SHUT_RDWR)
396
 
        except (socket.error, select.error), e:
397
 
            if e[0] in (errno.EBADF, errno.ENOTCONN):
398
 
                # Right, the socket is already down
399
 
                pass
400
 
            else:
401
 
                raise
402
 
 
403
385
 
404
386
class HttpServer(transport.Server):
405
387
    """A test server for http transports.
463
445
                raise httplib.UnknownProtocol(proto_vers)
464
446
            else:
465
447
                self._httpd = self.create_httpd(serv_cls, rhandler)
466
 
            self.host, self.port = self._httpd.socket.getsockname()
 
448
            host, self.port = self._httpd.socket.getsockname()
467
449
        return self._httpd
468
450
 
469
451
    def _http_start(self):
495
477
            except socket.timeout:
496
478
                pass
497
479
            except (socket.error, select.error), e:
498
 
                if (e[0] == errno.EBADF
499
 
                    or (sys.platform == 'win32' and e[0] == 10038)):
500
 
                    # Starting with python-2.6, handle_request may raise socket
501
 
                    # or select exceptions when the server is shut down (as we
502
 
                    # do).
503
 
                    # 10038 = WSAENOTSOCK
504
 
                    # http://msdn.microsoft.com/en-us/library/ms740668%28VS.85%29.aspx
505
 
                    pass
506
 
                else:
507
 
                    raise
 
480
               if e[0] == errno.EBADF:
 
481
                   # Starting with python-2.6, handle_request may raise socket
 
482
                   # or select exceptions when the server is shut down (as we
 
483
                   # do).
 
484
                   pass
 
485
               else:
 
486
                   raise
508
487
 
509
488
    def _get_remote_url(self, path):
510
489
        path_parts = path.split(os.path.sep)
522
501
        """Capture Server log output."""
523
502
        self.logs.append(format % args)
524
503
 
525
 
    def start_server(self, backing_transport_server=None):
526
 
        """See bzrlib.transport.Server.start_server.
 
504
    def setUp(self, backing_transport_server=None):
 
505
        """See bzrlib.transport.Server.setUp.
527
506
 
528
507
        :param backing_transport_server: The transport that requests over this
529
508
            protocol should be forwarded to. Note that this is currently not
531
510
        """
532
511
        # XXX: TODO: make the server back onto vfs_server rather than local
533
512
        # disk.
534
 
        if not (backing_transport_server is None
535
 
                or isinstance(backing_transport_server,
536
 
                              test_server.LocalURLServer)):
 
513
        if not (backing_transport_server is None or \
 
514
                isinstance(backing_transport_server, local.LocalURLServer)):
537
515
            raise AssertionError(
538
516
                "HTTPServer currently assumes local transport, got %s" % \
539
517
                backing_transport_server)
559
537
        self._http_starting.release()
560
538
        self.logs = []
561
539
 
562
 
    def stop_server(self):
563
 
        self._httpd.stop_server()
 
540
    def tearDown(self):
 
541
        """See bzrlib.transport.Server.tearDown."""
 
542
        self._httpd.tearDown()
564
543
        self._http_running = False
565
544
        # We don't need to 'self._http_thread.join()' here since the thread is
566
545
        # a daemonic one and will be garbage collected anyway. Joining just