Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3cb754e
add configmap processing test pipeline and test framework
zanejohnson-azure Apr 10, 2026
2db2e96
fix: patch CRS revision with --branch parameter
zanejohnson-azure Apr 11, 2026
7e2b2d5
fix: configmap variant should be exact copy of base plus only the cha…
zanejohnson-azure Apr 11, 2026
5d7eff8
fix: use PowerShell for Windows container process counting
zanejohnson-azure Apr 11, 2026
9b46a51
fix: RS telegraf default expected count should be 0, not 1
zanejohnson-azure Apr 11, 2026
6a9ec42
add indirect dependencies to configprocessing go.mod
zanejohnson-azure Apr 14, 2026
e0f7d2d
fix: filter for Running pods and correct RS expected count
zanejohnson-azure Apr 14, 2026
3b9e40a
fix: wait for TestKube API server readiness instead of blind sleep
zanejohnson-azure Apr 14, 2026
cdc9be8
fix: enable testkube-operator for CRD installation on fresh clusters
zanejohnson-azure Apr 15, 2026
5ddc430
chore: add default values for cluster params for quick testing
zanejohnson-azure Apr 15, 2026
163f459
fix: pre-install TestKube CRDs instead of enabling operator
zanejohnson-azure Apr 15, 2026
d72c189
fix: use exact CRD template path instead of glob for helm template
zanejohnson-azure Apr 15, 2026
eddd9ec
fix: label pre-installed CRDs for Helm ownership adoption
zanejohnson-azure Apr 15, 2026
bf3c71b
feat: add Helm deploy stage to deploy ama-logs before config tests
zanejohnson-azure Apr 15, 2026
a5e3bfe
fix: use relative template path for helm deploy
zanejohnson-azure Apr 15, 2026
7283ead
refactor: use each loop and CRS template for scalable config test sce…
zanejohnson-azure Apr 16, 2026
a0d997a
remove helm install
zanejohnson-azure Apr 18, 2026
bffa2c9
refactor
zanejohnson-azure Apr 19, 2026
fe9bf06
refactor: replace inline config test scenarios with YAML test matrix
zanejohnson-azure Apr 20, 2026
2c09aed
test: point countprocess workflow to feature branch for testing
zanejohnson-azure Apr 20, 2026
6b2b618
refactor effort 2
zanejohnson-azure Apr 21, 2026
5c3fbf7
add pipeline vars
zanejohnson-azure Apr 21, 2026
bab9305
group common workflow
zanejohnson-azure Apr 22, 2026
1b9888a
refactor configmap_test package
zanejohnson-azure Apr 23, 2026
d07661e
clean up
zanejohnson-azure Apr 23, 2026
06e1f75
rename script
zanejohnson-azure Apr 23, 2026
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
216 changes: 212 additions & 4 deletions .pipelines/azure-pipeline-config-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,229 @@
# ConfigMap Testing Pipeline for ama-logs (stub - full implementation in zane/configmap-testing-pipeline)
# ConfigMap Testing Pipeline for ama-logs
# Applies different ConfigMap variants, restarts pods, and runs scenario-specific Ginkgo tests via TestKube.
# Manual trigger only.

trigger: none
pr: none

parameters:
- name: clusterName
displayName: 'AKS Cluster Name'
type: string
default: 'ci-logs-dev-aks-std-prof-config-test1'
- name: clusterResourceGroup
displayName: 'AKS Cluster Resource Group'
type: string
default: 'ci-logs-dev-aks-configmap-test'
- name: branch
displayName: 'Git branch for TestKube workflows'
type: string
default: 'zane/configmap-testing-pipeline'
# Case names must match the 'name' field in test/testkube/configmap-test-matrix.yaml
- name: cases
displayName: 'Test cases to run'
type: object
default:
- process-metrics-enabled
- process-metrics-default

stages:
- stage: ConfigMapTests
jobs:
- job: Placeholder
- job: RunConfigMapTests
timeoutInMinutes: 120
displayName: "ConfigMap Processing Tests"
pool:
name: Azure-Pipelines-CI-Test-EO
variables:
skipComponentGovernanceDetection: true
steps:
- script: echo "Pipeline created. Point to branch zane/configmap-testing-pipeline for full implementation."
displayName: 'Placeholder'
- checkout: self
persistCredentials: true

# === Setup ===

- script: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
displayName: 'Install Azure CLI'

- script: |
set -euo pipefail
echo "Ensuring kubectl & helm are installed"
if ! command -v az >/dev/null 2>&1; then
echo "Azure CLI not found; aborting" >&2
exit 1
fi
if ! command -v kubectl >/dev/null 2>&1; then
echo "kubectl not found. Installing via 'az aks install-cli' with sudo"
sudo az aks install-cli
else
echo "kubectl already installed: $(kubectl version --client --short || true)"
fi
if ! command -v helm >/dev/null 2>&1; then
echo "Helm not found. Installing Helm 3"
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
else
echo "Helm already installed: $(helm version --short || true)"
fi
displayName: 'Install kubectl and Helm'

- task: AzureCLI@2
displayName: Get kubeconfig
inputs:
azureSubscription: 'ContainerInsights_Build_Subscription_CI'
scriptLocation: 'inlineScript'
scriptType: 'bash'
inlineScript: 'az aks get-credentials -g ${{ parameters.clusterResourceGroup }} -n ${{ parameters.clusterName }}'

- script: |
echo "Install testkube CLI"
wget -qO - https://repo.testkube.io/key.pub | sudo apt-key add -
echo "deb https://repo.testkube.io/linux linux main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y testkube
displayName: 'Install Testkube CLI'

- bash: |
set -euo pipefail

