~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Put in place a structure for the admin-guide

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006 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
27
27
 
28
28
from bzrlib import (
29
29
    builtins,
30
 
    debug,
31
30
    errors,
32
31
    osutils,
33
32
    revision as _mod_revision,
34
 
    transport,
35
33
    urlutils,
36
34
    )
37
35
from bzrlib.branch import Branch
39
37
from bzrlib.smart import client, medium
40
38
from bzrlib.smart.server import BzrServerFactory, SmartTCPServer
41
39
from bzrlib.tests import (
 
40
    ParamikoFeature,
42
41
    TestCaseWithMemoryTransport,
43
42
    TestCaseWithTransport,
44
43
    TestSkipped,
45
44
    )
46
45
from bzrlib.trace import mutter
47
 
from bzrlib.transport import remote
48
 
 
 
46
from bzrlib.transport import get_transport, remote
49
47
 
50
48
class TestBzrServeBase(TestCaseWithTransport):
51
49
 
132
130
            finish_bzr_subprocess, a client for the server, and a transport.
133
131
        """
134
132
        # Serve from the current directory
135
 
        args = ['serve', '--inet']
136
 
        args.extend(extra_options)
137
 
        process = self.start_bzr_subprocess(args)
 
133
        process = self.start_bzr_subprocess(['serve', '--inet'])
138
134
 
139
135
        # Connect to the server
140
136
        # We use this url because while this is no valid URL to connect to this
184
180
 
185
181
        process, transport = self.start_server_inet(['--allow-writes'])
186
182
 
187
 
        # We get a working branch, and can create a directory
 
183
        # We get a working branch
188
184
        branch = BzrDir.open_from_transport(transport).open_branch()
189
185
        self.make_read_requests(branch)
190
 
        transport.mkdir('adir')
191
186
        self.assertInetServerShutsdownCleanly(process)
192
187
 
193
188
    def test_bzr_serve_port_readonly(self):
194
189
        """bzr server should provide a read only filesystem by default."""
195
190
        process, url = self.start_server_port()
196
 
        t = transport.get_transport(url)
197
 
        self.assertRaises(errors.TransportNotPossible, t.mkdir, 'adir')
 
191
        transport = get_transport(url)
 
192
        self.assertRaises(errors.TransportNotPossible, transport.mkdir, 'adir')
198
193
        self.assertServerFinishesCleanly(process)
199
194
 
200
195
    def test_bzr_serve_port_readwrite(self):
220
215
        self.make_read_requests(branch)
221
216
        self.assertServerFinishesCleanly(process)
222
217
 
223
 
    def test_bzr_serve_dhpss(self):
224
 
        # This is a smoke test that the server doesn't crash when run with
225
 
        # -Dhpss, and does drop some hpss logging to the file.
226
 
        self.make_branch('.')
227
 
        log_fname = os.getcwd() + '/server.log'
228
 
        self._captureVar('BZR_LOG', log_fname)
229
 
        process, transport = self.start_server_inet(['-Dhpss'])
230
 
        branch = BzrDir.open_from_transport(transport).open_branch()
231
 
        self.make_read_requests(branch)
232
 
        self.assertInetServerShutsdownCleanly(process)
233
 
        f = open(log_fname, 'rb')
234
 
        content = f.read()
235
 
        f.close()
236
 
        self.assertContainsRe(content, r'hpss request: \[[0-9-]+\]')
237
 
 
238
218
 
239
219
class TestCmdServeChrooting(TestBzrServeBase):
240
220
 
288
268
        return path
289
269
 
290
270
    def make_test_server(self, base_path='/'):
291
 
        """Make and start a BzrServerFactory, backed by a memory transport, and
 
271
        """Make and setUp a BzrServerFactory, backed by a memory transport, and
292
272
        creat '/home/user' in that transport.
293
273
        """
294
274
        bzr_server = BzrServerFactory(