Skip to content
Open
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
132 changes: 37 additions & 95 deletions .github/workflows/kind-ci-automation.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: Build, Deploy and Test on kind
name: Build, Deploy and Test on KinD

on:
pull_request:
branches:
- "master"
- "v*"

permissions:
contents: read

env:
IMG: gitops-operator:test
LOG_DIR: /tmp/kind-ci-artifacts

Comment thread
coderabbitai[bot] marked this conversation as resolved.
jobs:
ci-build:
Expand All @@ -22,10 +26,14 @@ jobs:
with:
go-version-file: 'go.mod'

- name: Prepare log directory
run: mkdir -p "${{ env.LOG_DIR }}"

- name: Create kind cluster
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1
with:
cluster_name: gitops-test
config: test/kind-config.yaml

# TODO: check if porting is required for non-OCP clusters
- name: Disable webhook and conversion for non-OCP cluster
Expand All @@ -40,7 +48,8 @@ jobs:

- name: Build manager image
run: |
make docker-build IMG=${{ env.IMG }}
set -o pipefail
make docker-build IMG=${{ env.IMG }} 2>&1 | tee "${{ env.LOG_DIR }}/docker-build.log"

- name: Load image into kind
run: |
Expand All @@ -52,103 +61,36 @@ jobs:

- name: Deploy operator
run: |
echo "manifests: $(KUSTOMIZE) build config/default"
make deploy IMG=${{ env.IMG }} | tee /tmp/deploy.log
set -o pipefail
make deploy IMG=${{ env.IMG }} 2>&1 | tee "${{ env.LOG_DIR }}/deploy.log"

- name: Verify Controller Manager deployment is available
run: |
kubectl get deployment -n openshift-gitops-operator
kubectl describe deployment -n openshift-gitops-operator
kubectl wait --for=condition=available --timeout=300s \
deployment/openshift-gitops-operator-controller-manager \
-n openshift-gitops-operator

- name: Create ArgoCD instance
set -o pipefail
{
kubectl get deployment -n openshift-gitops-operator
kubectl describe deployment -n openshift-gitops-operator
kubectl wait --for=condition=available --timeout=300s \
deployment/openshift-gitops-operator-controller-manager \
-n openshift-gitops-operator
} 2>&1 | tee "${{ env.LOG_DIR }}/verify-deployment.log"

- name: Run E2E tests Sequential on xKS
run: |
kubectl create ns test-argocd
kubectl apply -f - <<'EOF'
apiVersion: argoproj.io/v1beta1
kind: ArgoCD
metadata:
name: argocd
namespace: test-argocd
EOF
set -o pipefail
NON_OLM=true make e2e-xks-tests-sequential-ginkgo 2>&1 | tee "${{ env.LOG_DIR }}/e2e-sequential.log"

- name: Wait for ArgoCD component pods to exist
- name: Run E2E tests Parallel on xKS
run: |
EXPECTED_LABELS=("argocd-application-controller" "argocd-redis" "argocd-repo-server" "argocd-server")
TIMEOUT=300
INTERVAL=10
ELAPSED=0

echo "Waiting for ArgoCD component pods to exist in test-argocd..."
while true; do
ALL_EXIST=true
for label in "${EXPECTED_LABELS[@]}"; do
if ! kubectl get pod -n test-argocd -l "app.kubernetes.io/name=${label}" --no-headers 2>/dev/null | grep -q .; then
ALL_EXIST=false
break
fi
done

if $ALL_EXIST; then
echo "All ArgoCD component pods exist after ${ELAPSED}s."
break
fi

if [ $ELAPSED -ge $TIMEOUT ]; then
echo "Timed out after ${TIMEOUT}s waiting for ArgoCD pods."
kubectl get pods -n test-argocd
kubectl get argocd -n test-argocd -o yaml
exit 1
fi

sleep $INTERVAL
ELAPSED=$((ELAPSED + INTERVAL))
done
set -o pipefail
NON_OLM=true make e2e-xks-tests-parallel-ginkgo 2>&1 | tee "${{ env.LOG_DIR }}/e2e-parallel.log"

