def branches(src_dir, remote=True): if remote: # alternatively: git for-each-ref refs/remotes/ --format='%(refname:short)' return _cleanup_remote_branch_names(process.run_subprocess_with_output( "git -C {src} for-each-ref refs/remotes/ --format='%(refname:short)'".format(src=src_dir))) else: return _cleanup_local_branch_names( process.run_subprocess_with_output( "git -C {src} for-each-ref refs/heads/ --format='%(refname:short)'".format(src=src_dir)))
def probe(src, *args, **kwargs): # Probe for -C if not process.exit_status_as_bool(lambda: process.run_subprocess_with_logging("git -C %s --version" % src, level=logging.DEBUG)): version = process.run_subprocess_with_output("git --version") if version: version = str(version).strip() else: version = "Unknown" raise exceptions.SystemSetupError("Your git version is [%s] but Rally requires at least git 1.9. Please update git." % version) return f(src, *args, **kwargs)
def system_property(java_home, system_property_name): lines = process.run_subprocess_with_output("%s/bin/java -XshowSettings:properties -version" % java_home) # matches e.g. " java.runtime.version = 1.8.0_121-b13" and captures "1.8.0_121-b13" sys_prop_pattern = re.compile(r".*%s.*=\s?(.*)" % system_property_name) for line in lines: m = sys_prop_pattern.match(line) if m: return m.group(1) return None
def probe(src, *args, **kwargs): # Probe for -C if not process.exit_status_as_bool( lambda: process.run_subprocess_with_logging( "git -C {} --version".format(src), level=logging.DEBUG), quiet=True): version = process.run_subprocess_with_output("git --version") if version: version = str(version).strip() else: version = "Unknown" raise exceptions.SystemSetupError( "Your git version is [%s] but Rally requires at least git 1.9. Please update git." % version) return f(src, *args, **kwargs)
def install(self, distribution_version, node_name, car, http_port): self.http_port = http_port transport_port = http_port + 100 try: output = process.run_subprocess_with_output( "esrally install --configuration-name={cfg} --quiet --distribution-version={dist} --build-type=tar " "--http-port={http_port} --node={node_name} --master-nodes={node_name} --car={car} " "--seed-hosts=\"127.0.0.1:{transport_port}\"".format(cfg=self.cfg, dist=distribution_version, http_port=http_port, node_name=node_name, car=car, transport_port=transport_port)) self.installation_id = json.loads("".join(output))["installation-id"] except BaseException as e: raise AssertionError("Failed to install Elasticsearch {}.".format(distribution_version), e)
def test_run_without_http_connection(cfg): cmd = it.esrally_command_line_for(cfg, "list races") output = process.run_subprocess_with_output(cmd, {"http_proxy": "http://invalid"}) expected = "No Internet connection detected. Specify --offline" assert expected in "\n".join(output)
def test_run_with_help(cfg): cmd = it.esrally_command_line_for(cfg, "--help") output = process.run_subprocess_with_output(cmd) expected = "usage: esrally [-h] [--version]" assert expected in "\n".join(output)
def tags(src_dir): return _cleanup_tag_names( process.run_subprocess_with_output("git -C {0} tag".format( io.escape_path(src_dir))))
def current_branch(src_dir): return process.run_subprocess_with_output( "git -C {0} rev-parse --abbrev-ref HEAD".format( io.escape_path(src_dir)))[0].strip()
def head_revision(src_dir): return process.run_subprocess_with_output( "git -C {0} rev-parse --short HEAD".format( io.escape_path(src_dir)))[0].strip()
def _get_container_id(self, compose_config): compose_ps_cmd = self._docker_compose(compose_config, "ps -q") return process.run_subprocess_with_output(compose_ps_cmd)[0]
def head_revision(src_dir): return process.run_subprocess_with_output( "git -C {0} rev-parse --short HEAD".format(src_dir))[0]
def pull_ts(src_dir, ts): fetch(src_dir) revision = process.run_subprocess_with_output( "git -C {0} rev-list -n 1 --before=\"{1}\" --date=iso8601 origin/master".format(src_dir, ts))[0].strip() if process.run_subprocess_with_logging("git -C {0} checkout {1}".format(src_dir, revision)): raise exceptions.SupplyError("Could not checkout source tree for timestamped revision [%s]" % ts)
def head_revision(src_dir): return process.run_subprocess_with_output("git -C {0} rev-parse --short HEAD".format(src_dir))[0].strip()