def _parse_java_version(line: str) -> tuple: """ Return the version number found in the first line of `java -version` >>> _parse_java_version('openjdk version "11.0.2" 2018-10-16') (11, 0, 2) """ m = VERSION_RE.search(line) version_str = m and m.group(0).replace('"', '') or '0.0.0' if '_' in version_str: fst, snd = version_str.split('_', maxsplit=2) version = parse_version(fst) return (version[1], version[2], int(snd)) else: return parse_version(version_str)
def __init__(self, spec_dir, benchmark_hosts, result_hosts, log, fail_if, sample_mode): self.benchmark_hosts = benchmark_hosts self.sample_mode = sample_mode self.spec_dir = spec_dir self.client = clients.client(benchmark_hosts) self.result_client = clients.client(result_hosts) self.server_version_info = aio.run(self.client.get_server_version) self.server_version = parse_version(self.server_version_info['number']) self.log = log self.create_result = partial( Result, version_info=self.server_version_info ) if fail_if: self.fail_if = partial(eval_fail_if, fail_if) else: self.fail_if = lambda x: None if result_hosts: self.process_result = _result_to_crate(self.log, self.result_client) else: self.process_result = log.result
def retrieve_columns(client, schema, table): r = aio.run(client.execute, "select min(version['number']) from sys.nodes") version = parse_version(r['rows'][0][0]) stmt = SELLECT_COLS.format( schema_column_name='table_schema' if version >= (0, 57, 0) else 'schema_name') r = aio.run(client.execute, stmt, (schema, table)) return OrderedDict(r['rows'])
def _get_uri_from_released_version(version: str) -> str: version_tup = parse_version(version) if version_tup < (4, 2, 0): return RELEASE_URL.format(version=version) try: return ReleaseUrlSegments.create().get_uri(version) except ValueError: # Unsupported platform, just return the linux tarball return RELEASE_URL.format(version=version)
async def _async_reindex(client): version_dict = await client.get_server_version() version = parse_version(version_dict['number']) if version < (3, 3, 0): raise ValueError( "reindex only works on a CrateDB cluster running 3.3.0 or later") tables = await _fetch_tables_to_upgrade(client, version) for schema, table in tables: create_table = await _show_create_table(client, f'{schema}.{table}') column_names = await _fetch_column_names(client, schema, table) await _reindex_table(client, schema, table, create_table, column_names)
async def _async_reindex(client): version_dict = await client.get_server_version() version = parse_version(version_dict['number']) if version < (3, 3, 0): raise ValueError( "reindex only works on a CrateDB cluster running 3.3.0 or later") tables = await _fetch_tables_to_upgrade(client, version) for schema, table in tables: if schema == 'blob': print(f'Skipping unsupported BLOB table "{schema}"."{table}"') continue create_table = await _show_create_table(client, f'"{schema}"."{table}"') column_names = await _fetch_column_names(client, schema, table) await _reindex_table(client, schema, table, create_table, column_names)
def run_queries(self, queries, meta=None): for query in queries: stmt = query['statement'] iterations = query.get('iterations', 1) duration = query.get('duration', None) concurrency = query.get('concurrency', 1) args = query.get('args') bulk_args = query.get('bulk_args') _min_version = query.get('min_version') min_version = _min_version and parse_version(_min_version) if min_version and min_version > self.server_version: self.log.info(self._skip_message(min_version, stmt)) continue mode_desc = 'Duration' if duration else 'Iterations' self.log.info( (f'\n## Running Query:\n' f' Statement:\n' f' {stmt}\n' f' Concurrency: {concurrency}\n' f' {mode_desc}: {duration or iterations}') ) with Runner(self.benchmark_hosts, concurrency, self.sample_mode) as runner: timed_stats = runner.run( stmt, iterations=iterations, duration=duration, args=args, bulk_args=bulk_args ) result = self.create_result( statement=stmt, meta=meta, timed_stats=timed_stats, concurrency=concurrency, bulk_size=try_len(bulk_args) ) self.process_result(result) self.fail_if(result)
def _extract_version(crate_dir) -> tuple: m = FOLDER_VERSION_RE.findall(crate_dir) if m: return parse_version(m[0]) return (1, 0, 0)
def _extract_version(crate_dir) -> tuple: m = FOLDER_VERSION_RE.findall(crate_dir) if m: return parse_version(m[0]) return (1, 0, 0)