- name: Verify ArgoCD components are ready
run: |
kubectl get pods -n test-argocd
kubectl wait --for=condition=Ready -n test-argocd pod --timeout=300s \
-l 'app.kubernetes.io/name in (argocd-application-controller,argocd-redis,argocd-repo-server,argocd-server)'
echo "All ArgoCD components are ready."
kubectl get pods -n test-argocd

- name: Collect operator debug info on failure
if: failure()
run: |
echo "=== Deployment status ==="
kubectl get deployment -n openshift-gitops-operator -o wide || true
echo ""
echo "=== Pod status ==="
kubectl get pods -n openshift-gitops-operator -o wide || true
echo ""
echo "=== Pod descriptions ==="
kubectl describe pods -n openshift-gitops-operator || true
echo ""
echo "=== Controller manager logs ==="
kubectl logs deployment/openshift-gitops-operator-controller-manager \
-n openshift-gitops-operator --all-containers=true --tail=200 || true
echo ""
echo "=== Events in operator namespace ==="
kubectl get events -n openshift-gitops-operator --sort-by='.lastTimestamp' || true
echo ""
echo "=== CRD conversion config ==="
kubectl get crd argocds.argoproj.io -o jsonpath='{.spec.conversion}' || true
echo ""

- name: Collect ArgoCD debug info on failure
if: failure()
run: |
echo "=== ArgoCD resources ==="
kubectl get argocds -n test-argocd -o yaml 2>/dev/null || true
echo ""
echo "=== Pods in test-argocd ==="
kubectl get pods -n test-argocd -o wide 2>/dev/null || true
echo ""
echo "=== Pod descriptions in test-argocd ==="
kubectl describe pods -n test-argocd 2>/dev/null || true
echo ""
echo "=== Events in test-argocd ==="
kubectl get events -n test-argocd --sort-by='.lastTimestamp' 2>/dev/null || true
- name: Upload CI artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: kind-ci-artifacts-${{ github.run_id }}
path: ${{ env.LOG_DIR }}/
if-no-files-found: ignore
retention-days: 7

21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ endif
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

# GINKGO_VERSION is the version of ginkgo to use.
# Pick ginkgo version from go.mod file.
# Update this command when ginkgo version is updated in go.mod file.
# example: go list -m -f '{{.Version}}' github.com/onsi/ginkgo/v3
GINKGO_VERSION := $(shell go list -m -f '{{.Version}}' github.com/onsi/ginkgo/v2)

# XKS_LABEL_FILTER is the label filter for XKS tests.
XKS_LABEL_FILTER ?= "!openshfit"

.PHONY: all
all: build

Expand Down Expand Up @@ -172,6 +181,16 @@ e2e-tests-sequential:
e2e-tests-parallel:
CI=prow make e2e-tests-parallel-ginkgo

.PHONY: e2e-xks-tests-sequential-ginkgo
e2e-xks-tests-sequential-ginkgo: ginkgo ## Runs Ginkgo e2e sequential tests
@echo "Running GitOps Operator sequential Ginkgo E2E tests..."
$(GINKGO_CLI) -v --trace --label-filter="$(XKS_LABEL_FILTER)" --timeout 240m -r ./test/openshift/e2e/ginkgo/sequential

.PHONY: e2e-xks-tests-parallel-ginkgo ## Runs Ginkgo e2e parallel tests, (Defaults to 5 runs at a time)
e2e-xks-tests-parallel-ginkgo: ginkgo
@echo "Running GitOps Operator parallel Ginkgo E2E tests..."
$(GINKGO_CLI) -p -v -procs=5 --trace --label-filter="$(XKS_LABEL_FILTER)" --timeout 60m -r ./test/openshift/e2e/ginkgo/parallel

##@ Build

.PHONY: build
Expand Down Expand Up @@ -247,7 +266,7 @@ kustomize: ## Download kustomize locally if necessary.
GINKGO_CLI = $(shell pwd)/bin/ginkgo
.PHONY: ginkgo
ginkgo: ## Download ginkgo locally if necessary.
$(call go-get-tool,$(GINKGO_CLI),github.com/onsi/ginkgo/v2/ginkgo@v2.29.0)
$(call go-get-tool,$(GINKGO_CLI),github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION))


