Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/scripts/performance-to-markdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env python3
import json
import sys
import os
import glob

def load_all_summaries(json_files):
"""Load summaries from all JSON files and group by test name"""
summaries_by_name = {}

for json_file in json_files:
try:
with open(json_file, 'r') as f:
data = json.load(f)

if 'summaries' in data and data['summaries']:
for summary in data['summaries']:
name = summary.get('name', 'Unknown Test')
if name not in summaries_by_name:
summaries_by_name[name] = []
summaries_by_name[name].append(summary)
except (FileNotFoundError, json.JSONDecodeError) as e:
print(f"Warning: Error processing {json_file}: {e}", file=sys.stderr)
continue

return summaries_by_name

def convert_to_markdown(json_files):
"""Convert performance test JSON results to markdown format"""
summaries_by_name = load_all_summaries(json_files)

if not summaries_by_name:
return "## Performance Test Results\n\nNo performance test results found."

markdown = "## Performance Test Results\n\n"

# Create a table for each test name
for name, summaries in sorted(summaries_by_name.items()):
markdown += f"### {name}\n\n"
markdown += "| Duration (ms) | Max Memory (GB) | Processors | Parameters |\n"
markdown += "|---------------|-----------------|------------|------------|\n"

for summary in summaries:
duration = summary.get('duration', 0)
processors = summary.get('numberOfProcessors', 0)
max_memory = summary.get('maxMemory', 0)

# Convert memory from bytes to GB
max_memory_gb = max_memory / (1024 ** 3) if max_memory > 0 else 0

# Extract dynamic properties (excluding standard fields)
standard_fields = {'name', 'duration', 'numberOfProcessors', 'maxMemory'}
params = []
for key, value in summary.items():
if key not in standard_fields:
params.append(f"{key}={value}")

params_str = ", ".join(params) if params else "-"

markdown += f"| {duration} | {max_memory_gb:.2f} | {processors} | {params_str} |\n"

markdown += "\n"

return markdown

if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: performance-to-markdown.py <json_file> [json_file2 ...]")
print(" or: performance-to-markdown.py <glob_pattern>")
sys.exit(1)

# Collect all JSON files from arguments (supporting both direct files and glob patterns)
json_files = []
for arg in sys.argv[1:]:
if '*' in arg:
json_files.extend(glob.glob(arg, recursive=True))
else:
json_files.append(arg)

# Filter to only existing files
json_files = [f for f in json_files if os.path.isfile(f)]

if not json_files:
print("## Performance Test Results\n\nNo performance test results found.")
sys.exit(0)

markdown = convert_to_markdown(json_files)
print(markdown)
9 changes: 8 additions & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,21 @@ jobs:
minikube version: 'v1.36.0'
kubernetes version: '${{ inputs.kube-version }}'
github token: ${{ github.token }}

- name: "${{inputs.it-category}} integration tests (kube: ${{ inputs.kube-version }} / java: ${{ inputs.java-version }} / client: ${{ inputs.http-client }})"
run: |
if [ -z "${{inputs.it-category}}" ]; then
it_profile="integration-tests"
else
it_profile="integration-tests-${{inputs.it-category}}"
fi
echo "{ "kube-version":"${{inputs.kube-version}}", "java-version":"${{ inputs.java-version }}","http-client":"${{inputs.http-client}}"}" >> run-properties.json
echo "Using profile: ${it_profile}"
./mvnw ${MAVEN_ARGS} -T1C -B install -DskipTests -Pno-apt --file pom.xml
./mvnw ${MAVEN_ARGS} -T1C -B package -P${it_profile} -Dfabric8-httpclient-impl.name=${{inputs.http-client}} --file pom.xml

- name: Upload performance test results
uses: actions/upload-artifact@v6
with:
name: performance-results-run-${{ github.run_id }}-java${{ inputs.java-version }}-k8s${{ inputs.kube-version }}-${{ inputs.http-client }}
path: operator-framework/target/performance_test_result.json
if-no-files-found: ignore
41 changes: 41 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,44 @@ jobs:

build:
uses: ./.github/workflows/build.yml

performance_report:
name: Post Performance Results
runs-on: ubuntu-latest
needs: build
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v6

- name: Download all performance artifacts
uses: actions/download-artifact@v7
with:
pattern: performance-results-run-${{ github.run_id }}*
path: performance-results
merge-multiple: false

- name: Check for performance results
id: check_results
run: |
if [ -d "performance-results" ] && [ "$(ls -A performance-results/**/*.json 2>/dev/null)" ]; then
echo "Has results"
echo "has_results=true" >> $GITHUB_OUTPUT
else
echo "Has NO results"
echo "has_results=false" >> $GITHUB_OUTPUT
fi

- name: Convert performance results to markdown
if: steps.check_results.outputs.has_results == 'true'
id: convert
run: |
python3 .github/scripts/performance-to-markdown.py performance-results/**/*.json > comment.md

- name: Post PR comment
if: steps.check_results.outputs.has_results == 'true' && github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
path: comment.md
recreate: true

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright Java Operator SDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.javaoperatorsdk.operator.baseapi.performance;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;

public class PerformanceTestResult {

private final Map<String, Object> additionalProperties = new HashMap<>();

@JsonAnySetter
public void addProperty(String key, Object value) {
additionalProperties.put(key, value);
}

@JsonAnyGetter
public Map<String, Object> getProperties() {
return additionalProperties;
}

private List<PerformanceTestSummary> summaries;

public List<PerformanceTestSummary> getSummaries() {
return summaries;
}

public void setSummaries(List<PerformanceTestSummary> summaries) {
this.summaries = summaries;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright Java Operator SDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.javaoperatorsdk.operator.baseapi.performance;

public class PerformanceTestSummary {

private String name;

// data about the machine
private int numberOfProcessors;
private long maxMemory;
private long duration;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getNumberOfProcessors() {
return numberOfProcessors;
}

public void setNumberOfProcessors(int numberOfProcessors) {
this.numberOfProcessors = numberOfProcessors;
}

public long getMaxMemory() {
return maxMemory;
}

public void setMaxMemory(long maxMemory) {
this.maxMemory = maxMemory;
}

public long getDuration() {
return duration;
}

public void setDuration(long duration) {
this.duration = duration;
}
}
Loading