java-buildpack icon indicating copy to clipboard operation
java-buildpack copied to clipboard

Migrate to Switchblade integration tests and modernize Ruby toolchain

Open ramonskie opened this issue 1 month ago • 4 comments

Summary

  • Migrate integration tests from legacy Java/Maven system to Switchblade (Go-based framework)
  • Modernize Ruby toolchain from 2.5.9 to 3.4.7 with compatibility fixes
  • Add containerized build tooling for platform-independent development
  • Update platform support from Ubuntu Bionic to Jammy

Integration Test Migration

New Switchblade Test Suite

  • 43 total tests across 9 categories with 100% pass rate
  • 39 active container tests + 4 offline/cached tests
  • Test runtime: ~7-8 minutes with optimal parallelism (-parallel=4)

Test Coverage

Category Tests Coverage
Tomcat 5 Servlet apps, JRE selection (Java 8/11/17), memory calculator
SpringBoot 4 Spring Boot apps, auto-reconfiguration, java-cfenv
JavaMain 4 Java Main-Class applications, JAVA_OPTS, custom arguments
Groovy 5 Scripts, main method, shebang, JAR files, edge cases
Ratpack 3 Ratpack dist/staged applications, JRE versions
Play Framework 8 Play 2.0/2.1/2.2, dist/staged, negative test for hybrid apps
DistZip 4 Distribution ZIP applications, custom classpath, JRE selection
SpringBootCLI 6 CLI apps, beans config, Groovy scripts, WEB-INF handling
Offline 4 Offline deployment, cached dependencies

Benefits over Legacy System

  • 5-6x more test scenarios per application type (legacy had 1 test per type)
  • Docker-based testing - no CF API required for local development
  • Enhanced coverage - JRE version selection, framework-specific edge cases
  • Faster execution - ~7-8 minutes vs longer CF deployment cycles
  • 100% stable - consistent pass rate across consecutive runs
  • Modern tooling - Go-based Switchblade framework (Cloud Foundry standard)

Ruby Modernization

Ruby 3.4.7 Migration

  • Update from Ruby 2.5.9 (EOL) to Ruby 3.4.7 (latest stable)
  • Fix Psych 4.0+ YAML compatibility (safe_load, permitted_classes)
  • Update RuboCop toolchain for Ruby 3.4 support
  • Fix REXML compatibility issues

CI/CD Updates

  • Update CI Dockerfile to Ubuntu Jammy (22.04) with Ruby 3.4.7
  • Remove Ubuntu Noble (24.04) support (not yet stable for buildpack)
  • Update platform detection from Bionic to Jammy

Developer Experience Improvements

New Build Scripts

  • scripts/package-local.sh - Containerized buildpack packaging (podman/docker)

    • No local Ruby/Bundler installation required
    • Works on any Linux distribution (Fedora, Ubuntu, etc.)
    • Auto-detects container runtime
  • scripts/integration.sh - Simplified integration test execution

    • Friendly CLI with --platform, --cached, --github-token options
    • Supports both Docker and Cloud Foundry platforms
    • Automatic dependency installation

Usage Examples

# Build buildpack (containerized)
./scripts/package-local.sh

# Run integration tests on Docker
BUILDPACK_FILE=$(pwd)/build/java-buildpack-dev.zip \
  ./scripts/integration.sh --platform docker

# Run tests on Cloud Foundry
BUILDPACK_FILE=$(pwd)/build/java-buildpack-dev.zip \
  ./scripts/integration.sh --platform cf --stack cflinuxfs4

Files Changed

  • 50 files changed: +4,763 insertions, -104 deletions
  • New files: 12 (integration tests, scripts, go.mod/go.sum)
  • Modified files: 32 (Ruby compatibility, CI/CD, docs)
  • Test fixtures: 6 JAR files for Play Framework tests

Testing

  • ✅ All 43 Switchblade tests passing (100% pass rate)
  • ✅ Ruby 3.4.7 compatibility verified
  • ✅ Buildpack packaging tested with containerized builds
  • ✅ Test cleanup verified (no leftover containers/files)

Migration Status

  • Complete migration from legacy test system to Switchblade
  • ✅ All active legacy test types covered with enhanced scenarios
  • ⚠️ EJB tests not included (were disabled in legacy system)
  • 📁 Legacy test directory preserved in temp/ for reference

Related Documentation

  • src/integration/README.md - Comprehensive Switchblade test guide
  • AGENTS.md - Added to .gitignore (session documentation)

ramonskie avatar Nov 19 '25 11:11 ramonskie

@cloudfoundry/wg-app-runtime-interfaces-buildpacks-and-stacks-reviewers FYI this is waiting for a review

beyhan avatar Nov 21 '25 10:11 beyhan

@ramonskie Thanks for working on that. I am not a ruby expert but I noticed something. Actually not related to this particular PR, rather to the ruby 3.4.7 migration in general. If I try to push an app with manifest like: `applications:

  • name: test-app buildpack: https://github.com/cloudfoundry/java-buildpack.git memory: 750M path: ./target/test.war instances: 1`

It fails with: 2025-11-24T12:26:52.92+0200 [STG/0] ERR unknown keywords: :permitted_classes, :aliases 2025-11-24T12:26:52.92+0200 [STG/0] ERR Failed to compile droplet: Failed to run finalize script: exit status 1 2025-11-24T12:26:52.93+0200 [STG/0] OUT Exit status 223

While the same app with latest released Java buildpack 4.77 is pushed successfully.

alexbakar avatar Nov 24 '25 10:11 alexbakar

@alexbakar damn. i really thought i catched all those but @wayneeseguin also mentioned this. let me double check this again

EDIT: cflinuxcf4 should not contain ruby by default. but the cflinuxfs4-compat does have ruby compiled with it. so could you double check if you are using the compat version?

and it seems to me that a older ruby is being used. could you provide the debug logging? maby with CF_TRACE=true

or could you ssh in the container and check the ruby version.

ramonskie avatar Nov 24 '25 11:11 ramonskie

@alexbakar this wil fix it https://github.com/cloudfoundry/java-buildpack/pull/1129 please test it use https://github.com/cloudfoundry/java-buildpack.git#fix-ruby-version-compatibility

see for reference https://cloudfoundry.slack.com/archives/C02HWMDUQ/p1763996653788929

ramonskie avatar Nov 24 '25 17:11 ramonskie