[V4] Adjustments to fix failing DateTimes asserts in tests due to local/UTC inconsistencies. #3601
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When running tests locally the following tests were found to be failing:
These were not caught running dry-run on the server previously because the server was set to +0 timezone offset (UTC) so local and UTC times were effectively the same.
TestDateTimeDeserializationWithDdbContext
This was caused from our intended breaking change of
DynamoDB RetrieveDateTimeInUtc has been switched to true as the default.
. Because the dates were being returning in UTC and the input dates were being passed as local the assert comparisons were failing. Required a test update.TestParsingResponse_200Result
Required adding back in the
.ToUniversalTime()
removed from a recent PR (#3541). Public properties such as Expiration should be UTC but there is no guarantee they will be if they can be publicly set. The.ToUniversalTime()
defensive call has been added back in.StaticStabilityWhenIMDSExperiencesAnOutageScenarioTest
Required adding back of
.ToUniversalTime()
and in addition adjustments toEC2InstanceMetadataServlet
for invalid mocked responses. The code was using JsonMapper.ToJson(from an object containing a UTC datetime) but because of the default datetime export handling in the mapper mocked IMDS service was setting the expiration as a datetime string without theZ
even though it was a UTC expiration datetime. This cause the response parser to assume it was an unspecified datetime which then got double converted to UTC with the reintroduced.ToUniversalTime()
call.Added in code to override the datetime export handling for
EC2InstanceMetadataServlet
to return the properly formatted datetime strings with aZ
.Motivation and Context
Testing
dry-run: DRY_RUN-ed208a00-5381-46b7-a858-ad97c0247863 (Succeeded)
Screenshots (if appropriate)
Types of changes
Checklist
License