Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TT-13041] [release-5.3] backport (#6499)
### **User description** Backport of issue on master, two conflicts resolved: 1. session.Touch doesn't exist on 5.3 (api compatibility) 2. some internal gateway function renames (initSystem) ___ ### **PR Type** Bug fix, Enhancement, Tests ___ ### **Description** - Refactored the `RedisQuotaExceeded` function to improve quota handling logic, including better management of key expiration and renewal. - Enhanced logging with additional context to aid in debugging and monitoring of quota operations. - Removed the distributed lock during quota increment and added it during quota reset to optimize performance. - Updated test cases in `middleware_test.go` to use `t.Run` for better organization and added additional test cases for comprehensive coverage. - Introduced `test.Exclusive` function to limit parallelism in tests that use `DeleteAllKeys`. - Replaced `initialiseSystem` with `initSystem` and added a global mutex for synchronization. - Enhanced CI workflow by adding steps to print CPU info and Go environment. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>4 files</summary><table> <tr> <td> <details> <summary><strong>session_manager.go</strong><dd><code>Refactor and improve quota handling logic</code> </dd></summary> <hr> gateway/session_manager.go <li>Refactored <code>RedisQuotaExceeded</code> function to improve quota handling.<br> <li> Enhanced logging for better debugging and monitoring.<br> <li> Removed distributed lock during quota increment and added it during <br>quota reset.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-e6b40a285464cd86736e970c4c0b320b44c75b18b363d38c200e9a9d36cdabb6">+81/-50</a> </td> </tr> <tr> <td> <details> <summary><strong>server.go</strong><dd><code>Synchronize system initialization with global mutex</code> </dd></summary> <hr> gateway/server.go <li>Replaced <code>initialiseSystem</code> with <code>initSystem</code>.<br> <li> Added a global mutex for synchronization.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+6/-4</a> </td> </tr> <tr> <td> <details> <summary><strong>testutil.go</strong><dd><code>Update test utility for system initialization</code> </dd></summary> <hr> gateway/testutil.go - Replaced `initialiseSystem` with `initSystem`. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-7aaf6ae49fb8f58a8c99d337fedd15b3e430dd928ed547e425ef429b10d28ce8">+1/-1</a> </td> </tr> <tr> <td> <details> <summary><strong>util.go</strong><dd><code>Add exclusive test execution utility</code> </dd></summary> <hr> test/util.go - Introduced `Exclusive` function to gate single test execution. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-042018ccb72a158622dc1cc3307e54dc21761f6ab59e5635854810127e4f48e6">+15/-0</a> </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>6 files</summary><table> <tr> <td> <details> <summary><strong>middleware_test.go</strong><dd><code>Refactor and extend test cases for session limiter</code> </dd></summary> <hr> gateway/middleware_test.go <li>Added <code>test.Exclusive</code> to limit parallelism in tests.<br> <li> Refactored test cases to use <code>t.Run</code> for better organization.<br> <li> Added additional test cases for comprehensive coverage.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-6a09a08e3f82cc5e9d8c6b5c8426d75ea1e5d85e15ab008fca1f512e7c49c1e6">+27/-24</a> </td> </tr> <tr> <td> <details> <summary><strong>api_test.go</strong><dd><code>Add exclusive test handling for API tests</code> </dd></summary> <hr> gateway/api_test.go <li>Added <code>test.Exclusive</code> to limit parallelism in tests.<br> <li> Added comments to <code>DeleteAllKeys</code> for clarity.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+11/-3</a> </td> </tr> <tr> <td> <details> <summary><strong>gateway_test.go</strong><dd><code>Add exclusive test handling for quota tests</code> </dd></summary> <hr> gateway/gateway_test.go - Added `test.Exclusive` to limit parallelism in quota tests. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-d34c7069ce5e81d45082b19eb3e869ee1a086e185dcd6630e75e3ed0d368b546">+2/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>mw_external_oauth_test.go</strong><dd><code>Add exclusive test handling for OAuth middleware tests</code> </dd></summary> <hr> gateway/mw_external_oauth_test.go <li>Added <code>test.Exclusive</code> to limit parallelism in OAuth middleware tests.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-3bde461a83fa23b503cf80349641129e4c69e6ae1afb7b628a882fada3a54566">+4/-2</a> </td> </tr> <tr> <td> <details> <summary><strong>mw_rate_limiting_test.go</strong><dd><code>Add exclusive test handling for rate limiting tests</code> </dd></summary> <hr> gateway/mw_rate_limiting_test.go <li>Added <code>test.Exclusive</code> to limit parallelism in rate limiting tests.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-7cf2199231924147d538ba7ad576a48a3c0e691852077e147c9b2d86ba9b7c4d">+4/-1</a> </td> </tr> <tr> <td> <details> <summary><strong>rpc_storage_handler_test.go</strong><dd><code>Add exclusive test handling for RPC storage handler tests</code></dd></summary> <hr> gateway/rpc_storage_handler_test.go <li>Added <code>test.Exclusive</code> to limit parallelism in RPC storage handler <br>tests.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-69de989a02b3bc32ae376c514ee84633c609200db22385c0e16c361d6ea74cd6">+11/-6</a> </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>1 files</summary><table> <tr> <td> <details> <summary><strong>ci-tests.yml</strong><dd><code>Enhance CI workflow with additional environment information</code></dd></summary> <hr> .github/workflows/ci-tests.yml - Added steps to print CPU info and Go environment in CI workflow. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6499/files#diff-03609cb60b0c6e92fb771eb8787d6722b8c31ca4c03eabc788e147acd8c6fb43">+6/-0</a> </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions --------- Co-authored-by: Tit Petric <[email protected]> Co-authored-by: Esteban Ricardo Mirizio <[email protected]>
- Loading branch information