- Timestamp:
- Jan 26, 2020, 1:23:49 PM (12 months ago)
- Branches:
- asyncio, master, proxy-ticket
- Children:
- 264ab17
- Parents:
- 72ebe64
- Location:
- test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
test/mgstest/services.py
r72ebe64 re2200db 121 121 122 122 def wait_ready(self, timeout=None): 123 """Wait for the started service to be ready. The function passed to 124 the constructor as "check" is called to determine whether it is.""" 123 """Wait for the started service to be ready. 124 125 The function passed to the constructor as "check" is called to 126 determine whether it is. Waiting also ends if self.process 127 terminates. 128 129 Returns: None if the service is ready, or the return code if 130 the process has terminated. 131 132 Raises a TimeoutError if the given timeout has been exceeded. 133 134 """ 125 135 if not self.check: 126 return 136 return None 127 137 128 138 slept = 0 129 139 while not timeout or slept < timeout: 140 if self.process and self.process.poll(): 141 return self.process.returncode 130 142 if self.check(): 131 return 143 return None 132 144 else: 133 145 sleep(self._step) … … 165 177 valgrind_log=None): 166 178 self.config = Path(config).resolve() 167 self.forking = True168 179 base_cmd = [self.apache2, '-f', str(self.config), '-k'] 169 start_cmd = base_cmd + ['start'] 170 stop_cmd = base_cmd + ['stop'] 180 start_cmd = base_cmd + ['start', '-DFOREGROUND'] 171 181 if valgrind_log: 172 182 start_cmd = ['valgrind', '-s', '--leak-check=full', 173 183 '--track-origins=yes', '--vgdb=no', 174 184 f'--log-file={valgrind_log}'] \ 175 + start_cmd + ['-DFOREGROUND'] 176 self.forking = False 185 + start_cmd 177 186 if not check: 178 187 check = self.pidfile_check 179 188 super(ApacheService, self).__init__(start=start_cmd, 180 stop= stop_cmd,181 forking= self.forking,189 stop=base_cmd + ['stop'], 190 forking=False, 182 191 env=env, 183 192 pidfile=pidfile, -
test/runtest.py
r72ebe64 re2200db 169 169 170 170 # special case: expected to fail in a few cases 171 try: 172 service_stack.enter_context(apache.run()) 173 if os.path.exists(os.path.join(testdir, 'fail.server')): 174 raise TestExpectationFailed( 175 'Server start did not fail as expected!') 176 apache.wait_ready() 177 except subprocess.CalledProcessError as e: 178 if os.path.exists(os.path.join(testdir, 'fail.server')): 171 service_stack.enter_context(apache.run()) 172 failed = apache.wait_ready() 173 if os.path.exists(os.path.join(testdir, 'fail.server')): 174 if failed: 179 175 print('Apache server failed to start as expected', 180 176 file=sys.stderr) 181 177 else: 182 raise e 178 raise TestExpectationFailed( 179 'Server start did not fail as expected!') 183 180 184 181 # Set TEST_TARGET for the request. Might be replaced with a
Note: See TracChangeset
for help on using the changeset viewer.