def test_explicit_cipd_version_file_empty_string(self): self.config['cipd_version_file'] = '' self.assertEqual({}, version_finder.find_version(self.config)) with open(os.path.join(self.path, 'CIPD_VERSION.json'), 'w') as fh: fh.write('{"package_name": "foo", "instance_id": "bar"}') self.assertEqual( { 'cipd_version_file': { 'package_name': 'foo', 'instance_id': 'bar', } }, version_finder.find_version(self.config))
def has_version_changed(self, state): """Returns True if the version has changed since the process started.""" if state.version is None: return False return state.version != version_finder.find_version(self.config)
def has_version_changed(self, state): """Returns True if the version has changed since the process started.""" if state.version is None: return False return state.version != version_finder.find_version(self.config)
def test_cipd_version_file(self): with open(os.path.join(self.path, 'CIPD_VERSION.json'), 'w') as fh: fh.write('{"package_name": "foo", "instance_id": "bar"}') self.assertEqual({'cipd_version_file': { 'package_name': 'foo', 'instance_id': 'bar', }}, version_finder.find_version(self.config))
def _write_state_file(self, pid): try: state = ProcessState.from_pid(pid) except ProcessStateError as ex: raise ServiceException( 'Failed to start %s: daemon process exited (%r)' % (self.name, ex)) state.version = version_finder.find_version(self.config) state.cmd = self._cmd state.write_to_file(self._state_file)
def _write_state_file(self, pid): try: state = ProcessState.from_pid(pid) except ProcessStateError as ex: raise ServiceException( 'Failed to start %s: daemon process exited (%r)' % (self.name, ex)) state.version = version_finder.find_version(self.config) state.args = self.args state.write_to_file(self._state_file)
def test_cipd_version_file(self): with open(self.cipd_version_file, 'w') as fh: fh.write('{"package_name": "foo", "instance_id": "bar"}') self.assertEqual( { 'cipd_version_file': { 'package_name': 'foo', 'instance_id': 'bar', } }, version_finder.find_version(self.config))
def test_explicit_cipd_version_file(self): self.config['cipd_version_file'] = os.path.join(self.path, 'foo') with open(self.config['cipd_version_file'], 'w') as fh: fh.write('{"package_name": "foo", "instance_id": "bar"}') self.assertEqual( { 'cipd_version_file': { 'package_name': 'foo', 'instance_id': 'bar', } }, version_finder.find_version(self.config))
def has_version_changed(self, state): """Returns True if the version has changed since the process started. Args: state(ProcessState): a process state. Returns: changed(bool): True if the running version does not match the one deployed on disk. """ if state.version is None: return False deployed_version = version_finder.find_version(self.config) if state.version != deployed_version: LOGGER.info('Version changed: %s -> %s. (cmd: %s)' % (state.version, deployed_version, str(state.cmd))) return True return False
def has_version_changed(self, state): """Returns True if the version has changed since the process started. Args: state(ProcessState): a process state. Returns: changed(bool): True if the running version does not match the one deployed on disk. """ if state.version is None: return False deployed_version = version_finder.find_version(self.config) if state.version != deployed_version: LOGGER.info('Version changed: %s -> %s. (cmd: %s)' % (state.version, deployed_version, str(state.cmd))) return True return False
def test_explicit_cipd_version_file_does_not_exist(self): self.config['cipd_version_file'] = os.path.join(self.path, 'foo') self.assertEqual({}, version_finder.find_version(self.config))
def test_missing_directory(self): self.assertEqual({}, version_finder.find_version({ 'root_directory': '/does/not/exist', }))
def test_empty_directory(self): self.assertEqual({}, version_finder.find_version(self.config))
def test_explicit_cipd_version_file_empty_string(self): self.config['cipd_version_file'] = '' self.assertEqual({}, version_finder.find_version(self.config))
def test_missing_directory(self): self.assertEqual({}, version_finder.find_version({ 'root_directory': '/does/not/exist', }))
def test_empty_directory(self): self.assertEqual({}, version_finder.find_version(self.config))