-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/end to end tests #9
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
Conversation
Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
… 240 seconds Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
fca9635 to
98ec952
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the end-to-end testing infrastructure to improve reliability and debugging capabilities. The changes introduce OCI-based package delivery as the default mode, add a flag to skip MariaDB tests for focused debugging, and harden PostgreSQL test setup with better error handling and diagnostics.
Key Changes:
- Switched to OCI mode by default for provider package delivery, using an in-cluster registry instead of mounted cache volumes
- Added
SKIP_MARIADBflag to enable PostgreSQL-only test runs - Improved PostgreSQL installation robustness with helm upgrade pattern, disabled persistence, and enhanced readiness checks
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 15 comments.
| File | Description |
|---|---|
| cmd/provider/main.go | Added configurable cache-sync-timeout flag for controller startup |
| cluster/local/postgresdb_functions.sh | Hardened PostgreSQL setup with pipefail-safe password generation, helm upgrade pattern, port-forward readiness checks, and safer cleanup |
| cluster/local/integration_tests.sh | Implemented OCI mode with in-cluster registry, added SKIP_MARIADB flag, improved provider health checks, and removed hardcoded Helm chart versions |
| .github/workflows/ci.yml | Added tmate debugging session for interactive troubleshooting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "${KUBECTL}" get all -A || true | ||
| "${KUBECTL}" get events --sort-by=.lastTimestamp | tail -n 200 || true | ||
| "${HELM}" status postgresdb || true | ||
| echo_error "Helm install/upgrade of PostgresDB failed" |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message uses echo_error but then doesn't exit. After checking for helm install failure and dumping diagnostics, the script should exit with a non-zero status code since the installation failed. Currently, the script continues executing even after the Helm install has failed.
| echo_error "Helm install/upgrade of PostgresDB failed" | |
| echo_error "Helm install/upgrade of PostgresDB failed" | |
| return $rc |
|
|
||
| # Start port-forward; ignore output filtering failures under pipefail | ||
| echo_sub_step "Start port-forward to svc/postgresdb-postgresql:5432" | ||
| ( "${KUBECTL}" port-forward --namespace default svc/postgresdb-postgresql 5432:5432 | grep -v "Handling connection for" || true ) & |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The port-forward command is being launched in a subshell with error suppression that could hide issues. The grep filter failure is silenced with '|| true', and any kubectl errors are redirected but not logged. If the port-forward fails to start, the script will proceed to the readiness check loop which will eventually timeout without clear indication of what went wrong. Consider capturing and logging stderr from kubectl separately before discarding it.
| # Wait for local port to be ready | ||
| for i in {1..20}; do | ||
| if nc -z 127.0.0.1 5432 >/dev/null 2>&1; then | ||
| echo_sub_step "Port-forward ready (PID: ${PORT_FORWARD_PID})" | ||
| echo_step_completed | ||
| break | ||
| fi | ||
| sleep 0.5 | ||
| if [ $i -eq 20 ]; then |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded timeout of 10 seconds (20 iterations × 0.5 seconds) may be too short for slower environments or loaded systems. The port-forward can take longer to establish in resource-constrained CI environments. Consider making this configurable or increasing the timeout to a more conservative value like 30 seconds.
| # Wait for local port to be ready | |
| for i in {1..20}; do | |
| if nc -z 127.0.0.1 5432 >/dev/null 2>&1; then | |
| echo_sub_step "Port-forward ready (PID: ${PORT_FORWARD_PID})" | |
| echo_step_completed | |
| break | |
| fi | |
| sleep 0.5 | |
| if [ $i -eq 20 ]; then | |
| # Wait for local port to be ready; allow overriding max attempts via env var | |
| PORT_FORWARD_MAX_ATTEMPTS="${POSTGRES_PORT_FORWARD_MAX_ATTEMPTS:-60}" | |
| for ((i=1; i<=PORT_FORWARD_MAX_ATTEMPTS; i++)); do | |
| if nc -z 127.0.0.1 5432 >/dev/null 2>&1; then | |
| echo_sub_step "Port-forward ready (PID: ${PORT_FORWARD_PID})" | |
| echo_step_completed | |
| break | |
| fi | |
| sleep 0.5 | |
| if [ "$i" -eq "$PORT_FORWARD_MAX_ATTEMPTS" ]; then |
| mkdir -p "${projectdir}/.work" | ||
| ( kubectl -n crossplane-system port-forward svc/registry 5000:5000 >/dev/null 2>&1 & echo $! >"${projectdir}/.work/registry-pf.pid" ) | ||
| for i in {1..20}; do nc -z localhost 5000 && break || sleep 0.5; done | ||
| } |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The registry port-forward process is launched in a background subshell with all output redirected to /dev/null, making it difficult to diagnose failures. The PID is captured, but if the port-forward fails immediately after starting, the subsequent nc check loop will timeout without useful diagnostic information about why the port-forward failed.
| } | |
| ( kubectl -n crossplane-system port-forward svc/registry 5000:5000 >"${projectdir}/.work/registry-pf.log" 2>&1 & echo $! >"${projectdir}/.work/registry-pf.pid" ) |
| set +o pipefail | ||
| postgres_root_pw=$(LC_ALL=C tr -cd "A-Za-z0-9" </dev/urandom | head -c 32 || true) | ||
| set -o pipefail |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pipefail handling for password generation is overly complex. Temporarily disabling pipefail with 'set +o pipefail' and then re-enabling it just to handle the 'head' command's SIGPIPE is a workaround that adds complexity. A cleaner approach would be to check if the password was generated successfully after the command, or use a different method that doesn't trigger SIGPIPE.
| set +o pipefail | |
| postgres_root_pw=$(LC_ALL=C tr -cd "A-Za-z0-9" </dev/urandom | head -c 32 || true) | |
| set -o pipefail | |
| postgres_root_pw=$(LC_ALL=C tr -cd "A-Za-z0-9" </dev/urandom | head -c 32 || true) |
f938334 to
f8266a6
Compare
f8266a6 to
458a8d0
Compare
Provider SQL: Default OCI packaging + stabilized E2E on Kind
Summary
This PR standardizes provider installation via OCI package (tag
latest) and hardens local end-to-end tests on a Kind cluster. It removes the temporary MariaDB skip option and ensures both MariaDB (no-TLS & TLS) and PostgreSQL suites run reliably with clear diagnostics and robust Helm-based setup.Key Changes
.xpkgto an in-cluster registry.:latesttag..gz) whenUSE_OCI=false.set -euo pipefail, step-by-step logging, extended waits, and better error messages.helm upgrade --install --wait --timeoutand repoadd/updatefor deterministic installs.SKIP_MARIADB).auth.postgresPassword, disabled persistence for Kind, and added readiness checks.pipefail.Implementation Details
.xpkgis pushed with both version andlatesttags, and Crossplane installs the Provider from the OCI reference.USE_OCI=false.Relevant scripts:
Test Plan
Run the full local end-to-end suite on Kind.
Prerequisites:
kind,kubectl, andhelmavailable on your machine.Examples:
Expected outcome:
Flags & Configuration
USE_OCI(default:true):true: in-cluster registry + OCI install with:latesttag.false: local cache path via PVC referencing the.gzpackage.KIND_VERSION,KIND_NODE_IMAGE_TAG).CI Impact
Breaking Changes
SKIP_MARIADBflag was removed; the suite now always runs both MariaDB and PostgreSQL as intended.Checklist
:latestby defaultUSE_OCI=false)Notes
If you encounter chart/image pull issues on Kind, ensure the Bitnami repos are added/updated and avoid pinning to stale chart versions. The integration tests use the following verified chart versions:
Increased waits and explicit readiness checks are in place, but logs from the integration script will guide further troubleshooting.