~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_serve.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    urlutils,
35
35
    )
36
36
from bzrlib.branch import Branch
37
 
from bzrlib.bzrdir import BzrDir
 
37
from bzrlib.controldir import ControlDir
38
38
from bzrlib.smart import client, medium
39
39
from bzrlib.smart.server import (
40
40
    BzrServerFactory,
122
122
        SmartTCPServer.hooks.install_named_hook(
123
123
            'server_exception', hook,
124
124
            'test_server_except_hook hook')
125
 
        args = ['--port', 'localhost:0', '--quiet']
 
125
        args = ['--listen', 'localhost', '--port', '0', '--quiet']
126
126
        out, err = self.run_bzr_serve_then_func(args, retcode=0)
127
127
        self.assertEqual('catching KeyboardInterrupt\n', err)
128
128
 
190
190
            finish_bzr_subprocess, and the base url for the server.
191
191
        """
192
192
        # Serve from the current directory
193
 
        args = ['serve', '--port', 'localhost:0']
 
193
        args = ['serve', '--listen', 'localhost', '--port', '0']
194
194
        args.extend(extra_options)
195
195
        process = self.start_bzr_subprocess(args, skip_if_plan_to_signal=True)
196
196
        port_line = process.stderr.readline()
203
203
 
204
204
    def test_bzr_serve_quiet(self):
205
205
        self.make_branch('.')
206
 
        args = ['--port', 'localhost:0', '--quiet']
 
206
        args = ['--listen', 'localhost', '--port', '0', '--quiet']
207
207
        out, err = self.run_bzr_serve_then_func(args, retcode=3)
208
208
        self.assertEqual('', out)
209
209
        self.assertEqual('', err)
221
221
        process, transport = self.start_server_inet(['--allow-writes'])
222
222
 
223
223
        # We get a working branch, and can create a directory
224
 
        branch = BzrDir.open_from_transport(transport).open_branch()
 
224
        branch = ControlDir.open_from_transport(transport).open_branch()
225
225
        self.make_read_requests(branch)
226
226
        transport.mkdir('adir')
227
227
        self.assertInetServerShutsdownCleanly(process)
263
263
        log_fname = os.getcwd() + '/server.log'
264
264
        self.overrideEnv('BZR_LOG', log_fname)
265
265
        process, transport = self.start_server_inet(['-Dhpss'])
266
 
        branch = BzrDir.open_from_transport(transport).open_branch()
 
266
        branch = ControlDir.open_from_transport(transport).open_branch()
267
267
        self.make_read_requests(branch)
268
268
        self.assertInetServerShutsdownCleanly(process)
269
269
        f = open(log_fname, 'rb')
274
274
    def test_bzr_serve_supports_configurable_timeout(self):
275
275
        gs = config.GlobalStack()
276
276
        gs.set('serve.client_timeout', 0.2)
 
277
        # Save the config as the subprocess will use it
 
278
        gs.store.save()
277
279
        process, url = self.start_server_port()
278
280
        self.build_tree_contents([('a_file', 'contents\n')])
279
281
        # We can connect and issue a request
281
283
        self.assertEqual('contents\n', t.get_bytes('a_file'))
282
284
        # However, if we just wait for more content from the server, it will
283
285
        # eventually disconnect us.
284
 
        # TODO: Use something like signal.alarm() so that if the server doesn't
285
 
        #       properly handle the timeout, we end up failing the test instead
286
 
        #       of hanging forever.
287
286
        m = t.get_smart_medium()
288
287
        m.read_bytes(1)
289
288
        # Now, we wait for timeout to trigger
354
353
        t = self.get_transport()
355
354
        t.mkdir('server-root')
356
355
        self.run_bzr_serve_then_func(
357
 
            ['--port', '127.0.0.1:0',
 
356
            ['--listen', '127.0.0.1', '--port', '0',
358
357
             '--directory', t.local_abspath('server-root'),
359
358
             '--allow-writes'],
360
359
            func=self.when_server_started)