Skip to content

Add Ceph storage test workflow with 6 tests for distributed storage s… #1

Add Ceph storage test workflow with 6 tests for distributed storage s…

Add Ceph storage test workflow with 6 tests for distributed storage s… #1

Workflow file for this run

name: Test Ceph on Arm64
on:
workflow_call:
workflow_dispatch:
push:
branches:
- main
- smoke_tests
paths:
- 'content/opensource_packages/ceph.md'
- '.github/workflows/test-ceph.yml'
jobs:
test-ceph:
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set test metadata
id: metadata
run: |
echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
echo "package_slug=ceph" >> $GITHUB_OUTPUT
echo "dashboard_link=/opensource_packages/ceph" >> $GITHUB_OUTPUT
# ============================================================
# Install Ceph
# ============================================================
- name: Install Ceph
id: install
run: |
echo "Installing Ceph..."
# Install Ceph from Ubuntu repository
sudo apt-get update
sudo apt-get install -y ceph ceph-common cephadm
# Verify installation
if command -v ceph &> /dev/null; then
echo "Ceph installed successfully"
echo "install_status=success" >> $GITHUB_OUTPUT
else
echo "Ceph installation failed"
echo "install_status=failed" >> $GITHUB_OUTPUT
exit 1
fi
# ============================================================
# Detect version
# ============================================================
- name: Detect Ceph version
id: version
run: |
VERSION=$(ceph --version | grep -oP '(?<=ceph version )[0-9.]+')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Detected Ceph version: $VERSION"
ceph --version
# ============================================================
# Run tests
# ============================================================
- name: Test 1 - Check ceph client binary exists
id: test1
run: |
START_TIME=$(date +%s)
if command -v ceph &> /dev/null; then
echo "✓ ceph command found"
which ceph
echo "status=passed" >> $GITHUB_OUTPUT
else
echo "✗ ceph command not found"
echo "status=failed" >> $GITHUB_OUTPUT
exit 1
fi
END_TIME=$(date +%s)
echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
- name: Test 2 - Check cephadm binary exists
id: test2
run: |
START_TIME=$(date +%s)
if command -v cephadm &> /dev/null; then
echo "✓ cephadm command found"
which cephadm
echo "status=passed" >> $GITHUB_OUTPUT
else
echo "✗ cephadm command not found"
echo "status=failed" >> $GITHUB_OUTPUT
exit 1
fi
END_TIME=$(date +%s)
echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
- name: Test 3 - Check Ceph version command
id: test3
run: |
START_TIME=$(date +%s)
if ceph --version | grep -q "ceph version"; then
echo "✓ Ceph version check passed"
ceph --version
echo "status=passed" >> $GITHUB_OUTPUT
else
echo "✗ Ceph version check failed"
echo "status=failed" >> $GITHUB_OUTPUT
exit 1
fi
END_TIME=$(date +%s)
echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
- name: Test 4 - Check rados binary (RADOS object store)
id: test4
run: |
START_TIME=$(date +%s)
if command -v rados &> /dev/null; then
echo "✓ rados command found"
which rados
rados --version 2>&1 || echo "rados binary exists"
echo "status=passed" >> $GITHUB_OUTPUT
else
echo "✗ rados command not found"
echo "status=failed" >> $GITHUB_OUTPUT
exit 1
fi
END_TIME=$(date +%s)
echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
- name: Test 5 - Check rbd binary (RADOS Block Device)
id: test5
run: |
START_TIME=$(date +%s)
if command -v rbd &> /dev/null; then
echo "✓ rbd command found"
which rbd
rbd --version 2>&1 || echo "rbd binary exists"
echo "status=passed" >> $GITHUB_OUTPUT
else
echo "✗ rbd command not found"
echo "status=failed" >> $GITHUB_OUTPUT
exit 1
fi
END_TIME=$(date +%s)
echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
- name: Test 6 - Check cephfs binary (Ceph File System)
id: test6
run: |
START_TIME=$(date +%s)
if command -v cephfs &> /dev/null || command -v ceph-fuse &> /dev/null; then
echo "✓ CephFS related command found"
if command -v ceph-fuse &> /dev/null; then
which ceph-fuse
ceph-fuse --version 2>&1 || echo "ceph-fuse binary exists"
fi
echo "status=passed" >> $GITHUB_OUTPUT
else
echo "✗ CephFS related commands not found"
echo "status=failed" >> $GITHUB_OUTPUT
exit 1
fi
END_TIME=$(date +%s)
echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
# ============================================================
# Calculate summary
# ============================================================
- name: Calculate test summary
if: always()
id: summary
run: |
PASSED=0
FAILED=0
TOTAL_DURATION=0
# Test 1
if [ "${{ steps.test1.outputs.status }}" == "passed" ]; then
PASSED=$((PASSED + 1))
else
FAILED=$((FAILED + 1))
fi
TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test1.outputs.duration || 0 }}))
# Test 2
if [ "${{ steps.test2.outputs.status }}" == "passed" ]; then
PASSED=$((PASSED + 1))
else
FAILED=$((FAILED + 1))
fi
TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test2.outputs.duration || 0 }}))
# Test 3
if [ "${{ steps.test3.outputs.status }}" == "passed" ]; then
PASSED=$((PASSED + 1))
else
FAILED=$((FAILED + 1))
fi
TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test3.outputs.duration || 0 }}))
# Test 4
if [ "${{ steps.test4.outputs.status }}" == "passed" ]; then
PASSED=$((PASSED + 1))
else
FAILED=$((FAILED + 1))
fi
TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test4.outputs.duration || 0 }}))
# Test 5
if [ "${{ steps.test5.outputs.status }}" == "passed" ]; then
PASSED=$((PASSED + 1))
else
FAILED=$((FAILED + 1))
fi
TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test5.outputs.duration || 0 }}))
# Test 6
if [ "${{ steps.test6.outputs.status }}" == "passed" ]; then
PASSED=$((PASSED + 1))
else
FAILED=$((FAILED + 1))
fi
TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test6.outputs.duration || 0 }}))
echo "passed=$PASSED" >> $GITHUB_OUTPUT
echo "failed=$FAILED" >> $GITHUB_OUTPUT
echo "duration=$TOTAL_DURATION" >> $GITHUB_OUTPUT
if [ $FAILED -eq 0 ]; then
echo "overall_status=success" >> $GITHUB_OUTPUT
echo "badge_status=passing" >> $GITHUB_OUTPUT
else
echo "overall_status=failure" >> $GITHUB_OUTPUT
echo "badge_status=failing" >> $GITHUB_OUTPUT
fi
# ============================================================
# Generate JSON with Ceph metadata
# ============================================================
- name: Generate test results JSON
if: always()
run: |
mkdir -p test-results
cat > test-results/ceph.json << EOF
{
"schema_version": "1.0",
"package": {
"name": "Ceph",
"version": "${{ steps.version.outputs.version }}",
"language": "c++",
"category": "Storage"
},
"run": {
"id": "${{ github.run_id }}",
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"timestamp": "${{ steps.metadata.outputs.timestamp }}",
"status": "${{ steps.summary.outputs.overall_status }}",
"runner": {
"os": "ubuntu-24.04",
"arch": "arm64"
}
},
"tests": {
"passed": ${{ steps.summary.outputs.passed }},
"failed": ${{ steps.summary.outputs.failed }},
"skipped": 0,
"duration_seconds": ${{ steps.summary.outputs.duration }},
"details": [
{
"name": "Check ceph client binary exists",
"status": "${{ steps.test1.outputs.status }}",
"duration_seconds": ${{ steps.test1.outputs.duration || 0 }}
},
{
"name": "Check cephadm binary exists",
"status": "${{ steps.test2.outputs.status }}",
"duration_seconds": ${{ steps.test2.outputs.duration || 0 }}
},
{
"name": "Check Ceph version command",
"status": "${{ steps.test3.outputs.status }}",
"duration_seconds": ${{ steps.test3.outputs.duration || 0 }}
},
{
"name": "Check rados binary (RADOS object store)",
"status": "${{ steps.test4.outputs.status }}",
"duration_seconds": ${{ steps.test4.outputs.duration || 0 }}
},
{
"name": "Check rbd binary (RADOS Block Device)",
"status": "${{ steps.test5.outputs.status }}",
"duration_seconds": ${{ steps.test5.outputs.duration || 0 }}
},
{
"name": "Check cephfs binary (Ceph File System)",
"status": "${{ steps.test6.outputs.status }}",
"duration_seconds": ${{ steps.test6.outputs.duration || 0 }}
}
]
},
"metadata": {
"dashboard_link": "${{ steps.metadata.outputs.dashboard_link }}",
"badge_status": "${{ steps.summary.outputs.badge_status }}"
}
}
EOF
echo "Generated test results:"
cat test-results/ceph.json
# ============================================================
# STANDARD STEPS - Commit results to repository
# ============================================================
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: ceph-test-results
path: test-results/ceph.json
retention-days: 90
- name: Commit test results to repository
if: always() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/smoke_tests')
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
mkdir -p data/test-results
cp test-results/ceph.json data/test-results/ceph.json
git add data/test-results/ceph.json
if ! git diff --staged --quiet; then
git commit -m "Update ceph test results [skip ci]"
# Retry logic for push
MAX_RETRIES=5
RETRY_COUNT=0
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
if git push origin ${{ github.ref_name }}; then
echo "Successfully pushed test results"
break
else
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
echo "Push failed, attempt $RETRY_COUNT of $MAX_RETRIES. Retrying in 5 seconds..."
sleep 5
git pull --rebase origin ${{ github.ref_name }}
else
echo "Failed to push after $MAX_RETRIES attempts"
exit 1
fi
fi
done
else
echo "No changes to commit"
fi