-
Notifications
You must be signed in to change notification settings - Fork 17
CWMS-2024: New LRTS identifier support #1126
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
base: develop
Are you sure you want to change the base?
Conversation
@@ -267,6 +265,7 @@ public class ApiServlet extends HttpServlet { | |||
public static final String DATA_SOURCE = "data_source"; | |||
public static final String RAW_DATA_SOURCE = "data_source"; | |||
public static final String DATABASE = "database"; | |||
public static final String IS_NEW_LRTS = "X-NEW_LRTS"; |
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.
X-CWMS-LRTS-Formatting
or something like that, but at a minimum: X-CWMS-...
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.
I'd argue that we don't want LRTS
as we're talking about the interval, so something like X-CWMS-Use-LocalRegularInterval
. But then again maybe client usage will only be thinking in context of time series so LRTS is clearer. Thoughts?
.when() | ||
.redirects().follow(true) | ||
.redirects().max(3) | ||
.delete("/timeseries/identifier-descriptor/" + tsId) |
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.
.delete("/timeseries/identifier-descriptor/" + tsId) | |
.delete("/timeseries/identifier-descriptor/{tsID}", tsId) |
There's a minor improvement in the log output when using this form. Also makes it easier to look at when there's more than one parameter.
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.
Adjusted path format as suggested.
@@ -68,7 +68,7 @@ static void beforeAll() throws Exception | |||
String ratingXml = readResourceFile("cwms/cda/api/Zanesville_Stage_Flow_COE_Production.xml"); | |||
ratingXml = ratingXml.replaceAll("Zanesville", EXISTING_LOC); | |||
String ratingXml2 = ratingXml.replaceAll("2002-04-09T13:53:01Z", "2016-06-06T00:00:00Z"); | |||
String ratingXml3 = ratingXml.replaceAll("2002-04-09T13:53:01Z", "2025-06-06T00:00:00Z"); | |||
String ratingXml3 = ratingXml.replaceAll("2002-04-09T13:53:01Z", "2065-06-06T00:00:00Z"); |
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.
Let's put this in a separate PR. You're already going to have to update several otherwise complete branches.... and I have one that needs it as well.
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.
#1149 Created a PR here
The current endpoints that return the legacy LRTS interval identifier despite the database being set to use the new format are:
This will be updated if more problematic endpoints are discovered. An issue has been created for cwms-database, and is visible here: HydrologicEngineeringCenter/cwms-database#24 |
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.
Integration tests should test both new and old format and assert that the returned identifier/name matches the request old/new format.
If the client passes in the new identifier without the requisite header, that should be a client error 400, not an internal server error 500.
.then() | ||
.log().ifValidationFails(LogDetail.ALL,true) | ||
.assertThat() | ||
.statusCode(is(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); |
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.
Should be a client error
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.
Added error checking and regex matching, now throws CONFLICT client error.
|
||
// Structure of test: | ||
// | ||
// 1)Try to create the binary time series without LRTS |
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.
// 1)Try to create the binary time series without LRTS | |
// 1)Try to create the binary time series using new LRTS format without the new LRTS format header |
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.
Updated comment as suggested
.queryParam(Controllers.NAME, tsIdentifier) | ||
.queryParam(Controllers.BEGIN, "2004-05-01T12:00:00Z") | ||
.queryParam(Controllers.END, "2007-05-19T16:00:00Z") | ||
.header(ApiServlet.IS_NEW_LRTS, true) |
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.
Add a test right after this that tests without the new header to assert that the old interval id is returned
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.
Added test to confirm old interval ID is returned
.log().ifValidationFails(LogDetail.ALL,true) | ||
.assertThat() | ||
.statusCode(is(HttpServletResponse.SC_OK)) | ||
.body("binary-values.size()", equalTo(3)) |
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.
Need to test that the new identifier is returned to the client as part of the name
.
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.
Added check for name value
org.jooq.Configuration configuration = DSL.using(c).configuration(); | ||
CWMS_UTIL_PACKAGE.call_SET_SESSION_INFO(configuration, | ||
SESSION_USE_LRTS_ID_FORMAT, requireBool, requireIntValue); | ||
try(PreparedStatement stmt = c.prepareStatement(createTimeseriesQuery)) { |
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 query does not distinguish between PRTS and LRTS using the old identifier
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.
Refactored method to only be used for new interval identifier. Should an alternative query specifying LRTS vs PRTS be used here?
…upport # Conflicts: # cwms-data-api/src/test/java/cwms/cda/api/TimeseriesControllerTestIT.java
CWMS-2024: New LRTS identifier support through header and integration testing