Skip to content

Add health check type configuration and improve CF API compatibility#120

Merged
ramonskie merged 4 commits intomainfrom
health-check
Dec 3, 2025
Merged

Add health check type configuration and improve CF API compatibility#120
ramonskie merged 4 commits intomainfrom
health-check

Conversation

@ivanovac
Copy link
Copy Markdown
Contributor

@ivanovac ivanovac commented Dec 1, 2025

Summary

This PR enhances the switchblade testing framework with health check configuration support and improves Cloud Foundry API compatibility for buildpack testing scenarios.

Changes

1. Health Check Configuration Support

  • Added WithHealthCheckType() method to DeployProcess interface and implementations
    • CF implementation: Calls cf set-health-check to configure process-based or port-based health checks
    • Docker implementation: No-op (Docker doesn't use CF health check types)
  • Use case: Enables tests to explicitly specify health check type for apps that don't run web servers
    • WithHealthCheckType("process") - For scripts/background processes that don't serve HTTP
    • Default (no call) - Uses CF's default port-based health check for web servers

2. CF API v2 to v3 Migration

  • Updated route retrieval in stage.go from /v2/apps/{guid}/routes to /v3/apps/{guid}/routes
  • Fixes compatibility with CF environments where API v2 endpoints are disabled
  • Added stderr logging to route fetch operation for better debugging

3. Graceful TCP Route Handling

  • Made TCP route creation non-fatal in setup.go
    • Previously: Fatal error when TCP port pool exhausted
    • Now: Logs warning and continues with HTTP routes only
  • Rationale: Many buildpack tests only need HTTP routes; TCP is optional for most scenarios
  • Preserves shared library compatibility: Other projects using switchblade may need TCP, so functionality remains but doesn't block tests

4. Buildpack Deletion Fix

  • Removed -s/--stack flag from cf delete-buildpack command in initialize.go
  • Fixes: "stackless buildpack already exists" errors during test initialization
  • Approach: Delete buildpack without stack filter first, then recreate with correct configuration

Motivation

These changes were needed to support R buildpack integration tests running on Cloud Foundry environments with:

  • CF API v2 endpoints disabled
  • Limited TCP port pools
  • Apps using process-based health checks (R scripts, background jobs)
  • Modern CF deployments requiring v3 API usage

Testing

  • ✅ Verified with R buildpack integration tests on CF (cflinuxfs4)
  • ✅ CF platforms tested
  • ✅ Process health check tests passing
  • ✅ TCP route warnings logged but tests continue successfully

Backward Compatibility

  • ✅ All changes are backward compatible
  • WithHealthCheckType() is optional (no call = default behavior)
  • ✅ Docker platform unchanged (health check is no-op)
  • ✅ TCP routes still attempted but failures don't block deployments

Copy link
Copy Markdown
Contributor

@ramonskie ramonskie left a comment

Choose a reason for hiding this comment

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

looks good. but we need to squash this when merging

@ramonskie ramonskie merged commit 6df7f4c into main Dec 3, 2025
2 checks passed
@ramonskie ramonskie deleted the health-check branch December 3, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants