/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 breezy/tests/blackbox/test_serve.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 19:09:26 UTC
  • mfrom: (6622.1.36 breezy)
  • Revision ID: jelmer@jelmer.uk-20170521190926-5vtz8xaf0e9ylrpc
Merge rename to breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
"""Tests of the bzr serve command."""
 
18
"""Tests of the brz serve command."""
19
19
 
20
20
import os
21
21
import signal
23
23
import thread
24
24
import threading
25
25
 
26
 
from bzrlib import (
 
26
from breezy import (
27
27
    builtins,
28
28
    config,
29
29
    errors,
33
33
    transport,
34
34
    urlutils,
35
35
    )
36
 
from bzrlib.branch import Branch
37
 
from bzrlib.controldir import ControlDir
38
 
from bzrlib.smart import client, medium
39
 
from bzrlib.smart.server import (
 
36
from breezy.branch import Branch
 
37
from breezy.controldir import ControlDir
 
38
from breezy.smart import client, medium
 
39
from breezy.smart.server import (
40
40
    BzrServerFactory,
41
41
    SmartTCPServer,
42
42
    )
43
 
from bzrlib.tests import (
 
43
from breezy.tests import (
44
44
    TestCaseWithMemoryTransport,
45
45
    TestCaseWithTransport,
46
46
    )
47
 
from bzrlib.transport import remote
 
47
from breezy.transport import remote
48
48
 
49
49
 
50
50
class TestBzrServeBase(TestCaseWithTransport):
51
51
 
52
52
    def run_bzr_serve_then_func(self, serve_args, retcode=0, func=None,
53
53
                                *func_args, **func_kwargs):
54
 
        """Run 'bzr serve', and run the given func in a thread once the server
 
54
        """Run 'brz serve', and run the given func in a thread once the server
55
55
        has started.
56
56
 
57
57
        When 'func' terminates, the server will be terminated too.
143
143
        self.assertEqual('', result[1])
144
144
 
145
145
    def assertServerFinishesCleanly(self, process):
146
 
        """Shutdown the bzr serve instance process looking for errors."""
 
146
        """Shutdown the brz serve instance process looking for errors."""
147
147
        # Shutdown the server
148
148
        result = self.finish_bzr_subprocess(process, retcode=3,
149
149
                                            send_signal=signal.SIGINT)
150
150
        self.assertEqual('', result[0])
151
 
        self.assertEqual('bzr: interrupted\n', result[1])
 
151
        self.assertEqual('brz: interrupted\n', result[1])
152
152
 
153
153
    def make_read_requests(self, branch):
154
154
        """Do some read only requests."""
161
161
            branch.unlock()
162
162
 
163
163
    def start_server_inet(self, extra_options=()):
164
 
        """Start a bzr server subprocess using the --inet option.
 
164
        """Start a brz server subprocess using the --inet option.
165
165
 
166
166
        :param extra_options: extra options to give the server.
167
 
        :return: a tuple with the bzr process handle for passing to
 
167
        :return: a tuple with the brz process handle for passing to
168
168
            finish_bzr_subprocess, a client for the server, and a transport.
169
169
        """
170
170
        # Serve from the current directory
183
183
        return process, transport
184
184
 
185
185
    def start_server_port(self, extra_options=()):
186
 
        """Start a bzr server subprocess.
 
186
        """Start a brz server subprocess.
187
187
 
188
188
        :param extra_options: extra options to give the server.
189
 
        :return: a tuple with the bzr process handle for passing to
 
189
        :return: a tuple with the brz process handle for passing to
190
190
            finish_bzr_subprocess, and the base url for the server.
191
191
        """
192
192
        # Serve from the current directory
209
209
        self.assertEqual('', err)
210
210
 
211
211
    def test_bzr_serve_inet_readonly(self):
212
 
        """bzr server should provide a read only filesystem by default."""
 
212
        """brz server should provide a read only filesystem by default."""
213
213
        process, transport = self.start_server_inet()
214
214
        self.assertRaises(errors.TransportNotPossible, transport.mkdir, 'adir')
215
215
        self.assertInetServerShutsdownCleanly(process)
227
227
        self.assertInetServerShutsdownCleanly(process)
228
228
 
229
229
    def test_bzr_serve_port_readonly(self):
230
 
        """bzr server should provide a read only filesystem by default."""
 
230
        """brz server should provide a read only filesystem by default."""
231
231
        process, url = self.start_server_port()
232
232
        t = transport.get_transport_from_url(url)
233
233
        self.assertRaises(errors.TransportNotPossible, t.mkdir, 'adir')
261
261
        # -Dhpss, and does drop some hpss logging to the file.
262
262
        self.make_branch('.')
263
263
        log_fname = os.getcwd() + '/server.log'
264
 
        self.overrideEnv('BZR_LOG', log_fname)
 
264
        self.overrideEnv('BRZ_LOG', log_fname)
265
265
        process, transport = self.start_server_inet(['-Dhpss'])
266
266
        branch = ControlDir.open_from_transport(transport).open_branch()
267
267
        self.make_read_requests(branch)
344
344
class TestCmdServeChrooting(TestBzrServeBase):
345
345
 
346
346
    def test_serve_tcp(self):
347
 
        """'bzr serve' wraps the given --directory in a ChrootServer.
 
347
        """'brz serve' wraps the given --directory in a ChrootServer.
348
348
 
349
349
        So requests that search up through the parent directories (like
350
350
        find_repositoryV3) will give "not found" responses, rather than