~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2010-01-15 03:58:20 UTC
  • mfrom: (4963 +trunk)
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: andrew.bennetts@canonical.com-20100115035820-ilb3t36swgzq6v1l
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

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