# Remove stale CRDs that block Helm ownership
stale_crds=(
"testworkflowexecutions.testworkflows.testkube.io"
"testworkflows.testkube.io"
"testworkflows.testworkflows.testkube.io"
"testworkflowtemplates.testworkflows.testkube.io"
)
echo "Checking for stale Testkube CRDs"
for crd in "${stale_crds[@]}"; do
if kubectl get crd "$crd" >/dev/null 2>&1; then
owner=$(kubectl get crd "$crd" -o jsonpath='{.metadata.labels.app\.kubernetes\.io/managed-by}')
if [[ "$owner" != "Helm" ]]; then
echo "Deleting CRD $crd with unmanaged owner: ${owner:-none}"
kubectl delete crd "$crd" --wait=true || true
fi
fi
done

# Clean up existing TestKube installation if present
if helm list -n testkube 2>/dev/null | grep -q testkube; then
echo "Found existing Testkube installation. Cleaning up..."
helm uninstall testkube -n testkube || true
kubectl delete namespace testkube --wait=true --timeout=120s || true
sleep 30
fi

# Add Helm repo
helm repo add kubeshop https://kubeshop.github.io/helm-charts
helm repo update

# Pre-install CRDs from the chart so post-install hooks can create
# TestWorkflowTemplate resources. The operator is disabled in values
# (existing CI clusters already have CRDs from prior installs).
echo "Pre-installing TestKube CRDs from chart..."
helm template testkube kubeshop/testkube -n testkube \
-f ./helm-testkube-values.yaml \
--set testkube-operator.enabled=true \
--set testkube-operator.installCRD=true \
--show-only charts/testkube-operator/templates/crds.yaml \
| kubectl apply --server-side -f -

# Label/annotate CRDs so Helm adopts them as part of the "testkube" release
echo "Labeling CRDs for Helm ownership..."
for crd in $(kubectl get crds -o name | grep testkube); do
kubectl label "$crd" app.kubernetes.io/managed-by=Helm --overwrite
kubectl annotate "$crd" meta.helm.sh/release-name=testkube --overwrite
kubectl annotate "$crd" meta.helm.sh/release-namespace=testkube --overwrite
done

echo "Waiting for CRDs to be established..."
for crd in testworkflows.testworkflows.testkube.io testworkflowtemplates.testworkflows.testkube.io testworkflowexecutions.testworkflows.testkube.io; do
kubectl wait --for=condition=Established crd/"$crd" --timeout=60s || echo "Warning: CRD $crd not yet established"
done

# Install TestKube (operator stays DISABLED — CRDs already in place)
helm upgrade --install --create-namespace testkube kubeshop/testkube -n testkube \
-f ./helm-testkube-values.yaml

# Apply RBAC
kubectl apply -f ./api-server-permissions.yaml

echo "Waiting for TestKube API server to be ready..."
kubectl rollout status deployment/testkube-api-server -n testkube --timeout=300s
# Give the API server a moment to finish initialization after pod is ready
sleep 15
workingDirectory: $(Build.SourcesDirectory)/test/testkube
displayName: 'Install TestKube on cluster'

# Apply TestWorkflow CRs (includes countprocess and others)
- bash: |
kubectl apply -f ./testkube-test-crs.yaml
echo "Waiting for TestWorkflows to be registered..."
sleep 10
workingDirectory: $(Build.SourcesDirectory)/test/testkube
displayName: 'Apply TestWorkflow CRs'

# === Validate cases match matrix ===
- bash: |
set -euo pipefail

# Install yq if not present
if ! command -v yq &> /dev/null; then
curl -sL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /tmp/yq
chmod +x /tmp/yq
yq="/tmp/yq"
else
yq="yq"
fi

# Cases from pipeline parameter
echo "$PIPELINE_CASES" | tr ',' '\n' | sed 's/^ *//;s/ *$//' | sort > /tmp/pipeline.txt

# Cases from matrix YAML
$yq '.cases[].name' ./configmap-test-matrix.yaml | sort > /tmp/matrix.txt

echo "Pipeline cases:"
cat /tmp/pipeline.txt
echo ""
echo "Matrix cases:"
cat /tmp/matrix.txt
echo ""

if ! diff /tmp/pipeline.txt /tmp/matrix.txt; then
echo "##[error]Pipeline cases and matrix cases are out of sync!"
echo "Update the 'cases' parameter in azure-pipeline-config-tests.yaml to match configmap-test-matrix.yaml"
exit 1
fi

echo "Pipeline cases match matrix cases."
workingDirectory: $(Build.SourcesDirectory)/test/testkube
displayName: 'Validate cases match matrix'
env:
PIPELINE_CASES: ${{ join(',', parameters.cases) }}

# === Run test cases (one step per case) ===
- ${{ each caseName in parameters.cases }}:
- bash: |
chmod +x ./run-configmap-test-case.sh
./run-configmap-test-case.sh \
--case "${{ caseName }}" \
--repo-root "$(Build.SourcesDirectory)"
workingDirectory: $(Build.SourcesDirectory)/test/testkube
displayName: "ConfigTest: ${{ caseName }}"
continueOnError: true
env:
AZURE_TENANT_ID: $(AZURE_TENANT_ID)
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
GENEVA_INTEGRATION: false

# === Cleanup ===
- bash: |
echo "Restoring original configmap..."
kubectl apply -f $(Build.SourcesDirectory)/kubernetes/container-azm-ms-agentconfig.yaml || true

echo "Cleaning up Testkube installation..."
helm uninstall testkube -n testkube || true
kubectl delete namespace testkube --wait=true --timeout=120s || true
echo "Cleanup complete."
workingDirectory: $(Build.SourcesDirectory)/test/testkube
displayName: 'Cleanup'
condition: always()
Loading
Loading