Skip to content

Add test to validate codependency bug exists#1126

Open
geofffranks wants to merge 8 commits intodevelopfrom
sidecar-codependency-bug
Open

Add test to validate codependency bug exists#1126
geofffranks wants to merge 8 commits intodevelopfrom
sidecar-codependency-bug

Conversation

@geofffranks
Copy link
Copy Markdown
Contributor

Made-with: Cursor

Summary

Adds inigo tests to ensure that the issue found with codependent processes exiting of their own accord not triggering other processes to exit does not regress

Backward Compatibility

Breaking Change? no

@geofffranks geofffranks requested a review from a team as a code owner April 23, 2026 14:46
Comment thread src/code.cloudfoundry.org/inigo/cell/codependency_test.go Outdated
Comment on lines +59 to +63
time.Sleep(15 * time.Second)
fmt.Println("Proxy signaling self")
proc, _ := os.FindProcess(os.Getpid())
proc.Signal(syscall.SIGABRT)
time.Sleep(10 * time.Second)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is all this sleeping really necessary? Or can we trigger on something?

Also do we normally have fmt.Println in tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These are being done from inside the processes running inside garden, so the println gets captured as part of the garden job output rather than as test output. It probably goes nowhere anyway since we don't look at any of the logged output.

I'll look into these processes being http servers that the test signals after they're running, to trigger them crashing. But since one is the main app, one is a sidecar process, and one is the proxy process, it may be a little weird.

@geofffranks geofffranks force-pushed the sidecar-codependency-bug branch from c82dd2a to a851c03 Compare April 27, 2026 19:45
The fake applications in codependency tests were failing to exit with the
correct exit codes because server.Shutdown() was causing main() to return
normally before os.Exit() could execute. This was causing integration tests
to timeout as containers remained in RUNNING state instead of CRASHED.

Changes:
- Remove graceful server shutdown that prevented proper exit codes
- Remove 10s sleep after SIGABRT that could interfere with signal handling
- Increase HTTP response flush time to 200ms to ensure response is sent
- Add standalone unit test (test_fake_app.go) to validate exit behavior

The unit test verifies all exit codes work correctly outside Garden/Rep:
- Exit code 0: ✓
- Exit code 1: ✓
- Exit code 134 (SIGABRT): ✓

Made-with: Cursor
Extract embedded fake app and proxy code from test strings into proper
Go source files in assets/ directory. This enables:

- Proper Go linting and vetting of fake app code
- Code reuse between integration tests and unit tests
- Better maintainability and IDE support
- Easier debugging and modification

Changes:
- Create assets/fake_app.go - standalone fake HTTP app
- Create assets/fake_proxy.go - standalone fake proxy with listeners
- Update buildFakeApp() to compile from assets/fake_app.go
- Update buildFakeProxy() to compile from assets/fake_proxy.go
- Update unit test to use asset files instead of embedded code
- Rename unit test file to codependency_fake_app_unit.go (runnable)

Both asset files pass go vet and gofmt checks.

Made-with: Cursor
Replace the poorly implemented standalone test script with a proper
Ginkgo-based unit test that follows Go testing conventions:

✅ FIXED:
1. Uses _test.go suffix (fake_app_test.go)
2. Uses Go testing framework (Ginkgo v2)
3. Uses Ginkgo properly with DescribeTable and test suite
4. Passes gofmt formatting checks
5. Runs in isolated unit test package to avoid integration dependencies

✅ IMPROVEMENTS:
- Proper test organization with BeforeEach/AfterEach
- Comprehensive test coverage: exit codes 0, 1, SIGABRT + edge cases
- Clean port allocation to avoid conflicts
- Proper Gomega matchers for exit code validation
- Uses gexec for proper process management
- Includes edge case testing (invalid exit codes, missing parameters)

Tests validate that fake applications exit correctly with expected
exit codes when called outside the Diego/Garden environment, proving
the asset files work as intended.

All 5 test cases pass:
- fake app exits with code 0 ✓
- fake app exits with code 1 ✓
- fake app exits with SIGABRT ✓
- handles invalid exit codes gracefully ✓
- handles missing exit code parameter ✓

Made-with: Cursor
- Comprehensive 6-task plan to fix SMB volume driver vulnerability
- Includes path validation function and entry point protection
- Covers both tnz-runtime-volume-services-release and smb-volume-release
- Uses TDD approach with detailed test cases and validation

TNZ-97050 ai-assisted=yes

Made-with: Cursor
CRITICAL FIX: assets/fake_app.go and assets/fake_proxy.go both had
package main and main() functions in the same directory, violating
Go's "one main per package" rule. This was causing vet failures:

  vet: cell/assets/fake_proxy.go:27:6: main redeclared in this block

SOLUTION: Move each main package to its own directory:
- assets/fake_app.go → assets/fake_app/main.go
- assets/fake_proxy.go → assets/fake_proxy/main.go

Updated all build references to use directory paths instead of
.go file paths since gexec.Build works with package directories.

✅ VERIFIED:
- GOOS=linux go vet ./assets/fake_app ./assets/fake_proxy (passes)
- Both packages build correctly
- Unit tests still pass (3/3 ✓)
- Integration test build references updated

This follows proper Go package structure where each main package
lives in its own directory.

Made-with: Cursor
@geofffranks geofffranks force-pushed the sidecar-codependency-bug branch from 9f17c6b to 9cf12db Compare May 5, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants