[TT-16950] Backport test fixes for nonroot gateway and RPC storage#8036
[TT-16950] Backport test fixes for nonroot gateway and RPC storage#8036buger merged 2 commits intorelease-5.12.1from
Conversation
<!-- Provide a general summary of your changes in the Title above --> [TT-16693](https://tyktech.atlassian.net/browse/TT-16693) [TT-16695](https://tyktech.atlassian.net/browse/TT-16695) [TT-16696](https://tyktech.atlassian.net/browse/TT-16696) ## Description When running tests that use the StartTest helper with `config.SlaveOptions.UseRPC` enabled, the gateway enters an "emergency mode" and the gateway falls back to loading API Definitions and Policies from a Redis backup instead of the master nodes. Because the entire test suite runs against a single shared Redis instance, tests running in parallel would often write to the same Redis keys. This created a race condition where a test could read data written by another test. The data, while often valid JSON, would have an incorrect structure for the context in which it was being read. The unmarshaling process would succeed but produce a slice containing nil values ([]model.MergedAPI{nil}). Subsequent code that did not anticipate these nil values would then panic, causing the test to fail unpredictably. Subsequently, the `prepareSpecs` function iterates over this slice and calls methods on the APIDefinition. This leads to a nil pointer dereference panic when it encounters one of the nil entries. ## List of change 1. Update dispatcher setup at tests to assign default func handlers and make code cleaner 2. Update the expected response values to provide better documentation 3. Add unique tags for RPC based tests to avoid fetching invalid values populated by other tests ## How This Has Been Tested This change is targeting flaky tests not the production code in particular ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [x] I ensured that the documentation is up to date - [x] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why <!---TykTechnologies/jira-linter starts here--> ### Ticket Details <details> <summary> <a href="https://tyktech.atlassian.net/browse/TT-16693" title="TT-16693" target="_blank">TT-16693</a> </summary> | | | |---------|----| | Status | In Code Review | | Summary | [CI GW] Failing Unit Test: TestProcessKeySpaceChanges_UserKeyReset | Generated at: 2026-03-10 06:40:24 </details> <!---TykTechnologies/jira-linter ends here--> [TT-16693]: https://tyktech.atlassian.net/browse/TT-16693?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TT-16695]: https://tyktech.atlassian.net/browse/TT-16695?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TT-16696]: https://tyktech.atlassian.net/browse/TT-16696?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Vlad Zabolotnyi <vlad.z@tyk.io>
- The gateway base image now runs as `nonroot` (uid 65532) instead of root - Test docker-compose files mount host directories (`apps`, `policies`) into `/opt/tyk-gateway/`, but Docker creates these as root when they don't exist, causing permission denied errors - Adds `mkdir -p && chmod 777` for mounted directories before `docker compose up` in three test suites: specs, tracing, and metrics - [ ] Verify specs contract tests pass in CI (apps/policies dirs created writable) - [ ] Verify tracing e2e tests pass in CI - [ ] Verify metrics e2e tests pass in CI 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🚨 Jira Linter FailedCommit: The Jira linter failed to validate your PR. Please check the error details below: 🔍 Click to view error detailsNext Steps
This comment will be automatically deleted once the linter passes. |
|
This pull request backports two test-related fixes to the Files Changed Analysis
Architecture & Impact Assessment
Scope Discovery & Context Expansion
Metadata
Powered by Visor from Probelabs Last updated: 2026-04-15T19:22:49.414Z | Triggered by: pr_opened | Commit: 42387fa 💡 TIP: You can chat with Visor using |
Security Issues (2)
Security Issues (2)
No architecture issues found – changes LGTM. ✅ Performance Check PassedNo performance issues found – changes LGTM. Powered by Visor from Probelabs Last updated: 2026-04-15T19:22:41.144Z | Triggered by: pr_opened | Commit: 42387fa 💡 TIP: You can chat with Visor using |
|
API Changes no api changes detected |
|



Problem / Task
Backport test fixes for nonroot gateway and RPC storage to release-5.12.1.
Changes
Testing