-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Merging to release-5.8: Disabled/empty uptime test fields migrated to Tyk OAS (#7069) #7085
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
Merging to release-5.8: Disabled/empty uptime test fields migrated to Tyk OAS (#7069) #7085
Conversation
### **User description** <details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-14183" title="TT-14183" target="_blank">TT-14183</a></summary> <br /> <table> <tr> <th>Summary</th> <td>Disabled/empty uptime test fields migrated to Tyk OAS</td> </tr> <tr> <th>Type</th> <td> <img alt="Bug" src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium" /> Bug </td> </tr> <tr> <th>Status</th> <td>In Code Review</td> </tr> <tr> <th>Points</th> <td>N/A</td> </tr> <tr> <th>Labels</th> <td><a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%205.8.0Regression%20ORDER%20BY%20created%20DESC" title="5.8.0Regression">5.8.0Regression</a>, <a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%205.8.1Refinement%20ORDER%20BY%20created%20DESC" title="5.8.1Refinement">5.8.1Refinement</a>, <a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20QA_Fail%20ORDER%20BY%20created%20DESC" title="QA_Fail">QA_Fail</a>, <a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC" title="codilime_refined">codilime_refined</a></td> </tr> </table> </details> <!-- do not remove this marker as it will break jira-lint's functionality. added_by_jira_lint --> --- <!-- Provide a general summary of your changes in the Title above --> Chnage migration rules <!-- Describe your changes in detail --> ## Related Issue <!-- This project only accepts pull requests related to open issues. --> <!-- If suggesting a new feature or change, please discuss it in an issue first. --> <!-- If fixing a bug, there should be an issue describing it with steps to reproduce. --> <!-- OSS: Please link to the issue here. Tyk: please create/link the JIRA ticket. --> ## Motivation and Context <!-- Why is this change required? What problem does it solve? --> ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## 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) - [x] 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. --> - [ ] I ensured that the documentation is up to date - [ ] 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 ___ ### **PR Type** Bug fix, Tests ___ ### **Description** - Fixes migration of disabled/empty uptime test fields to Tyk OAS. - Ensures empty uptime test fields are omitted in JSON serialization. - Updates service discovery cache logic for disabled state. - Adds and enhances tests for uptime test migration and serialization. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>upstream.go</strong><dd><code>Refactor uptime test and cache migration logic</code> </dd></summary> <hr> apidef/oas/upstream.go <li>Refactored uptime test migration to omit empty fields in JSON.<br> <li> Changed cache logic to set cache to nil if not enabled.<br> <li> Updated uptime test enabling logic to depend on test presence and <br>disabled flag.<br> <li> Ensured empty body is omitted from JSON output. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7069/files#diff-7b0941c7f37fe5a2a23047e0822a65519ca11c371660f36555b59a60f000e3f4">+6/-11</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>upstream_test.go</strong><dd><code>Add tests for uptime test migration and serialization</code> </dd></summary> <hr> apidef/oas/upstream_test.go <li>Added tests for empty uptime test migration and JSON serialization.<br> <li> Verified omission of empty body and protocol fields in JSON.<br> <li> Checked that Fill produces empty structure when no tests are present. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7069/files#diff-222cc254c0c6c09fa0cf50087860b837a0873e2aef3c84ec7d80b1014c149057">+44/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>fixtures_test.go</strong><dd><code>Assert migration errors in test fixtures</code> </dd></summary> <hr> apidef/oas/fixtures_test.go - Updated migration call to handle error and assert no error occurs. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7069/files#diff-2c27bf7208b7414ba0b07325bc834177a424d5348f2ffb4a78d46f428f8e303f">+2/-1</a> </td> </tr> <tr> <td> <details> <summary><strong>service_discovery.yml</strong><dd><code>Update service discovery fixture for disabled state</code> </dd></summary> <hr> apidef/oas/testdata/fixtures/service_discovery.yml - Updated expected output for disabled service discovery to be nil. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7069/files#diff-8a41102394fc3160d93fc56f1bcec9d1a03404724ba9e10dd624faf8e1154f65">+1/-5</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details> (cherry picked from commit 6495337)
API Changes --- prev.txt 2025-05-28 11:47:07.385699432 +0000
+++ current.txt 2025-05-28 11:47:02.580697071 +0000
@@ -4899,7 +4899,7 @@
// Timeout declares a timeout for the request. If the test exceeds
// this timeout, the check fails.
- Timeout time.ReadableDuration `bson:"timeout" json:"timeout"`
+ Timeout time.ReadableDuration `bson:"timeout" json:"timeout,omitempty"`
// Method allows you to customize the HTTP method for the test (`GET`, `POST`,...).
Method string `bson:"method" json:"method"`
@@ -4908,7 +4908,7 @@
Headers map[string]string `bson:"headers" json:"headers,omitempty"`
// Body is the body of the test request.
- Body string `bson:"body" json:"body"`
+ Body string `bson:"body" json:"body,omitempty"`
// Commands are used for TCP checks.
Commands []UptimeTestCommand `bson:"commands" json:"commands,omitempty"`
@@ -4947,11 +4947,11 @@
// HostDownRetestPeriod is the time to wait until rechecking a failed test.
// If undefined, the default testing interval (10s) is in use.
// Setting this to a lower value would result in quicker recovery on failed checks.
- HostDownRetestPeriod time.ReadableDuration `bson:"hostDownRetestPeriod" json:"hostDownRetestPeriod"`
+ HostDownRetestPeriod time.ReadableDuration `bson:"hostDownRetestPeriod" json:"hostDownRetestPeriod,omitempty"`
// LogRetentionPeriod holds a time to live for the uptime test results.
// If unset, a value of 100 years is the default.
- LogRetentionPeriod time.ReadableDuration `bson:"logRetentionPeriod" json:"logRetentionPeriod"`
+ LogRetentionPeriod time.ReadableDuration `bson:"logRetentionPeriod" json:"logRetentionPeriod,omitempty"`
}
UptimeTests configures uptime tests.
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
…fb595a4e4212e527cbf20
|
User description
Disabled/empty uptime test fields migrated to Tyk OAS (#7069)
User description
TT-14183
Chnage migration rules
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
functionality to change)
coverage to functionality)
Checklist
why it's required
explained why
PR Type
Bug fix, Tests
Description
Fixes migration of disabled/empty uptime test fields to Tyk OAS.
Ensures empty uptime test fields are omitted in JSON serialization.
Updates service discovery cache logic for disabled state.
Adds and enhances tests for uptime test migration and serialization.
Changes walkthrough 📝
upstream.go
Refactor uptime test and cache migration logic
apidef/oas/upstream.go
disabled flag.
upstream_test.go
Add tests for uptime test migration and serialization
apidef/oas/upstream_test.go
fixtures_test.go
Assert migration errors in test fixtures
apidef/oas/fixtures_test.go
service_discovery.yml
Update service discovery fixture for disabled state
apidef/oas/testdata/fixtures/service_discovery.yml
...
in the comments thread for any questions about PR-Agentusage.
for more information.
PR Type
Bug fix, Tests
Description
Fix migration to omit disabled/empty uptime test fields in Tyk OAS.
Ensure empty uptime test fields are omitted in JSON serialization.
Update service discovery cache logic for disabled state.
Add and enhance tests for uptime test migration and serialization.
Changes walkthrough 📝
upstream.go
Refactor uptime test and service discovery migration logic
apidef/oas/upstream.go
enabled.
disabled flag.
upstream_test.go
Add tests for uptime test migration and serialization
apidef/oas/upstream_test.go
fixtures_test.go
Assert migration errors in test fixtures
apidef/oas/fixtures_test.go
service_discovery.yml
Update service discovery fixture for disabled state
apidef/oas/testdata/fixtures/service_discovery.yml