Repository navigation
feat(integration): add real Spring Boot 3.x/4.x integration tests #1361
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
Merged
stokpop
merged 1 commit into
cloudfoundry:main
from
stokpop:feature/1357-real-spring-boot-integration-fixtures
Aug 27, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| package integration_test | ||
|
|
||
| import ( | ||
| "archive/zip" | ||
| "fmt" | ||
| "io" | ||
| "net/http" | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| "time" | ||
| ) | ||
|
|
||
| const ( | ||
| javaTestAppsReleaseTag = "v1.0.0" | ||
| javaTestAppsBaseURL = "https://github.com/cloudfoundry/java-test-applications/releases/download/" + javaTestAppsReleaseTag | ||
| sb3JarName = "java-main-application-boot3-1.0.0.jar" | ||
| sb4JarName = "java-main-application-1.0.0.jar" | ||
| ) | ||
|
|
||
| // downloadJavaTestAppsJars downloads the pinned SB3 and SB4 fat jars. | ||
| // For Docker-mode tests, jars are extracted (exploded) into fixture directories | ||
| // to simulate what real CF staging does: CF treats the pushed artifact as a zip | ||
| // and extracts it before running the buildpack, so BOOT-INF/ and META-INF/ | ||
| // appear as flat files on disk. | ||
| // For CF-mode tests, the raw jar is returned as-is — `cf push -p` handles | ||
| // zip extraction natively. | ||
| // | ||
| // Pre-exploding is the correct pattern for Docker-mode tests: switchblade's | ||
| // Docker mode archives the fixture directory as-is (TGZArchiver), while CF mode | ||
| // delegates to `cf push -p` which handles zip extraction natively. | ||
| // See https://github.com/cloudfoundry/switchblade/issues/134 for details. | ||
| // | ||
| // Returns (sb3FixturePath, sb4FixturePath, cleanup func, error). | ||
| func downloadJavaTestAppsJars(platform string) (string, string, func(), error) { | ||
| dir, err := os.MkdirTemp("", "java-test-apps-*") | ||
| if err != nil { | ||
| return "", "", nil, fmt.Errorf("create temp dir: %w", err) | ||
| } | ||
|
|
||
| cleanup := func() { os.RemoveAll(dir) } | ||
|
|
||
| type jarEntry struct { | ||
| jarName string | ||
| path string // set after download/extract | ||
| } | ||
| entries := []jarEntry{ | ||
| {jarName: sb3JarName}, | ||
| {jarName: sb4JarName}, | ||
| } | ||
|
|
||
| for i := range entries { | ||
| jarPath := filepath.Join(dir, entries[i].jarName) | ||
| if err := downloadFile(javaTestAppsBaseURL+"/"+entries[i].jarName, jarPath); err != nil { | ||
| cleanup() | ||
| return "", "", nil, fmt.Errorf("download %s: %w", entries[i].jarName, err) | ||
| } | ||
|
|
||
| if platform == "docker" { | ||
| // Docker mode: explode jar into directory (simulates CF staging zip extraction). | ||
| // Switchblade Docker archives the fixture dir as-is via TGZArchiver. | ||
| explodedDir := filepath.Join(dir, fmt.Sprintf("exploded-%d", i)) | ||
| if err := extractZip(jarPath, explodedDir); err != nil { | ||
| cleanup() | ||
| return "", "", nil, fmt.Errorf("extract %s: %w", entries[i].jarName, err) | ||
| } | ||
| _ = os.Remove(jarPath) | ||
| entries[i].path = explodedDir | ||
| } else { | ||
| // CF mode: return raw jar path — `cf push -p` handles zip extraction natively. | ||
| entries[i].path = jarPath | ||
| } | ||
| } | ||
|
|
||
| return entries[0].path, entries[1].path, cleanup, nil | ||
| } | ||
|
|
||
| // extractZip extracts a zip/jar file into destDir, replicating the flat-file | ||
| // layout that CF staging creates when it unpacks the pushed artifact. | ||
| func extractZip(src, destDir string) error { | ||
| r, err := zip.OpenReader(src) | ||
| if err != nil { | ||
| return fmt.Errorf("open zip: %w", err) | ||
| } | ||
| defer r.Close() | ||
|
|
||
| for _, f := range r.File { | ||
| target := filepath.Join(destDir, f.Name) | ||
|
|
||
| // Guard against zip-slip | ||
| if !strings.HasPrefix(filepath.Clean(target)+string(os.PathSeparator), | ||
| filepath.Clean(destDir)+string(os.PathSeparator)) { | ||
| return fmt.Errorf("zip entry %q escapes destination", f.Name) | ||
| } | ||
|
|
||
| if f.FileInfo().IsDir() { | ||
| if err := os.MkdirAll(target, 0755); err != nil { | ||
| return err | ||
| } | ||
| continue | ||
| } | ||
|
|
||
| if err := os.MkdirAll(filepath.Dir(target), 0755); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| out, err := os.OpenFile(target, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, f.Mode()) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| rc, err := f.Open() | ||
| if err != nil { | ||
| out.Close() | ||
| return err | ||
| } | ||
|
|
||
| _, copyErr := io.Copy(out, rc) | ||
| rc.Close() | ||
| out.Close() | ||
| if copyErr != nil { | ||
| return copyErr | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func downloadFile(url, dest string) error { | ||
| client := &http.Client{Timeout: 2 * time.Minute} | ||
| resp, err := client.Get(url) //nolint:noctx | ||
| if err != nil { | ||
| return err | ||
| } | ||
| defer resp.Body.Close() | ||
|
|
||
| if resp.StatusCode != http.StatusOK { | ||
| return fmt.Errorf("HTTP %d for %s", resp.StatusCode, url) | ||
| } | ||
|
|
||
| f, err := os.Create(dest) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| defer f.Close() | ||
|
|
||
| _, err = io.Copy(f, resp.Body) | ||
| return err | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@stokpop note that the build fails in https://concourse.app-runtime-interfaces.ci.cloudfoundry.org/teams/buildpacks-team/pipelines/java-buildpack/jobs/specs-switchblade-docker-cflinuxfs4/builds/144 with:
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.
@kiril-keranov thanks for noticing. Is there a way to test branches before the merge? In this case I tested locally, and it uses some unstaged empty dirs that were not present in the merged code (git does not work with empty dirs). It only fails locally with a complete fresh checkout that then also misses these empty dirs.
Made a followup fix PR: #1404, can you have a look? Thanks
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.
@stokpop We might think of introducing some PR validation jobs to run the tests. I also run the tests locally, don't think there is possibility currently for central test run on PR changes