~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/codehosting/codeimport/tests/servers.py

  • Committer: Jelmer Vernooij
  • Date: 2011-08-22 11:56:26 UTC
  • mto: This revision was merged to the branch mainline in revision 13767.
  • Revision ID: jelmer@canonical.com-20110822115626-43ooz1a5gnlvs4i7
Re-enable test_import_bzrsvn and others.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
__metaclass__ = type
14
14
 
15
15
from cStringIO import StringIO
 
16
import errno
16
17
import os
17
18
import shutil
18
19
import signal
114
115
            with open(conf_path , 'w') as conf_file:
115
116
                conf_file.write('[general]\nanon-access = write\n')
116
117
            self._svnserve = subprocess.Popen(
117
 
                ['svnserve', '--daemon', '--foreground', '--root',
118
 
                 self.repository_path])
 
118
                ['svnserve', '--daemon', '--foreground', '--threads',
 
119
                 '--root', self.repository_path])
119
120
            delay = 0.1
120
121
            for i in range(10):
121
122
                try:
122
 
                    ra = self._get_ra(self.get_url())
123
 
                except subvertpy.SubversionException, e:
124
 
                    if 'Connection refused' in str(e):
 
123
                    self._get_ra(self.get_url())
 
124
                except OSError, e:
 
125
                    if e.errno == errno.ECONNREFUSED:
125
126
                        time.sleep(delay)
126
127
                        delay *= 1.5
127
128
                        continue
128
129
                else:
129
130
                    break
130
131
            else:
 
132
                self._kill_svnserve()
131
133
                raise AssertionError(
132
134
                    "svnserve didn't start accepting connections")
133
135
 
 
136
    def _kill_svnserve(self):
 
137
        os.kill(self._svnserve.pid, signal.SIGINT)
 
138
        self._svnserve.communicate()
 
139
 
134
140
    def stop_server(self):
135
141
        super(SubversionServer, self).stop_server()
136
142
        if self._use_svn_serve:
137
 
            os.kill(self._svnserve.pid, signal.SIGINT)
138
 
            self._svnserve.communicate()
 
143
            self._kill_svnserve()
139
144
 
140
145
    def makeBranch(self, branch_name, tree_contents):
141
146
        """Create a branch on the Subversion server called `branch_name`.