diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 323d0652..1bb9a1db 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -74,6 +74,11 @@ "source": "./plugins/must-gather", "description": "A plugin to analyze and report on must-gather data" }, + { + "name": "microshift-prow-job", + "source": "./plugins/microshift-prow-job", + "description": "Analyze MicroShift Test Results from Prow CI jobs" + }, { "name": "hcp", "source": "./plugins/hcp", diff --git a/PLUGINS.md b/PLUGINS.md index 13ef9a73..3d481a63 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -10,6 +10,7 @@ This document lists all available Claude Code plugins and their commands in the - [Hcp](#hcp-plugin) - [Hello World](#hello-world-plugin) - [Jira](#jira-plugin) +- [Microshift Prow Job](#microshift-prow-job-plugin) - [Must Gather](#must-gather-plugin) - [Olm](#olm-plugin) - [Openshift](#openshift-plugin) @@ -107,6 +108,16 @@ A plugin to automate tasks with Jira See [plugins/jira/README.md](plugins/jira/README.md) for detailed documentation. +### Microshift Prow Job Plugin + +Analyze MicroShift Prow CI jobs + +**Commands:** +- **`/microshift-prow-job:analyze-job` ``** - Analyze a MicroShift Prow CI job execution +- **`/microshift-prow-job:analyze-test-scenario` ` `** - Analyze MicroShift Test Scenario results + +See [plugins/microshift-prow-job/README.md](plugins/microshift-prow-job/README.md) for detailed documentation. + ### Must Gather Plugin A plugin to analyze and report on must-gather data diff --git a/docs/data.json b/docs/data.json index d8ef00f4..85708b04 100644 --- a/docs/data.json +++ b/docs/data.json @@ -558,6 +558,33 @@ ], "has_readme": true }, + { + "name": "microshift-prow-job", + "description": "Analyze MicroShift Test Results from Prow CI jobs", + "version": "0.0.1", + "commands": [ + { + "name": "analyze-job", + "description": "Analyze a MicroShift Prow CI job execution", + "synopsis": "/microshift-prow-job:analyze-job ", + "argument_hint": "" + }, + { + "name": "analyze-test-scenario", + "description": "Analyze MicroShift Test Scenario results", + "synopsis": "/microshift-prow-job:analyze-test-scenario ", + "argument_hint": " " + } + ], + "skills": [ + { + "name": "Extract MicroShift Version", + "id": "extract-microshift-version", + "description": "Extract MicroShift version and build type from Prow CI build logs" + } + ], + "has_readme": true + }, { "name": "hcp", "description": "Generate HyperShift cluster creation commands via hcp CLI from natural language descriptions", diff --git a/plugins/microshift-prow-job/.claude-plugin/plugin.json b/plugins/microshift-prow-job/.claude-plugin/plugin.json new file mode 100644 index 00000000..556d3036 --- /dev/null +++ b/plugins/microshift-prow-job/.claude-plugin/plugin.json @@ -0,0 +1,10 @@ +{ + "name": "microshift-prow-job", + "description": "Analyze MicroShift Prow CI jobs", + "version": "0.0.1", + "author": { + "name": "Alejandro Gullón", + "email": "agullon@redhat.com", + "url": "https://github.com/agullon" + } +} diff --git a/plugins/microshift-prow-job/README.md b/plugins/microshift-prow-job/README.md new file mode 100644 index 00000000..c1e0de0f --- /dev/null +++ b/plugins/microshift-prow-job/README.md @@ -0,0 +1,337 @@ +# MicroShift Prow Jobs Plugin + +A Claude Code plugin for analyzing MicroShift Prow CI job executions, test results, and scenarios. + +## Overview + +The `microshift-prow-job` plugin provides commands to fetch and analyze detailed information from MicroShift CI jobs running on OpenShift's Prow CI infrastructure. It helps developers and QE engineers understand test results, diagnose failures, and track MicroShift version testing across different configurations. + +## Features + +- **Comprehensive Job Analysis**: Get detailed information about any MicroShift CI job execution +- **Scenario-Level Testing Details**: Analyze individual test scenarios with structured JSON output +- **Version Detection**: Automatically extract MicroShift versions being tested +- **Build Type Classification**: Identify nightly, RC, EC, and stable builds +- **Test Result Parsing**: Parse JUnit XML and extract pass/fail statistics +- **Artifact Access**: Direct links to all logs, test reports, and artifacts + +## Commands + +### `/microshift-prow-job:analyze-job` + +Analyzes a complete MicroShift Prow CI job execution, providing: +- Job metadata (status, timing, architecture, image type) +- MicroShift version being tested (with build type detection) +- Comprehensive test scenario results with pass/fail statistics +- Failure analysis with detailed error messages +- Build information +- Direct links to all logs and artifacts + +**Usage:** +``` +/microshift-prow-job:analyze-job +``` + +**Arguments:** +- `job-url`: URL to the Prow CI job (supports Prow dashboard URLs, GCS web URLs, or job ID) + +**Example:** +``` +/microshift-prow-job:analyze-job https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic/1979744605507162112 +``` + +**Output:** Comprehensive Markdown report with job overview, MicroShift version details, test scenario results with pass/fail counts, failure analysis, build information, and artifact links. + +--- + +### `/microshift-prow-job:analyze-test-scenario` + +Retrieves comprehensive information about a specific test scenario within a MicroShift CI job in structured JSON format. + +**Usage:** +``` +/microshift-prow-job:analyze-test-scenario [scenario-name] +``` + +**Arguments:** +- `job-url`: URL to the Prow CI job (required) +- `scenario-name`: Name of the scenario to analyze (e.g., `el96-lrel@standard1`) + - If omitted, lists all available scenarios + +**Examples:** + +1. **Get detailed scenario information:** +``` +/microshift-prow-job:analyze-test-scenario https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic/1979744605507162112 el96-lrel@standard1 +``` + +2. **List all scenarios in a job:** +``` +/microshift-prow-job:analyze-test-scenario https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic/1979744605507162112 +``` + +**Output:** Structured JSON object containing scenario configuration, test results, MicroShift version, execution timing, and artifact links. + +## Helper Scripts + +### `extract_microshift_version.py` + +A Python script that extracts the exact MicroShift version being tested from Prow CI job logs. + +**Location:** `plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py` + +**Usage:** +```bash +python3 plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py +``` + +**Arguments:** +- `job_id`: The Prow CI job ID (e.g., "1982281180531134464") +- `version`: The release version (e.g., "4.20") +- `job_type`: The job type identifier: + - `e2e-aws-tests-bootc-release-periodic` (bootc x86_64) + - `e2e-aws-tests-bootc-release-arm-periodic` (bootc aarch64) + - `e2e-aws-tests-release-periodic` (rpm-ostree x86_64) + - `e2e-aws-tests-release-arm-periodic` (rpm-ostree aarch64) + +**Example:** +```bash +python3 plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py \ + 1979744605507162112 \ + 4.20 \ + e2e-aws-tests-bootc-release-periodic +``` + +**Output:** +```json +{ + "success": true, + "version": "4.20.0-202510161342.p0.g17d1d9a.assembly.4.20.0.el9.x86_64", + "build_type": "zstream", + "url": "https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/...", + "error": null +} +``` + +**Build Types:** +- `nightly`: Nightly development builds +- `ec`: Engineering Candidate +- `rc`: Release Candidate +- `zstream`: Stable/zstream release + +## Installation + +### From Claude Code Marketplace + +```bash +# Add the ai-helpers marketplace +/plugin marketplace add openshift-eng/ai-helpers + +# Install the plugin +/plugin install microshift-prow-job@ai-helpers +``` + +### Manual Installation + +```bash +# Clone the repository +git clone git@github.com:openshift-eng/ai-helpers.git + +# Link to Claude Code plugins directory +cd ~/.claude/plugins +ln -s /path/to/ai-helpers/plugins/microshift-prow-job microshift-prow-job +``` + +## Common Use Cases + +### 1. Investigate a Failed CI Job + +``` +/microshift-prow-job:analyze-job https://prow.ci.openshift.org/view/gs/test-platform-results/logs/... +``` + +This provides a complete overview of what failed, which scenarios had issues, detailed failure messages, and links to relevant logs. + +### 2. Compare Test Results Across Scenarios + +``` +# First, list all scenarios +/microshift-prow-job:analyze-test-scenario + +# Then analyze specific scenarios +/microshift-prow-job:analyze-test-scenario el96-lrel@standard1 +/microshift-prow-job:analyze-test-scenario el96-lrel@lvm +``` + +### 3. Track Version Testing + +Use the version extraction to understand exactly what MicroShift version was tested: + +```bash +python3 plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py \ + 1979744605507162112 4.20 e2e-aws-tests-bootc-release-periodic +``` + +### 4. Automated Analysis + +The JSON output from `analyze-test-scenario` can be piped to other tools for automated analysis: + +```bash +# Extract JSON and process with jq +/microshift-prow-job:analyze-test-scenario | jq '.test_results.summary' +``` + +## Understanding Test Scenarios + +MicroShift CI tests run across multiple scenarios, each testing different configurations: + +### Scenario Naming Convention + +Format: `{source-os}@{target-os}@{test-type}` or `{os}@{test-type}` + +Examples: +- `el96-lrel@standard1`: RHEL 9.6 Latest Release - Standard Tests (variant 1) +- `el94-y2@el96-lrel@standard1`: Upgrade from RHEL 9.4 (Y-2) to 9.6 - Standard Tests +- `el96-lrel@lvm`: RHEL 9.6 Latest Release - LVM Storage Tests + +### Common Test Categories + +| Test Type | Description | +|-----------|-------------| +| `standard1`, `standard2` | Basic functionality tests (different variants) | +| `lvm` | LVM storage configuration tests | +| `storage` | Storage subsystem tests including CSI and snapshotter | +| `dual-stack` | Dual-stack IPv4/IPv6 networking tests | +| `ipv6` | IPv6-only networking tests | +| `multi-nic` | Multiple network interface tests | +| `router` | OpenShift router and ingress tests | +| `osconfig` | OS configuration and system settings tests | +| `optional` | Optional component functionality tests | +| `telemetry` | Telemetry and monitoring tests | +| `low-latency` | Low-latency kernel and configuration tests | +| `ginkgo-tests` | OpenShift Ginkgo integration tests | +| `ai-model-serving-online` | AI model serving capability tests | + +### Job Types + +MicroShift CI runs tests across different configurations: + +| Configuration | Architecture | Image Type | Job Type Identifier | +|--------------|-------------|------------|---------------------| +| Bootc x86_64 | x86_64 | bootc | `e2e-aws-tests-bootc-release-periodic` | +| Bootc ARM | aarch64 | bootc | `e2e-aws-tests-bootc-release-arm-periodic` | +| RPM-OSTree x86_64 | x86_64 | rpm-ostree | `e2e-aws-tests-release-periodic` | +| RPM-OSTree ARM | aarch64 | rpm-ostree | `e2e-aws-tests-release-arm-periodic` | + +## Requirements + +- **Claude Code**: Latest version with plugin support +- **Python 3**: Required for the `extract_microshift_version.py` helper script +- **Internet Access**: Required to fetch data from Prow CI and GCS + +## Output Examples + +### Job Info Output (Markdown) + +```markdown +# MicroShift CI Job Analysis + +## Job Overview +- **Job ID**: 1977207773863088128 +- **Job Name**: periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic +- **Status**: ✗ FAILURE +- **Architecture**: x86_64 +- **Image Type**: bootc +- **Version**: 4.20 +- **Duration**: 1h 30m 40s +- **Started**: 2025-10-12 03:00:46 UTC +- **Finished**: 2025-10-12 04:31:26 UTC + +## MicroShift Version +- **Full Version**: `4.20.0~rc.3-202509290606.p0.g1c4675a.assembly.rc.3.el9.x86_64` +- **Build Type**: RC (Release Candidate) - zstream +- **Base Version**: 4.20.0-rc.3 +- **Build Date**: 2025-09-29 06:06 +- **Commit**: g1c4675a + +## Test Results Summary + +**Overall**: 14 scenarios passed, 1 failed, 1 not available + +| Status | Count | +|--------|-------| +| ✓ Passed | 14 | +| ✗ Failed | 1 | +| **Total Tests** | **205** | +| **Total Passed** | **204** | +| **Total Failed** | **1** | + +## Test Scenarios + +### ✓ el96-lrel@standard1 +**RHEL 9.6 Latest Release - Standard Tests Set 1** +- **Status**: PASSED +- **Tests**: 33 total (33 passed, 0 failed) +- **Duration**: 22m 9s +- **JUnit**: [View XML](https://storage.googleapis.com/...) + +### ✗ el96-lrel@storage +**RHEL 9.6 Latest Release - Storage Tests** +- **Status**: FAILED +- **Tests**: 4 total (3 passed, 1 failed) +- **Duration**: 8m 32s + +**Failed Tests**: +1. **Snapshotter Smoke Test** + - Type: AssertionError + - Message: Setup failed: 1 != 0 + +## Failure Analysis + +The job failed due to 1 test failure in the `el96-lrel@storage` scenario: +- Snapshotter Smoke Test failed during setup and teardown +- This indicates an issue with CSI snapshotter functionality + +... +``` + +## Troubleshooting + +### Job Not Found (404) + +If you get a 404 error: +1. Verify the job ID is correct +2. Check if the job is still running (artifacts may not be available yet) +3. Ensure you're using the correct job URL format + +### Missing Artifacts + +Some jobs may not have all artifacts available: +- The command will gracefully handle missing files +- Check the job status - failed jobs may have incomplete artifacts +- Look at the build log to understand why artifacts are missing + +### SSL Certificate Errors + +The helper script handles SSL certificate issues automatically, but if you encounter problems: +- Ensure you have internet connectivity +- Check if corporate proxies are blocking GCS access +- Try accessing the GCS URLs directly in a browser first + +## Contributing + +Contributions are welcome! Please see the main [ai-helpers repository](https://github.com/openshift-eng/ai-helpers) for contribution guidelines. + +## Support + +- **Issues**: Report issues at [ai-helpers/issues](https://github.com/openshift-eng/ai-helpers/issues) +- **Documentation**: See individual command files in `commands/` for detailed implementation notes + +## Author + +- **Alejandro Gullón** (agullon@redhat.com) +- GitHub: [@agullon](https://github.com/agullon) + +## License + +This plugin is part of the ai-helpers project and follows the same license. diff --git a/plugins/microshift-prow-job/commands/analyze-job.md b/plugins/microshift-prow-job/commands/analyze-job.md new file mode 100644 index 00000000..34b0cadc --- /dev/null +++ b/plugins/microshift-prow-job/commands/analyze-job.md @@ -0,0 +1,417 @@ +--- +description: Analyze a MicroShift Prow CI job execution +argument-hint: +--- + +## Name +microshift-prow-job:analyze-job + +## Synopsis +``` +/microshift-prow-job:analyze-job +``` + +## Description +The `microshift-prow-job:analyze-job` command fetches comprehensive information from a Prow CI job execution and displays it in both JSON and Markdown formats. + +This command provides: +- Job metadata (status, timing, architecture, image type) +- MicroShift version being tested +- Test scenarios executed and their results +- Build information +- Links to logs and artifacts + +This command is useful for understanding what was tested in a specific job run, identifying failures, and accessing detailed logs and artifacts. + +## Implementation + +This command works by: + +1. **Parsing the job URL** to extract job name, ID, and configuration (architecture, image type, version) +2. **Fetching job metadata** from `finished.json` and `started.json` to get status, timing, and result information +3. **Extracting MicroShift version** using the `extract_microshift_version.py` helper script from build logs +4. **Listing test scenarios** by fetching the scenario-info directory structure from GCS artifacts +5. **Analyzing test results** for each scenario using the `analyze-test-scenario` command to get comprehensive JSON data +6. **Compiling artifacts and logs** by constructing URLs to build logs, test execution logs, and failure diagnostics +7. **Generating a detailed Markdown report** with job overview, version info, scenario results, and artifact links + +The command integrates with the `analyze-test-scenario` command to provide detailed per-scenario analysis and aggregates all information into a human-readable report with proper formatting (status icons, duration calculations, failure summaries). + +## Arguments +- `$1` (job-url): URL to the Prow CI job - **Required** + - Formats accepted: + - Full Prow dashboard URL: `https://prow.ci.openshift.org/view/gs/test-platform-results/logs//` + - GCS web URL: `https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs//` + - Job ID only (e.g., "1979744605507162112") - will attempt to infer job type from context + +## Return Value +- **Format**: Markdown +- **Location**: Output directly to the conversation +- **Content**: + - Job overview (status, timing, configuration) + - MicroShift version details + - Test scenario results + - Build information + - Links to logs and artifacts + +## Implementation Steps + +### Step 1: Parse Arguments and Validate Job URL + +**Goal**: Extract the job name, job ID, and job configuration. + +**Actions**: +1. Parse the job URL to extract: + - Job name (e.g., "periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic") + - Job ID (e.g., "1979744605507162112") +2. Determine job configuration from job name: + - Architecture: x86_64 or aarch64 (look for "arm" in job name) + - Image type: bootc or rpm-ostree (look for "bootc" in job name) + - Version: extract from job name (e.g., "4.20") +3. Validate URL format +4. If only job ID provided, ask user for job type or attempt to determine from recent jobs + +**Example Parsing**: +``` +URL: https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic/1979744605507162112 + +Extracted: +- job_name: "periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic" +- job_id: "1979744605507162112" +- version: "4.20" +- arch: "x86_64" +- image_type: "bootc" +``` + +### Step 2: Fetch Job Metadata + +**Goal**: Get job information (status, timing, result). + +**Actions**: +1. Construct the GCS URL for the `finished.json` file: + ``` + https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs///finished.json + ``` +2. Fetch the `finished.json` file using curl or WebFetch +3. Parse the JSON to extract: + - Job result (SUCCESS/FAILURE/ABORTED) + - Timestamp (start/end times) + - Duration + - Passed status + - Metadata (repo, revision, etc.) +4. Fetch `started.json` for additional metadata: + ```bash + curl -s "https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs///started.json" + ``` + +### Step 3: Extract MicroShift Version + +**Goal**: Determine the exact MicroShift version being tested. + +This command includes a Python script that automates version extraction from test logs. + +**Script Location**: `plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py` + +**Usage**: +```bash +python3 plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py +``` + +**Arguments**: +- `job_id`: The Prow CI job ID (e.g., "1982281180531134464") +- `version`: The release version (e.g., "4.20") +- `job_type`: The job type identifier: + - For bootc jobs: `e2e-aws-tests-bootc-release-periodic` (x86_64) or `e2e-aws-tests-bootc-release-arm-periodic` (aarch64) + - For rpm-ostree jobs: `e2e-aws-tests-release-periodic` (x86_64) or `e2e-aws-tests-release-arm-periodic` (aarch64) + +**Example**: +```bash +# Extract version for bootc x86_64 job +python3 plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py 1979744605507162112 4.20 e2e-aws-tests-bootc-release-periodic +``` + +**Output** (JSON): +```json +{ + "success": true, + "version": "4.20.0-202510161342.p0.g17d1d9a.assembly.4.20.0.el9.x86_64", + "build_type": "zstream", + "url": "https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs/...", + "error": null +} +``` + +**Build Types Detected**: +- `"nightly"`: Nightly development builds +- `"ec"`: Engineering Candidate +- `"rc"`: Release Candidate +- `"zstream"`: Stable/zstream release + +### Step 4: List Test Scenarios + +**Goal**: Find all test scenarios executed in this job and list them. + +**Output** (JSON): +```json +{ + "job_id": "1979744605507162112", + "scenarios": [ + "el94-y2@el96-lrel@standard1", + "el96-lrel@standard1", + "el96-lrel@lvm", + "el96-lrel@dual-stack", + "el96-lrel@ipv6" + ], + "total_scenarios": 5 +} +``` + +### Step 5: Analyze Test Results for Each Scenario + +**Goal**: Get detailed test execution results for each scenario. + +**Method**: Use the `analyze-test-scenario` command for each scenario to get comprehensive JSON data. + +**Actions**: +For each scenario found in Step 4: + +1. **Get scenario details** using the analyze-test-scenario command: + ```bash + /microshift-prow-job:analyze-test-scenario + ``` + +2. **Parse the JSON response** which includes: + - Test results summary (total, passed, failed, errors, skipped) + - Individual test case details + - Failure messages and details (if any) + - Scenario configuration (RHEL version, test category) + - Execution timing + - Links to all artifacts + +**Example JSON Response**: +```json +{ + "scenario": { + "name": "el96-lrel@standard1", + "description": "RHEL 9.6 Latest Release - Standard Tests", + "configuration": { + "rhel_version": "9.6", + "release_type": "latest", + "test_category": "Standard Tests" + } + }, + "test_results": { + "status": "passed", + "summary": { + "total": 65, + "passed": 65, + "failed": 0, + "errors": 0, + "skipped": 0 + }, + "execution_time_seconds": 1234.56, + "test_cases": [ + { + "name": "MicroShift boots successfully", + "status": "passed" + } + ], + "failures": [] + }, + "artifacts": { + "junit_xml": "https://...", + "boot_log": "https://...", + "debug_log": "https://..." + } +} +``` + +3. **Extract key information** from each scenario: + - Overall status (passed/failed) + - Test counts + - Failure details (for failed scenarios) + - Execution time + - Test category and configuration + +**Alternative Manual Method** (if analyze-test-scenario command unavailable): +1. Fetch junit.xml directly from artifact URL +2. Parse XML to extract test counts +3. Check boot_and_run.log for execution details +4. Extract scenario metadata from directory structure + +### Step 6: Compile Artifacts and Logs + +**Goal**: Provide links to useful artifacts and logs. + +**Actions**: +1. Compile key artifact URLs: + - Build log: `artifacts//openshift-microshift-infra-iso-build/build-log.txt` + - Test logs for each scenario + - JUnit XML reports + - Any failure logs or sosreports + +2. Categorize artifacts by type: + - Build artifacts + - Test execution logs + - Failure diagnostics + - System information + +### Step 7: Generate Detailed Report + +**Goal**: Create a comprehensive, well-structured report. + +**Report Structure**: +```markdown +# MicroShift CI Job Details + +## Job Overview +- **Job ID**: +- **Job Name**: +- **Status**: ✓ SUCCESS / ✗ FAILURE / ⚠️ ABORTED +- **Architecture**: x86_64 / aarch64 +- **Image Type**: bootc / rpm-ostree +- **Duration**: Xh Ym Zs +- **Started**: YYYY-MM-DD HH:MM:SS UTC +- **Finished**: YYYY-MM-DD HH:MM:SS UTC + +## MicroShift Version +- **Full Version**: +- **Build Type**: nightly / RC / EC / stable +- **Base Version**: X.Y.Z +- **Commit**: +- **Build Timestamp**: YYYY-MM-DD-HHMMSS + +## Test Scenarios + +### Scenario: +- **Description**: +- **Status**: ✓ PASS / ✗ FAIL +- **Tests**: X passed, Y failed, Z skipped +- **Duration**: Xm Ys + +**Failures** (if any): +- Test: + - Error: + - Log: [View]() + +[Repeat for each scenario] + +## Build Information +- **Build Status**: SUCCESS / FAILURE +- **Build Log**: [View]() +- **Build Duration**: Xm Ys + +## Artifacts & Logs +- [Build Log]() +- [Test Execution Logs]() +- [Scenario Details]() +- [Full Artifacts]() + +## Links +- [View on Prow CI]() +- [Browse All Artifacts]() +``` + +### Step 8: Error Handling + +**Goal**: Handle errors gracefully. + +**Common Issues**: +1. **Job not found (404)**: + - Verify job ID is correct + - Check if job is still running (no finished.json yet) + - Provide helpful error message to user + - Handle network errors gracefully + +2. **Artifacts not available**: + - Some jobs may not have all artifacts + - Gracefully handle missing files + - Indicate which artifacts are unavailable in the report + +3. **Invalid job URL**: + - Validate URL format before making requests + - Handle malformed URLs + - Provide examples of valid formats + - Suggest using job ID from create-report command + +4. **Version extraction failures**: + - Handle cases where version cannot be determined + - Provide partial information if available + - Include error message in report + +## Examples + +### Example 1: Successful Job Analysis +``` +/microshift-prow-job:analyze-job https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic/1979744605507162112 +``` + +Output: +```markdown +# MicroShift CI Job Details + +## Job Overview +- **Job ID**: 1979744605507162112 +- **Job Name**: periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic +- **Status**: ✓ SUCCESS +- **Architecture**: x86_64 +- **Image Type**: bootc +- **Duration**: 1h 43m 40s +- **Started**: 2025-10-19 03:01:17 UTC +- **Finished**: 2025-10-19 04:44:57 UTC + +## MicroShift Version +- **Full Version**: 4.20.0-0.nightly-2025-10-15-110252-20251017171355-4ad30ab2d +- **Build Type**: nightly +- **Base Version**: 4.20.0 +- **Commit**: 4ad30ab2d +- **Build Date**: 2025-10-15 + +## Test Scenarios + +### Scenario: el96-lrel@standard1 +- **Description**: RHEL 9.6 Latest Release - Standard Tests +- **Status**: ✓ PASS +- **Tests**: 45 passed, 0 failed, 2 skipped + +[Additional sections...] +``` + +### Example 2: Using GCS Web URL +``` +/microshift-prow-job:analyze-job https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-release-arm-periodic/1979744608019550208 +``` + +### Example 3: Failed Job Analysis +``` +/microshift-prow-job:analyze-job https://prow.ci.openshift.org/view/gs/test-platform-results/logs/some-failing-job/9876543210 +``` + +Output would include failure details: +```markdown +## Job Overview +- **Status**: ✗ FAILURE +... + +## Test Scenarios +... +**Failures**: +- Test: + - Error: + - Log: [View]() +``` + +### Example 4: Job ID Only +``` +/microshift-prow-job:analyze-job 1979744605507162112 +``` +(May prompt for additional context or attempt to determine job type from recent jobs) + +## Notes +- This command provides comprehensive analysis including job status, MicroShift version, test scenarios, and detailed results +- Works with MicroShift-specific Prow CI jobs +- Requires internet access to fetch job data from Prow CI +- All times are displayed in UTC +- Duration is calculated from the finished.json timestamp and start time from started.json +- The command is read-only and does not modify any CI job data +- Useful for debugging specific test failures or understanding what was tested diff --git a/plugins/microshift-prow-job/commands/analyze-test-scenario.md b/plugins/microshift-prow-job/commands/analyze-test-scenario.md new file mode 100644 index 00000000..899cf6ac --- /dev/null +++ b/plugins/microshift-prow-job/commands/analyze-test-scenario.md @@ -0,0 +1,405 @@ +--- +description: Analyze MicroShift Test Scenario results +argument-hint: +--- + +## Name +microshift-prow-job:analyze-test-scenario + +## Synopsis +``` +/microshift-prow-job:analyze-test-scenario +``` + +## Description +The `microshift-prow-job:analyze-test-scenario` command retrieves comprehensive information about a specific test scenario executed within a MicroShift CI job. It returns detailed information containing: +- Scenario configuration (OS version, test type, architecture) +- Test execution results (pass/fail counts, test names) +- MicroShift version tested +- Execution timing +- Links to logs and artifacts +- Test failure details (if any) + +This command is useful for detailed investigation of specific test scenarios and understanding test execution results. + +## Implementation + +This command works by: + +1. **Parsing the job URL** to extract job metadata (ID, name, version, architecture, image type) +2. **Constructing artifact URLs** for the specified scenario in the GCS bucket +3. **Fetching JUnit XML** test results using curl/WebFetch from the scenario's artifact directory +4. **Parsing test results** to extract pass/fail counts, test case names, and failure details +5. **Extracting scenario metadata** from the scenario name (RHEL version, release type, test category) +6. **Compiling artifact links** for all logs and diagnostic files +7. **Generating formatted Markdown output** containing all collected information + +If no scenario name is provided it will prompt to the user what scenario to use. + +The command uses the `extract_microshift_version.py` helper script to determine the exact MicroShift version tested in the scenario. + +## Arguments +- `$1` (job-url): URL to the Prow CI job - **Required** + - Formats accepted: + - Full Prow dashboard URL: `https://prow.ci.openshift.org/view/gs/test-platform-results/logs//` + - GCS web URL: `https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs//` +- `$2` (scenario-name): Name of the scenario to analyze - **Required** + - Examples: `el96-lrel@standard1`, `el96-lrel@lvm`, `el96-lrel@dual-stack` + - If not provided, the command will list all available scenarios + +## Return Value +- **Format**: Markdown +- **Location**: Output directly to the conversation +- **Content**: Comprehensive scenario information including test results, configuration, and artifacts + +## Implementation Steps + +### Step 1: Parse and Validate Input + +**Goal**: Extract job information and scenario name from the arguments. + +**Actions**: +1. Parse the job URL to extract: + - Job name + - Job ID + - Version (e.g., "4.20") + - Job type (bootc/rpm-ostree, x86_64/aarch64) +2. Validate scenario name format (should match pattern: `el[0-9]+-[a-z0-9]+@.+`) +3. If no scenario name provided, set `list_scenarios = true` flag + +**Example**: +```javascript +// Input +job_url = "https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic/1979744605507162112" +scenario_name = "el96-lrel@standard1" + +// Parsed +job_id = "1979744605507162112" +job_name = "periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic" +version = "4.20" +job_type = "e2e-aws-tests-bootc-release-periodic" +arch = "x86_64" +image_type = "bootc" +``` + +### Step 2: Construct Artifact URLs + +**Goal**: Build URLs to the scenario's artifacts. + +**Actions**: +1. Construct base artifact URL: + ``` + https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs///artifacts//openshift-microshift-e2e-metal-tests/artifacts/scenario-info// + ``` +2. Construct specific artifact URLs: + - JUnit XML: `/junit.xml` + - Boot log: `/boot_and_run.log` + - Debug log: `/rf-debug.log` + - Phase logs: `/phase_*/*.log` + +### Step 3: List Available Scenarios (if no scenario specified) + +**Goal**: If no scenario name was provided, list all available scenarios in the job. + +**Actions**: +1. Fetch the scenario-info directory listing: + ``` + https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs///artifacts//openshift-microshift-e2e-metal-tests/artifacts/scenario-info/ + ``` +2. Use WebFetch to parse the HTML directory listing +3. Extract all scenario directory names +4. Return formatted list of scenarios + +**Output Format** (if listing scenarios): +``` +# Available Test Scenarios + +Job: periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic +Job ID: 1979744605507162112 + +## Scenarios (11 total) +- el94-y2@el96-lrel@standard1 +- el94-y2@el96-lrel@standard2 +- el96-lrel@ai-model-serving-online +- el96-lrel@dual-stack +- el96-lrel@ginkgo-tests +- el96-lrel@ipv6 +- el96-lrel@low-latency +- el96-lrel@lvm +- el96-lrel@multi-nic +- el96-lrel@standard1 +- el96-lrel@standard2 +``` + +### Step 4: Fetch and Parse JUnit XML + +**Goal**: Get test execution results from JUnit XML. + +**Actions**: +1. Fetch the junit.xml file using curl or WebFetch +2. Parse XML to extract: + - Total test count + - Passed tests count + - Failed tests count + - Skipped tests count + - Error count + - Test execution time + - Individual test case names and statuses + - Failure messages and stack traces (if any) + +**Example Parsing**: +```python +import xml.etree.ElementTree as ET + +root = ET.fromstring(xml_content) +testsuite = root.find('.//testsuite') + +test_results = { + 'total': int(testsuite.get('tests', '0')), + 'passed': 0, + 'failures': int(testsuite.get('failures', '0')), + 'errors': int(testsuite.get('errors', '0')), + 'skipped': int(testsuite.get('skipped', '0')), + 'time': float(testsuite.get('time', '0')), + 'test_cases': [] +} + +for testcase in testsuite.findall('.//testcase'): + name = testcase.get('name') + status = 'passed' + message = None + + if testcase.find('failure') is not None: + status = 'failed' + message = testcase.find('failure').get('message') + elif testcase.find('error') is not None: + status = 'error' + message = testcase.find('error').get('message') + elif testcase.find('skipped') is not None: + status = 'skipped' + + test_results['test_cases'].append({ + 'name': name, + 'status': status, + 'message': message + }) + +test_results['passed'] = test_results['total'] - test_results['failures'] - test_results['errors'] - test_results['skipped'] +``` + +### Step 5: Extract Scenario Metadata + +**Goal**: Parse scenario name to extract configuration details. + +**Actions**: +1. Parse scenario name to extract components: + - RHEL version (e.g., "el96" → "RHEL 9.6") + - Release type (e.g., "lrel" → "Latest Release") + - Test type (e.g., "standard1", "lvm", "dual-stack") + - Upgrade path (if format is `el94-y2@el96-lrel@...` → upgrade from 9.4 to 9.6) + +2. Determine test category from test type: + - `standard1`, `standard2` → "Standard Tests" + - `lvm` → "LVM Storage Tests" + - `dual-stack` → "Dual-Stack Networking Tests" + - `ipv6` → "IPv6 Networking Tests" + - `multi-nic` → "Multi-NIC Configuration Tests" + - `low-latency` → "Low-Latency Tests" + - `ginkgo-tests` → "Ginkgo Integration Tests" + - `ai-model-serving-online` → "AI Model Serving Tests" + +**Example**: +```javascript +// Scenario: el96-lrel@standard1 +{ + "rhel_version": "9.6", + "release_type": "latest", + "test_category": "Standard Tests", + "test_variant": "1", + "is_upgrade": false +} + +// Scenario: el94-y2@el96-lrel@standard1 +{ + "source_rhel_version": "9.4", + "target_rhel_version": "9.6", + "release_type": "latest", + "test_category": "Standard Tests", + "test_variant": "1", + "is_upgrade": true +} +``` + +### Step 6: Get Execution Timing + +**Goal**: Extract when the scenario was executed and how long it took. + +**Actions**: +1. Check boot_and_run.log for timestamps +2. Look for start and end markers in the log +3. Calculate duration if both timestamps available +4. Extract from junit.xml `time` attribute as fallback + +### Step 7: Compile Artifact Links + +**Goal**: Provide direct links to all relevant artifacts for the scenario. + +**Actions**: +1. Build URLs for common artifacts: + - JUnit XML report + - Boot and run log + - Debug log + - Phase logs (if they exist) + - Sosreport (if test failed) + +2. Categorize artifacts: + - Test results: junit.xml + - Execution logs: boot_and_run.log, rf-debug.log + - Phase logs: All logs under phase_* directories + - Diagnostics: sosreports, system logs + + +### Error Handling + +**Common Issues and Responses**: + +1. **Scenario not found**: +``` +# Error: Scenario Not Found + +Scenario 'el96-lrel@invalid' does not exist in job 1979744605507162112 + +## Available Scenarios +- el96-lrel@standard1 +- el96-lrel@lvm +- ... +``` + +2. **Job not found**: +``` +# Error: Job Not Found + +Could not fetch artifacts for job ID 1234567890 + +Please verify the job URL and ensure the job has completed. +``` + +3. **Missing artifacts**: +``` +# Warning: Partial Data Available + +Some artifacts were not available for this scenario. + +## Missing Artifacts +- junit.xml + +Displaying available information below... +``` + +## Examples + +### Example 1: Get scenario information +``` +/microshift-prow-job:analyze-test-scenario https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic/1979744605507162112 el96-lrel@standard1 +``` + +Output: +``` +# Test Scenario Analysis: el96-lrel@standard1 + +## Job Information +- **Job Name**: periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic +- **Job ID**: 1979744605507162112 +- **Version**: 4.20 +- **Architecture**: x86_64 +- **Image Type**: bootc + +## Scenario Configuration +- **Name**: el96-lrel@standard1 +- **Description**: RHEL 9.6 Latest Release - Standard Tests +- **RHEL Version**: 9.6 +- **Release Type**: Latest +- **Test Category**: Standard Tests +- **Upgrade Test**: No + +## Test Results +**Status**: PASSED + +### Summary +- **Total Tests**: 65 +- **Passed**: 65 +- **Failed**: 0 +- **Errors**: 0 +- **Skipped**: 0 + +## Artifacts +- [JUnit XML](https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/.../junit.xml) +- [Boot and Run Log](https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/.../boot_and_run.log) +``` + +### Example 2: List all scenarios (no scenario name provided) +``` +/microshift-prow-job:analyze-test-scenario https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic/1979744605507162112 +``` + +Output: +``` +# Available Test Scenarios + +Job: periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic +Job ID: 1979744605507162112 + +## Scenarios (5 total) +- el96-lrel@standard1 +- el96-lrel@standard2 +- el96-lrel@lvm +- el96-lrel@dual-stack +- el96-lrel@ipv6 +``` + +### Example 3: Get information about a failed scenario +``` +/microshift-prow-job:analyze-test-scenario https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-release-periodic/1234567890 el96-lrel@lvm +``` + +Output would include failure details: +``` +# Test Scenario Analysis: el96-lrel@lvm + +## Job Information +- **Job Name**: periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-release-periodic +- **Job ID**: 1234567890 +- **Version**: 4.20 + +## Scenario Configuration +- **Name**: el96-lrel@lvm +- **Description**: RHEL 9.6 Latest Release - LVM Storage Tests +- **Test Category**: LVM Storage Tests + +## Test Results +**Status**: FAILED + +### Summary +- **Total Tests**: 45 +- **Passed**: 43 +- **Failed**: 2 +- **Errors**: 0 +- **Skipped**: 0 + +### Failed Tests +1. **LVM volume creation** + - **Error**: Failed to create LVM volume: insufficient space + - **Log**: [create-lvm.log](https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/.../phase_create-and-run/create-lvm.log) + +## Artifacts +- [JUnit XML](https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/.../junit.xml) +- [Boot and Run Log](https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/.../boot_and_run.log) +- [Debug Log](https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/.../rf-debug.log) +``` + +## Notes +- This command outputs detailed information in Markdown format for easy reading +- The command is read-only and does not modify any CI job data +- If a scenario doesn't have junit.xml, the command will attempt to infer results from logs +- The command caches scenario lists internally to avoid repeated fetches when listing scenarios +- Artifact links in the output are direct URLs to GCS storage for immediate access diff --git a/plugins/microshift-prow-job/skills/extract-microshift-version/SKILL.md b/plugins/microshift-prow-job/skills/extract-microshift-version/SKILL.md new file mode 100644 index 00000000..2c09ef71 --- /dev/null +++ b/plugins/microshift-prow-job/skills/extract-microshift-version/SKILL.md @@ -0,0 +1,185 @@ +--- +name: Extract MicroShift Version +description: Extract MicroShift version and build type from Prow CI build logs +--- + +# Extract MicroShift Version + +This skill provides a utility script for extracting the exact MicroShift version and build type from Prow CI job artifacts. + +## When to Use This Skill + +Use this skill whenever you need to: +- Extract the exact MicroShift version being tested in a Prow CI job +- Determine the build type (nightly, rc, ec, zstream) from a job +- Parse version information from build logs programmatically +- Retrieve version metadata for reporting purposes + +This skill is used by commands that need to: +- Display version information in job summaries +- Correlate test results with specific MicroShift builds +- Generate release testing reports with version details + +## Prerequisites + +1. **Python 3 Installation** + - Check if installed: `which python3` + - The script uses only standard library modules (sys, json, re, urllib) + - No additional dependencies required + +2. **Network Access** + - Scripts need access to `gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com` + - Used to fetch build logs from Prow CI artifact storage + +## Available Scripts + +### Script: `extract_microshift_version.py` + +Extracts the exact MicroShift version and build type from Prow CI job artifacts. + +**Usage:** +```bash +python3 plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py +``` + +**Parameters:** +- `job_id`: The Prow CI job ID (e.g., "1982281180531134464") +- `version`: The release version (e.g., "4.20") +- `job_type`: The job type (e.g., "e2e-aws-tests-bootc-release-periodic" or "e2e-aws-tests-release-periodic") + +**Output:** +Returns a JSON object with the following structure: +```json +{ + "success": true, + "version": "4.20.0-202510161342.p0.g17d1d9a.assembly.4.20.0.el9.x86_64", + "build_type": "zstream", + "url": "https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/...", + "error": null +} +``` + +**Build Types:** +- `nightly`: Nightly builds (contains "nightly" in version string) +- `rc`: Release candidate builds (contains "-rc." in version string) +- `ec`: Engineering candidate builds (contains "-ec." in version string) +- `zstream`: Z-stream/patch release builds (all other versions) + +**How it works:** +1. Constructs the URL to the rf-debug.log artifact based on job parameters +2. Fetches the build log from GCS storage +3. Searches for the `${version_string_raw}` variable in the log +4. Extracts the full version string (e.g., "4.20.0-202510161342.p0.g17d1d9a.assembly.4.20.0.el9.x86_64") +5. Determines build type from version string patterns +6. Returns structured JSON with all metadata + +**Example:** +```bash +# Extract version from a bootc release periodic job +python3 plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py \ + 1982281180531134464 \ + 4.20 \ + e2e-aws-tests-bootc-release-periodic + +# Output: +{ + "success": true, + "version": "4.20.0-202510161342.p0.g17d1d9a.assembly.4.20.0.el9.x86_64", + "build_type": "zstream", + "url": "https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs/periodic-ci-openshift-microshift-release-4.20-periodics-e2e-aws-tests-bootc-release-periodic/1982281180531134464/artifacts/e2e-aws-tests-bootc-release-periodic/openshift-microshift-e2e-metal-tests/artifacts/scenario-info/el96-lrel@standard1/rf-debug.log", + "error": null +} +``` + +## Error Handling + +The script provides clear error messages for common scenarios: + +1. **Invalid arguments** + ```json + { + "success": false, + "error": "Usage: extract_microshift_version.py " + } + ``` + +2. **Network errors / log not found** + ```json + { + "success": false, + "error": "Failed to fetch build log: HTTP Error 404: Not Found", + "url": "https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/..." + } + ``` + +3. **Version not found in log** + ```json + { + "success": false, + "error": "Could not find version string in build log", + "url": "https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/..." + } + ``` + +## Usage in Commands + +Commands should parse the JSON output and check the `success` field: + +```bash +# Example integration in a command +result=$(python3 plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py "$job_id" "$version" "$job_type") + +# Check if extraction succeeded +success=$(echo "$result" | jq -r '.success') +if [ "$success" = "true" ]; then + microshift_version=$(echo "$result" | jq -r '.version') + build_type=$(echo "$result" | jq -r '.build_type') + echo "MicroShift Version: $microshift_version ($build_type)" +else + error=$(echo "$result" | jq -r '.error') + echo "Failed to extract version: $error" +fi +``` + +## Implementation Details + +### Version Extraction Logic + +The script searches for the version string using this regex pattern: +```python +pattern = r'\$\{version_string_raw\}\s*=\s*(.+?)(?:\s|$)' +``` + +This matches lines in the rf-debug.log file like: +``` +${version_string_raw} = 4.20.0-202510161342.p0.g17d1d9a.assembly.4.20.0.el9.x86_64 +``` + +### SSL Handling + +The script disables SSL certificate verification to handle environments with incomplete certificate chains: +```python +ssl_context = ssl.create_default_context() +ssl_context.check_hostname = False +ssl_context.verify_mode = ssl.CERT_NONE +``` + +This is necessary because some internal OpenShift CI environments may not have complete SSL certificate chains. + +### URL Construction + +Build log URLs follow this pattern: +``` +https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs/ + periodic-ci-openshift-microshift-release-{version}-periodics-{job_type}/ + {job_id}/ + artifacts/{job_type}/openshift-microshift-e2e-metal-tests/artifacts/scenario-info/el96-lrel@standard1/rf-debug.log +``` + +## Benefits + +1. **Consistent Version Extraction**: Single source of truth for version parsing logic +2. **Structured Output**: JSON format makes it easy to integrate with other tools +3. **Error Handling**: Clear error messages with context (including attempted URL) +4. **Build Type Detection**: Automatically categorizes builds for reporting +5. **No External Dependencies**: Uses only Python standard library diff --git a/plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py b/plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py new file mode 100755 index 00000000..f286e5cb --- /dev/null +++ b/plugins/microshift-prow-job/skills/extract-microshift-version/extract_microshift_version.py @@ -0,0 +1,174 @@ +#!/usr/bin/env python3 +""" +Extract MicroShift version from Prow CI build logs. + +This script fetches the build log from a Prow CI job and extracts the +exact MicroShift version being tested, along with determining the build type. + +Usage: + python3 extract_microshift_version.py + +Arguments: + job_id: The Prow CI job ID (e.g., "1982281180531134464") + version: The release version (e.g., "4.20") + job_type: The job type (e.g., "e2e-aws-tests-bootc-release-periodic" or "e2e-aws-tests-release-periodic") +Output: + JSON object with: + { + "version": "4.20.0-0.nightly-2025-10-15-110252-20251024164401-7d3263467", + "build_type": "nightly", + "success": true, + "error": null + } +""" + +import sys +import json +import re +import urllib.request +import urllib.error +import ssl + + +def construct_build_log_url(version, job_id, job_type): + """Construct the URL to the build log for a given job.""" + base_url = "https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs" + job_name = f"periodic-ci-openshift-microshift-release-{version}-periodics-{job_type}" + artifact_path = f"artifacts/{job_type}/openshift-microshift-e2e-metal-tests/artifacts/scenario-info/el96-lrel@standard1/rf-debug.log" + + return f"{base_url}/{job_name}/{job_id}/{artifact_path}" + + +def fetch_build_log(url): + """Fetch the build log content from the given URL.""" + try: + # Validate URL scheme + if not url.startswith('https://'): + return None, f"Invalid URL scheme. Only HTTPS URLs are supported." + + # Create SSL context that doesn't verify certificates + # This is needed for some environments where SSL cert chain is incomplete + ssl_context = ssl.create_default_context() + ssl_context.check_hostname = False + ssl_context.verify_mode = ssl.CERT_NONE + + with urllib.request.urlopen(url, timeout=30, context=ssl_context) as response: + content = response.read().decode('utf-8') + return content, None + except urllib.error.URLError as e: + return None, f"Failed to fetch build log: {e}" + except (UnicodeDecodeError, OSError) as e: + return None, f"Error reading build log: {e}" + + +def extract_version_from_log(log_content): + """ + Extract MicroShift version from build log content. + + Looks for patterns like: + - ${version_string_raw} = 4.20.0-202510161342.p0.g17d1d9a.assembly.4.20.0.el9.x86_64 + """ + # Look for the version string pattern in the log + # Pattern: ${version_string_raw} = 4.20.0-202510161342.p0.g17d1d9a.assembly.4.20.0.el9.x86_64 + pattern = r'\$\{version_string_raw\}\s*=\s*(.+?)(?:\s|$)' + + match = re.search(pattern, log_content) + if match: + version_string = match.group(1).strip() + return version_string, None + + return None, "Could not find version string in build log" + + +def determine_build_type(version_string): + """ + Determine the build type from the version string. + + Returns one of: "nightly", "ec", "rc", "zstream" + """ + if "nightly" in version_string.lower(): + return "nightly" + elif "-ec." in version_string: + return "ec" + elif "-rc." in version_string: + return "rc" + else: + return "zstream" + + +def main(): + """Main entry point.""" + if len(sys.argv) != 4: + print(json.dumps({ + "success": False, + "error": "Usage: extract_microshift_version.py " + })) + sys.exit(1) + + job_id = sys.argv[1] + version = sys.argv[2] + job_type = sys.argv[3] + + # Validate inputs + if not job_id or not job_id.strip(): + print(json.dumps({ + "success": False, + "error": "job_id cannot be empty" + })) + sys.exit(1) + + if not version or not version.strip(): + print(json.dumps({ + "success": False, + "error": "version cannot be empty" + })) + sys.exit(1) + + if not job_type or not job_type.strip(): + print(json.dumps({ + "success": False, + "error": "job_type cannot be empty" + })) + sys.exit(1) + + # Construct build log URL + url = construct_build_log_url(version, job_id, job_type) + + # Fetch build log + log_content, error = fetch_build_log(url) + if error: + print(json.dumps({ + "success": False, + "error": error, + "url": url + })) + sys.exit(1) + + # Extract version + microshift_version, error = extract_version_from_log(log_content) + if error: + print(json.dumps({ + "success": False, + "error": error, + "url": url + })) + sys.exit(1) + + # Determine build type + build_type = determine_build_type(microshift_version) + + # Output result + result = { + "success": True, + "version": microshift_version, + "build_type": build_type, + "url": url, + "error": None + } + + print(json.dumps(result, indent=2)) + sys.exit(0) + + +if __name__ == "__main__": + main()