# go-get-tool will 'go install' any package $2 and install it to $1.
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/argocd_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ var _ = Describe("Argo CD ConsoleLink controller", func() {
route := &routev1.Route{}
consoleLink := &console.ConsoleLink{}

It("Argocd route is present", func() {
It("Argocd route is present", Label("openshfit"), func() {
checkIfPresent(types.NamespacedName{Name: argoCDRouteName, Namespace: argoCDNamespace}, route)
})

It("ConsoleLink is created", func() {
It("ConsoleLink is created", Label("openshfit"), func() {
checkIfPresent(types.NamespacedName{Name: consoleLinkName}, consoleLink)
})

It("ConsoleLink and argocd route should match", func() {
It("ConsoleLink and argocd route should match", Label("openshfit"), func() {
Eventually(func() error {
err := k8sClient.Get(context.TODO(), types.NamespacedName{Name: consoleLinkName}, consoleLink)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions test/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
50 changes: 50 additions & 0 deletions test/openshift/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,56 @@ SKIP_HA_TESTS=true LOCAL_RUN=true make e2e-tests-sequential-ginkgo



## Test Labels

Ginkgo [labels](https://onsi.github.io/ginkgo/#spec-labels) are used to categorize tests that are only supported on specific platforms or configurations. Labels allow the CI system to filter tests using `--label-filter` at runtime.

**Important**: Labels should only be applied to tests that are restricted to a specific platform or configuration. Do NOT add labels to generic tests that can run on any Kubernetes cluster (OpenShift, KinD, EKS, etc.). If a test works everywhere, it should remain unlabelled.

### Available labels

| Label | Meaning | When to use |
|-------|---------|-------------|
| `openshfit` | Test requires OpenShift-specific features (Routes, ConsoleLinks, OLM Subscriptions, SCCs, etc.) and cannot run on vanilla Kubernetes (KinD, EKS, GKE, AKS). | Add when the test depends on OpenShift APIs or resources not available on non-OCP clusters. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the typo in the OpenShift label name across all documentation and tests.

The label is consistently misspelled as openshfit instead of openshift in the documentation and test files. This mismatch causes confusion and contradicts the PR description, which specifies !openshift. Please correct the spelling across the codebase (including in the XKS_LABEL_FILTER definition in the Makefile).

  • test/openshift/e2e/README.md#L107-L107: change openshfit to openshift.
  • test/openshift/e2e/README.md#L114-L114: change openshfit to openshift.
  • test/openshift/e2e/README.md#L122-L122: change openshfit to openshift.
  • test/openshift/e2e/README.md#L127-L127: change openshfit to openshift.
  • test/openshift/e2e/README.md#L132-L132: change openshfit to openshift.
  • test/openshift/e2e/README.md#L141-L141: change openshfit to openshift.
  • test/openshift/e2e/ginkgo/parallel/1-001_alpha_to_beta_dex_conversion_test.go#L50-L50: change Label("openshfit") to Label("openshift", "conversionWebhook").
  • test/openshift/e2e/ginkgo/sequential/1-083_validate_apps_in_any_namespace_test.go#L57-L57: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-092_validate_workload_status_monitoring_alert.go#L48-L48: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-103-validate-rollouts-imagepullpolicy.go#L51-L51: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-103-validate-rollouts-imagepullpolicy.go#L75-L75: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-103-validate-rollouts-imagepullpolicy.go#L118-L118: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-110_validate_podsecurity_alerts_test.go#L31-L31: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-112_validate_rollout_plugin_support_test.go#L38-L38: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L84-L84: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L103-L103: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L165-L165: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L213-L213: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L245-L245: change Label("openshfit") to Label("openshift").
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L259-L259: change Label("openshfit") to Label("openshift").
🧰 Tools
🪛 LanguageTool

[grammar] ~107-~107: Ensure spelling is correct
Context: ...e | |-------|---------|-------------| | openshfit | Test requires OpenShift-specific feat...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

📍 Affects 8 files
  • test/openshift/e2e/README.md#L107-L107 (this comment)
  • test/openshift/e2e/README.md#L114-L114
  • test/openshift/e2e/README.md#L122-L122
  • test/openshift/e2e/README.md#L127-L127
  • test/openshift/e2e/README.md#L132-L132
  • test/openshift/e2e/README.md#L141-L141
  • test/openshift/e2e/ginkgo/parallel/1-001_alpha_to_beta_dex_conversion_test.go#L50-L50
  • test/openshift/e2e/ginkgo/sequential/1-083_validate_apps_in_any_namespace_test.go#L57-L57
  • test/openshift/e2e/ginkgo/sequential/1-092_validate_workload_status_monitoring_alert.go#L48-L48
  • test/openshift/e2e/ginkgo/sequential/1-103-validate-rollouts-imagepullpolicy.go#L51-L51
  • test/openshift/e2e/ginkgo/sequential/1-103-validate-rollouts-imagepullpolicy.go#L75-L75
  • test/openshift/e2e/ginkgo/sequential/1-103-validate-rollouts-imagepullpolicy.go#L118-L118
  • test/openshift/e2e/ginkgo/sequential/1-110_validate_podsecurity_alerts_test.go#L31-L31
  • test/openshift/e2e/ginkgo/sequential/1-112_validate_rollout_plugin_support_test.go#L38-L38
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L84-L84
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L103-L103
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L165-L165
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L213-L213
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L245-L245
  • test/openshift/e2e/ginkgo/sequential/1-120_repo_server_system_ca_trust.go#L259-L259
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/openshift/e2e/README.md` at line 107, The OpenShift label is misspelled
as openshfit across documentation, Ginkgo tests, and the Makefile’s
XKS_LABEL_FILTER. Replace every occurrence with openshift, preserving the
existing label combinations, including the conversion test’s conversionWebhook
label; update test/openshift/e2e/README.md lines 107-107, 114-114, 122-122,
127-127, 132-132, and 141-141, all listed Ginkgo sites in the specified files,
and the corresponding Makefile definition.

Source: Linked repositories

| `HA` | Test requires a cluster with at least 3 worker nodes for HA (High Availability) validation. | Add when the test creates HA Redis StatefulSets or validates pod anti-affinity across nodes. |
| `conversionWebhook` | Test requires the ArgoCD v1alpha1 ↔ v1beta1 conversion webhook to be running. | Add when the test exercises CRD conversion between API versions. |

### How labels are used in CI

- **OpenShift CI**: Runs all tests (no label filter), so all labelled and unlabelled tests execute.
- **xKS/KinD CI** (`make e2e-xks-tests-sequential-ginkgo` / `make e2e-xks-tests-parallel-ginkgo`): Uses `--label-filter="!openshfit"` to exclude OpenShift-only tests. The `XKS_LABEL_FILTER` env var can further customize filtering (e.g., `XKS_LABEL_FILTER="!openshfit && !HA"`).

### How to apply a label

Add the `Label(...)` decorator to `It`, `Context`, or `Describe` nodes:

```go
// Single label — test requires OpenShift
It("verifies ConsoleLink is created for ArgoCD route", Label("openshfit"), func() {
// ...
})

// Multiple labels — test requires OpenShift AND conversion webhook
It("verifies v1beta1 to v1alpha1 conversion", Label("conversionWebhook", "openshfit"), func() {
// ...
})

// Label on Context — all specs inside inherit the label
Context("1-120_repo_server_system_ca_trust", Label("openshfit"), func() {
It("ensures that missing Secret aborts startup", func() {
// ...
})
})
```

### Guidelines

- If your test uses OpenShift-specific resources (Routes, ConsoleLinks, SCCs, Subscriptions, CSVs, monitoring via prometheus-operator CRDs that are only present on OCP, etc.), add `Label("openshfit")`.
- If your test requires 3+ nodes for HA validation, add `Label("HA")`.
- If your test works on any conformant Kubernetes cluster, do NOT add any label.
- When in doubt, leave the test unlabelled — it will run everywhere, which provides broader coverage.


## Test Code

gitops-operator E2E tests are defined within `test/openshift/e2e/ginkgo`.
Expand Down
Loading
Loading