mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-28 05:34:02 +00:00
ci: support full image references in benchmark comparisons
Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
@@ -27,19 +27,38 @@ def read(path):
|
||||
return json.loads(path.read_text()) if path.is_file() else {}
|
||||
|
||||
|
||||
def image_reference(env, baseline=False):
|
||||
prefix = 'BASELINE_GREPTIMEDB' if baseline else 'GREPTIMEDB'
|
||||
image = env.get(prefix + '_IMAGE_REF', '')
|
||||
if not image:
|
||||
tag = env.get(prefix + '_TAG', '')
|
||||
if not re.fullmatch(r'[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}(@sha256:[0-9a-f]{64})?', tag):
|
||||
raise ValueError(f'Invalid {prefix}_TAG')
|
||||
image = 'greptime/greptimedb:' + tag
|
||||
# Require an explicit tag or digest and reject target-spec separators.
|
||||
if not re.fullmatch(
|
||||
r'[a-z0-9]+(?:[._-][a-z0-9]+)*(?::[0-9]+)?'
|
||||
r'(?:/[a-z0-9]+(?:[._-][a-z0-9]+)*)+'
|
||||
r'(?::[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127})?'
|
||||
r'(?:@sha256:[0-9a-f]{64})?', image):
|
||||
raise ValueError(f'Invalid {prefix} image reference')
|
||||
if ':' not in image.rsplit('/', 1)[-1]:
|
||||
raise ValueError('Image reference requires a tag or digest')
|
||||
return image
|
||||
|
||||
|
||||
def validate(env):
|
||||
enabled = env.get('COMPARE_GREPTIMEDB', 'false')
|
||||
if enabled not in ('true', 'false'):
|
||||
raise ValueError('COMPARE_GREPTIMEDB must be true or false')
|
||||
if env.get('RUN_GREPTIMEDB') == 'true':
|
||||
image_reference(env)
|
||||
if enabled == 'false':
|
||||
return
|
||||
if env.get('RUN_GREPTIMEDB') != 'true':
|
||||
raise ValueError('Version comparison requires Run GreptimeDB')
|
||||
for key in ('BASELINE_GREPTIMEDB_TAG', 'GREPTIMEDB_TAG'):
|
||||
if not re.fullmatch(r'[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}(@sha256:[0-9a-f]{64})?', env.get(key, '')):
|
||||
raise ValueError(f'Invalid {key}')
|
||||
if env['BASELINE_GREPTIMEDB_TAG'] == env['GREPTIMEDB_TAG']:
|
||||
raise ValueError('Baseline and candidate must have different image tags')
|
||||
if image_reference(env, baseline=True) == image_reference(env):
|
||||
raise ValueError('Baseline and candidate must have different images')
|
||||
|
||||
|
||||
def same(a, b, fields):
|
||||
@@ -154,7 +173,7 @@ def render(document):
|
||||
return f'{v:.3f}'
|
||||
return f'{v / 1000:.2f} s' if v >= 1000 else f'{v:.2f} ms'
|
||||
lines = ['# GreptimeDB version comparison', '',
|
||||
f'Baseline: `{cell(document["baseline_tag"])}` → candidate: `{cell(document["candidate_tag"])}`.', '',
|
||||
f'Baseline: `{cell(document.get("baseline_image") or document["baseline_tag"])}` → candidate: `{cell(document.get("candidate_image") or document["candidate_tag"])}`.', '',
|
||||
'Same-host sequential runs with fresh databases and shared input data. Positive = improvement; '
|
||||
'latency: (baseline − candidate) / baseline; QPS: (candidate − baseline) / baseline. '
|
||||
'Single runs are diagnostic, not a statistically established regression. No performance threshold gates CI.', '',
|
||||
@@ -184,6 +203,8 @@ def main():
|
||||
parser.error('report requires --root and --kind')
|
||||
document = {'kind': args.kind, 'baseline_tag': os.environ.get('BASELINE_GREPTIMEDB_TAG', ''),
|
||||
'candidate_tag': os.environ.get('GREPTIMEDB_TAG', ''),
|
||||
'baseline_image': os.environ.get('BASELINE_GREPTIMEDB_IMAGE_REF', ''),
|
||||
'candidate_image': os.environ.get('GREPTIMEDB_IMAGE_REF', ''),
|
||||
'rows': []}
|
||||
mode = os.environ.get('GREPTIMEDB_STORAGE', 'file')
|
||||
for storage in (['file', 's3'] if mode == 'both' else [mode]):
|
||||
|
||||
@@ -36,6 +36,16 @@ on:
|
||||
type: boolean
|
||||
default: false
|
||||
required: false
|
||||
baseline_greptimedb_image:
|
||||
description: Full baseline image reference; overrides baseline_greptimedb_tag
|
||||
type: string
|
||||
default: ''
|
||||
required: false
|
||||
greptimedb_image:
|
||||
description: Full candidate image reference; overrides greptimedb_tag
|
||||
type: string
|
||||
default: ''
|
||||
required: false
|
||||
baseline_greptimedb_tag:
|
||||
description: Baseline Docker Hub greptime/greptimedb tag; required when comparison is enabled
|
||||
type: string
|
||||
@@ -110,6 +120,8 @@ env:
|
||||
RUNNER_REGION: ${{ vars.EC2_RUNNER_REGION }}
|
||||
RUN_GREPTIMEDB: ${{ inputs.run_greptimedb }}
|
||||
COMPARE_GREPTIMEDB: ${{ inputs.compare_greptimedb }}
|
||||
BASELINE_GREPTIMEDB_IMAGE_REF: ${{ inputs.baseline_greptimedb_image || format('greptime/greptimedb:{0}', inputs.baseline_greptimedb_tag) }}
|
||||
GREPTIMEDB_IMAGE_REF: ${{ inputs.greptimedb_image || format('greptime/greptimedb:{0}', inputs.greptimedb_tag) }}
|
||||
BASELINE_GREPTIMEDB_TAG: ${{ inputs.baseline_greptimedb_tag }}
|
||||
PROFILE: ${{ inputs.dataset }}
|
||||
GREPTIMEDB_TAG: ${{ inputs.greptimedb_tag }}
|
||||
@@ -353,13 +365,13 @@ jobs:
|
||||
for target in greptimedb clickhouse victorialogs; do
|
||||
[[ "$TARGETS" == all || ",$TARGETS," == *",$target,"* ]] || continue
|
||||
case "$target" in
|
||||
greptimedb) resolve_image "$target" "greptime/greptimedb:$GREPTIMEDB_TAG" GREPTIMEDB_IMAGE ;;
|
||||
greptimedb) resolve_image "$target" "$GREPTIMEDB_IMAGE_REF" GREPTIMEDB_IMAGE ;;
|
||||
clickhouse) resolve_image "$target" "clickhouse/clickhouse-server:$CLICKHOUSE_TAG" CLICKHOUSE_IMAGE ;;
|
||||
victorialogs) resolve_image "$target" "victoriametrics/victoria-logs:$VICTORIALOGS_TAG" VICTORIALOGS_IMAGE ;;
|
||||
esac
|
||||
done
|
||||
if [[ "$COMPARE_GREPTIMEDB" == true ]]; then
|
||||
resolve_image greptimedb-baseline "greptime/greptimedb:$BASELINE_GREPTIMEDB_TAG" BASELINE_GREPTIMEDB_IMAGE
|
||||
resolve_image greptimedb-baseline "$BASELINE_GREPTIMEDB_IMAGE_REF" BASELINE_GREPTIMEDB_IMAGE
|
||||
fi
|
||||
jq -n --arg sha "$actual" --arg targets "$TARGETS" --arg profile "$PROFILE" \
|
||||
--arg cpus "$DB_CPUS" --arg memory "$DB_MEMORY" --argjson images "$images" \
|
||||
|
||||
@@ -27,6 +27,16 @@ on:
|
||||
type: boolean
|
||||
default: false
|
||||
required: false
|
||||
baseline_greptimedb_image:
|
||||
description: Full baseline image reference; overrides baseline_greptimedb_tag
|
||||
type: string
|
||||
default: ''
|
||||
required: false
|
||||
greptimedb_image:
|
||||
description: Full candidate image reference; overrides greptimedb_tag
|
||||
type: string
|
||||
default: ''
|
||||
required: false
|
||||
baseline_greptimedb_tag:
|
||||
description: Baseline Docker Hub greptime/greptimedb tag; required when comparison is enabled
|
||||
type: string
|
||||
@@ -118,6 +128,8 @@ env:
|
||||
RUNNER_REGION: ${{ vars.EC2_RUNNER_REGION }}
|
||||
RUN_GREPTIMEDB: ${{ inputs.run_greptimedb }}
|
||||
COMPARE_GREPTIMEDB: ${{ inputs.compare_greptimedb }}
|
||||
BASELINE_GREPTIMEDB_IMAGE_REF: ${{ inputs.baseline_greptimedb_image || format('greptime/greptimedb:{0}', inputs.baseline_greptimedb_tag) }}
|
||||
GREPTIMEDB_IMAGE_REF: ${{ inputs.greptimedb_image || format('greptime/greptimedb:{0}', inputs.greptimedb_tag) }}
|
||||
BASELINE_GREPTIMEDB_TAG: ${{ inputs.baseline_greptimedb_tag }}
|
||||
DATASET: ${{ inputs.dataset }}
|
||||
GREPTIMEDB_TAG: ${{ inputs.greptimedb_tag }}
|
||||
@@ -169,7 +181,7 @@ jobs:
|
||||
done
|
||||
[[ -n "$selected" ]] || { echo 'Select at least one database' >&2; exit 1; }
|
||||
if [[ "$greptimedb" == true ]]; then
|
||||
[[ "$GREPTIMEDB_TAG" =~ ^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}$ ]] || { echo 'Invalid GreptimeDB image tag' >&2; exit 1; }
|
||||
# Full GreptimeDB image references are validated by the shared comparison helper.
|
||||
fi
|
||||
printf 'targets=%s\n' "$selected" >> "$GITHUB_OUTPUT"
|
||||
- name: Validate GreptimeDB storage
|
||||
@@ -378,7 +390,7 @@ jobs:
|
||||
IFS=, read -ra targets <<< "$TARGETS"
|
||||
for target in "${targets[@]}"; do
|
||||
if [[ "$target" == greptimedb ]]; then
|
||||
image="greptime/greptimedb:$GREPTIMEDB_TAG"
|
||||
image="$GREPTIMEDB_IMAGE_REF"
|
||||
else
|
||||
image=$(jq -er '.target_identity.image | select(test("@sha256:[a-f0-9]{64}$"))' \
|
||||
"o11ybench/workloads/tracesbench/catalogs/$target.json")
|
||||
@@ -391,7 +403,7 @@ jobs:
|
||||
fi
|
||||
done
|
||||
if [[ "$COMPARE_GREPTIMEDB" == true ]]; then
|
||||
image="greptime/greptimedb:$BASELINE_GREPTIMEDB_TAG"
|
||||
image="$BASELINE_GREPTIMEDB_IMAGE_REF"
|
||||
bash greptimedb/.github/scripts/pull-benchmark-image.sh "$image"
|
||||
docker image inspect "$image" > "$METADATA_ROOT/greptimedb-baseline-image.json"
|
||||
resolved=$(jq -er '.[0].RepoDigests[0] | select(test("@sha256:[a-f0-9]{64}$"))' "$METADATA_ROOT/greptimedb-baseline-image.json")
|
||||
|
||||
@@ -35,6 +35,16 @@ on:
|
||||
type: boolean
|
||||
default: false
|
||||
required: false
|
||||
baseline_greptimedb_image:
|
||||
description: Full baseline image reference; overrides baseline_greptimedb_tag
|
||||
type: string
|
||||
default: ''
|
||||
required: false
|
||||
greptimedb_image:
|
||||
description: Full candidate image reference; overrides greptimedb_tag
|
||||
type: string
|
||||
default: ''
|
||||
required: false
|
||||
baseline_greptimedb_tag:
|
||||
description: Baseline Docker Hub greptime/greptimedb tag; required when comparison is enabled
|
||||
type: string
|
||||
@@ -110,6 +120,8 @@ env:
|
||||
RUNNER_REGION: ${{ vars.EC2_RUNNER_REGION }}
|
||||
RUN_GREPTIMEDB: ${{ inputs.run_greptimedb }}
|
||||
COMPARE_GREPTIMEDB: ${{ inputs.compare_greptimedb }}
|
||||
BASELINE_GREPTIMEDB_IMAGE_REF: ${{ inputs.baseline_greptimedb_image || format('greptime/greptimedb:{0}', inputs.baseline_greptimedb_tag) }}
|
||||
GREPTIMEDB_IMAGE_REF: ${{ inputs.greptimedb_image || format('greptime/greptimedb:{0}', inputs.greptimedb_tag) }}
|
||||
BASELINE_GREPTIMEDB_TAG: ${{ inputs.baseline_greptimedb_tag }}
|
||||
BENCHMARK_ROOT: ${{ inputs.benchmark_root }}
|
||||
RANGE_PRESET: ${{ inputs.range_preset }}
|
||||
@@ -203,7 +215,7 @@ jobs:
|
||||
--db-cpus "$DB_CPUS" --db-memory "$DB_MEMORY"
|
||||
--run-classification controlled_server_benchmark --no-open-browser)
|
||||
if [[ "$COMPARE_GREPTIMEDB" == true ]]; then
|
||||
args+=(--target "greptimedb:name=greptimedb-baseline,image=greptime/greptimedb:$BASELINE_GREPTIMEDB_TAG,url=http://127.0.0.1:14000/v1/prometheus/api/v1/query_range")
|
||||
args+=(--target "greptimedb:name=greptimedb-baseline,image=$BASELINE_GREPTIMEDB_IMAGE_REF,url=http://127.0.0.1:14000/v1/prometheus/api/v1/query_range")
|
||||
fi
|
||||
# Tags become target-spec fields; reject separators before passing them to the planner.
|
||||
for target in greptimedb victoriametrics prometheus; do
|
||||
@@ -213,8 +225,13 @@ jobs:
|
||||
prometheus) enabled=$RUN_PROMETHEUS; tag=$PROMETHEUS_TAG; repo=prom/prometheus; url=http://127.0.0.1:19090/api/v1/query_range ;;
|
||||
esac
|
||||
[[ "$enabled" == true ]] || continue
|
||||
[[ "$tag" =~ ^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}(@sha256:[0-9a-f]{64})?$ ]]
|
||||
args+=(--target "$target:name=$target,image=$repo:$tag,url=$url")
|
||||
if [[ "$target" == greptimedb ]]; then
|
||||
image=$GREPTIMEDB_IMAGE_REF
|
||||
else
|
||||
[[ "$tag" =~ ^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}(@sha256:[0-9a-f]{64})?$ ]]
|
||||
image=$repo:$tag
|
||||
fi
|
||||
args+=(--target "$target:name=$target,image=$image,url=$url")
|
||||
done
|
||||
# The packaged planner owns profile, target and resource-limit validation.
|
||||
mkdir -p "$RUNNER_TEMP/vmbench-plans"
|
||||
|
||||
@@ -44,6 +44,24 @@ class VersionComparison(unittest.TestCase):
|
||||
with self.subTest(key=key, value=value), self.assertRaises(ValueError):
|
||||
comparison.validate(good | {key: value})
|
||||
|
||||
def test_full_image_references(self):
|
||||
base = 'greptime/greptimedb@sha256:' + 'a' * 64
|
||||
candidate = 'greptime/greptimedb-dev@sha256:' + 'b' * 64
|
||||
env = dict(COMPARE_GREPTIMEDB='true', RUN_GREPTIMEDB='true',
|
||||
BASELINE_GREPTIMEDB_IMAGE_REF=base, GREPTIMEDB_IMAGE_REF=candidate)
|
||||
comparison.validate(env)
|
||||
self.assertEqual(comparison.image_reference(env), candidate)
|
||||
comparison.validate(env | {'GREPTIMEDB_TAG': 'ignored'})
|
||||
comparison.validate(env | {'COMPARE_GREPTIMEDB': 'false'})
|
||||
for value in [base, 'greptime/greptimedb', candidate + ',url=other',
|
||||
candidate + '\n', 'https://example.com/image:tag',
|
||||
'greptime/greptimedb@sha256:bad']:
|
||||
with self.subTest(value=value), self.assertRaises(ValueError):
|
||||
comparison.validate(env | {'GREPTIMEDB_IMAGE_REF': value})
|
||||
with self.assertRaises(ValueError):
|
||||
comparison.validate(env | {'COMPARE_GREPTIMEDB': 'false',
|
||||
'GREPTIMEDB_IMAGE_REF': 'bad'})
|
||||
|
||||
def test_improvement_direction(self):
|
||||
self.assertAlmostEqual(comparison.improvement(100, 80), 20)
|
||||
self.assertAlmostEqual(comparison.improvement(100, 120), -20)
|
||||
|
||||
Reference in New Issue
Block a user