-
Notifications
You must be signed in to change notification settings - Fork 2
Basic integration test for NIC #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
136de79
feat: add integration test
dareste 31e2e11
fix: update upload-artifact version
dareste 93fd943
chore: bump helm kind-action to 1.12.0
dareste 62df1e9
fix: install nic
dareste 07ec9c1
fix: verify-contents.sh
dareste 068e447
fix: verify-contents.sh
dareste File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/kind-action@v1.12.0 | ||
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/ | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.