-
Notifications
You must be signed in to change notification settings - Fork 351
Fixed TO API /servers/{id}/deliveryservices endpoint to respond with all DS's on cache that are directly assigned and inherited through topology. #7520
Conversation
4ce1bf5 to
6a7e0aa
Compare
Codecov Report
@@ Coverage Diff @@
## master #7520 +/- ##
============================================
- Coverage 33.31% 30.44% -2.88%
Complexity 98 98
============================================
Files 499 792 +293
Lines 50832 82868 +32036
Branches 851 885 +34
============================================
+ Hits 16937 25227 +8290
- Misses 32655 55527 +22872
- Partials 1240 2114 +874
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 306 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
a5dd2bc to
bdd96b1
Compare
zrhoffman
left a comment
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.
Looks good, thanks!
zrhoffman
left a comment
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.
The V3 Delivery Service API tests fail:
--- FAIL: TestServersIDDeliveryServices (6.62s)
--- FAIL: TestServersIDDeliveryServices/POST (0.13s)
--- FAIL: TestServersIDDeliveryServices/POST/OK_when_VALID_request (0.03s)
servers_id_deliveryservices_test.go:167: Not equal. Expected: 1 Actual: 2 Messages: Expected one Delivery Service returned Got: 2
--- FAIL: TestServersIDDeliveryServices/POST/OK_when_ASSIGNING_ORIGIN_to_TOPOLOGY_BASED_DELIVERY_SERVICE (0.03s)
servers_id_deliveryservices_test.go:167: Not equal. Expected: 1 Actual: 3 Messages: Expected one Delivery Service returned Got: 3
FAIL
Also, this PR needs to be rebased onto the master branch to get #7546, which will make CDN in a Box work again
|
Fixed V3 Integration tests that were failing. |
| } | ||
| where += "ds.id in (SELECT deliveryService FROM deliveryservice_server where server = :server)" | ||
|
|
||
| where += "ds.id in (SELECT deliveryService FROM deliveryservice_server WHERE server = :server) OR ds.id in (SELECT id FROM deliveryservice WHERE topology in ( SELECT topology FROM topology_cachegroup WHERE cachegroup = ( SELECT name FROM cachegroup WHERE id = ( SELECT cachegroup FROM server WHERE id = :server ))))" |
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.
In general, accomplishing this with JOINs for the
WHERE topology in ( SELECT topology FROM topology_cachegroup WHERE cachegroup = ( SELECT name FROM cachegroup WHERE id = ( SELECT cachegroup FROM server WHERE id = :server )))instead of subqueries would be possible, but there is probably not a performance difference, so keeping this structure is fine.
| } | ||
| where += "ds.id in (SELECT deliveryService FROM deliveryservice_server where server = :server)" | ||
|
|
||
| where += "ds.id in (SELECT deliveryService FROM deliveryservice_server WHERE server = :server) OR ds.id in (SELECT id FROM deliveryservice WHERE topology in ( SELECT topology FROM topology_cachegroup WHERE cachegroup = ( SELECT name FROM cachegroup WHERE id = ( SELECT cachegroup FROM server WHERE id = :server ))))" |
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.
This is a long line for a query fragment. How about reformatting it as a multiline string like this?
where += `
ds.id in (
SELECT deliveryService FROM deliveryservice_server WHERE server = :server
) OR ds.id in (
SELECT id FROM deliveryservice
WHERE topology in (
SELECT topology FROM topology_cachegroup
WHERE cachegroup = (
SELECT name FROM cachegroup
WHERE id = (
SELECT cachegroup FROM server WHERE id = :server
))))
`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.
Fixed It. Thanks
| ds.id in ( | ||
| SELECT deliveryService FROM deliveryservice_server WHERE server = :server | ||
| ) OR ds.id in ( | ||
| SELECT id FROM deliveryservice | ||
| WHERE topology in ( | ||
| SELECT topology FROM topology_cachegroup | ||
| WHERE cachegroup = ( | ||
| SELECT name FROM cachegroup | ||
| WHERE id = ( | ||
| SELECT cachegroup FROM server WHERE id = :server | ||
| )))) |
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.
Queries should not be indented like the rest of the function, because if you look at the complete, assembled query that Traffic Ops logs, that indentation does not make sense.
So, the query fragment should be unindented by 2 tabs.
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.
Fixed it.
zrhoffman
left a comment
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.
Looks good, thanks! I'll merge when the GHAs pass.
Closes: #7519
Which Traffic Control components are affected by this PR?
What is the best way to verify this PR?
Get request to Traffic Ops API /servers/{id}/deliveryservices endpoint should provide both DS that are directly assigned and that are inherited from the topology.
If this is a bugfix, which Traffic Control versions contained the bug?
PR submission checklist