Skip to content
Merged
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
20 changes: 20 additions & 0 deletions .github/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: test-cluster
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
- role: worker

75 changes: 75 additions & 0 deletions .github/scripts/verify-contents.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash
set -e

EXTRACTED_DIR="$1"

if [ -z "$EXTRACTED_DIR" ]; then
echo "Usage: $0 <extracted_directory>"
exit 1
fi

echo "Verifying contents in directory: $EXTRACTED_DIR"

# Check if extraction directory exists
if [ ! -d "$EXTRACTED_DIR" ]; then
echo "Error: Extracted directory does not exist: $EXTRACTED_DIR"
exit 1
fi

# List of expected files/directories based on the common and NIC job lists
EXPECTED_ITEMS=(
"manifest.json"
"supportpkg.log"
"k8s/crd.json"
"k8s/nodes.json"
"k8s/version.json"
)

# Check for expected items
MISSING_ITEMS=()
FOUND_ITEMS=()

for item in "${EXPECTED_ITEMS[@]}"; do
FULL_PATH="$EXTRACTED_DIR/$item"
if [ -e "$FULL_PATH" ]; then
FOUND_ITEMS+=("$item")
echo "✓ Found: $item"
else
MISSING_ITEMS+=("$item")
echo "✗ Missing: $item"
fi
done

# Check if manifest.json is valid JSON and contains expected fields
MANIFEST_FILE="$EXTRACTED_DIR/manifest.json"
if [ -f "$MANIFEST_FILE" ]; then
if jq empty "$MANIFEST_FILE" 2>/dev/null; then
echo "✓ manifest.json is valid JSON"
else
echo "✗ manifest.json is not valid JSON"
MISSING_ITEMS+=("valid manifest.json")
fi
fi

# Summary
echo ""
echo "=== VERIFICATION SUMMARY ==="
echo "Found items: ${#FOUND_ITEMS[@]}"
echo "Missing items: ${#MISSING_ITEMS[@]}"

if [ ${#MISSING_ITEMS[@]} -eq 0 ]; then
echo "✅ All expected items found!"
echo ""
echo "Complete directory structure:"
find "$EXTRACTED_DIR" -type f | sort | sed 's/^/ /'
exit 0
else
echo "❌ Some expected items are missing:"
for item in "${MISSING_ITEMS[@]}"; do
echo " - $item"
done
echo ""
echo "Actual directory structure:"
find "$EXTRACTED_DIR" -type f | sort | sed 's/^/ /'
exit 1
fi
116 changes: 116 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Integration Test

on:
push:
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
integration-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'

- name: Build binary
run: |
go build -o nginx-supportpkg main.go
chmod +x nginx-supportpkg

- name: Create KinD cluster
uses: helm/[email protected]
with:
cluster_name: test-cluster
config: .github/kind-config.yaml

- name: Wait for cluster to be ready
run: |
kubectl wait --for=condition=Ready nodes --all --timeout=300s
kubectl cluster-info

- name: Install NGINX Ingress Controller with Helm
run: |
# Install Helm (it's pre-installed on GitHub runners but ensure latest version)
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

# Add and update helm repos (if needed)
helm version

# Install NGINX Ingress Controller
helm install my-release oci://ghcr.io/nginx/charts/nginx-ingress --version 2.2.2 \
--namespace nginx-ingress --create-namespace

# Verify installation
kubectl get pods -n nginx-ingress

- name: Wait for NGINX Ingress Controller to be ready
run: |
kubectl wait --namespace nginx-ingress \
--for=condition=ready pod \
--selector=app.kubernetes.io/instance=my-release \
--timeout=300s
kubectl get pods -A

- name: Run nginx-supportpkg tool
run: |
./nginx-supportpkg -n nginx-ingress -p nic

- name: Verify output file exists
run: |
ls -la *.tar.gz
if [ ! -f *.tar.gz ]; then
echo "Error: No tarball file found"
exit 1
fi
echo "Tarball found: $(ls *.tar.gz)"

- name: Verify tarball is valid
run: |
TARBALL=$(ls *.tar.gz | head -n 1)
echo "Testing tarball: $TARBALL"

# Test if it's a valid gzipped tarball
if ! gzip -t "$TARBALL"; then
echo "Error: File is not a valid gzip file"
exit 1
fi

# Test if it's a valid tar archive
if ! tar -tzf "$TARBALL" >/dev/null 2>&1; then
echo "Error: File is not a valid tar archive"
exit 1
fi

echo "Tarball is valid"

- name: Extract and verify contents
run: |
TARBALL=$(ls *.tar.gz | head -n 1)
echo "Extracting tarball: $TARBALL"

# Extract to a test directory
mkdir -p extracted_test
tar -xzf "$TARBALL" -C extracted_test

# List all extracted contents
echo "Extracted contents:"
find extracted_test -type f | sort

# Verify expected files exist
bash .github/scripts/verify-contents.sh extracted_test

- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-test-artifacts
path: |
*.tar.gz
extracted_test/