-
Notifications
You must be signed in to change notification settings - Fork 337
Use Instant and log dropped FFE flags #11535
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
Open
leoromanovsky
wants to merge
7
commits into
master
Choose a base branch
from
leo.romanovsky/ffl-2339-instant-allocation-windows
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+64
−64
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7772a57
Skip malformed FFE flags during config parsing
leoromanovsky 2eaf305
Use Instant for FFE allocation windows
leoromanovsky d69f39b
Log dropped malformed FFE flags
leoromanovsky cb2e852
Merge remote-tracking branch 'origin/master' into leo.romanovsky/ffl-…
leoromanovsky d426669
Merge branch 'master' into leo.romanovsky/ffl-2339-instant-allocation…
leoromanovsky 67712dd
Clarify FFE instant parser test label
leoromanovsky e738c43
Merge branch 'master' into leo.romanovsky/ffl-2339-instant-allocation…
leoromanovsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...ure-flagging-bootstrap/src/main/java/datadog/trace/api/featureflag/ufc/v1/Allocation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,7 +25,6 @@ | |||||
| import datadog.trace.api.featureflag.FeatureFlaggingGateway; | ||||||
| import datadog.trace.api.featureflag.ufc.v1.ServerConfiguration; | ||||||
| import java.time.Instant; | ||||||
| import java.util.Date; | ||||||
| import org.junit.jupiter.api.AfterEach; | ||||||
| import org.junit.jupiter.api.Test; | ||||||
| import org.junit.jupiter.api.extension.ExtendWith; | ||||||
|
|
@@ -174,47 +173,49 @@ void skipsUnknownOperatorFlagAndKeepsValidFlag() throws Exception { | |||||
| } | ||||||
|
|
||||||
| @TableTest({ | ||||||
| "scenario | value | expectedEpochMilli", | ||||||
| "utc second | '2023-01-01T00:00:00Z' | 1672531200000 ", | ||||||
| "utc end of year | '2023-12-31T23:59:59Z' | 1704067199000 ", | ||||||
| "leap day | '2024-02-29T12:00:00Z' | 1709208000000 ", | ||||||
| "millisecond precision | '2023-01-01T00:00:00.000Z' | 1672531200000 ", | ||||||
| "three fractional digits | '2023-06-15T14:30:45.123Z' | 1686839445123 ", | ||||||
| "six fractional digits truncate to millis | '2023-06-15T14:30:45.123456Z' | 1686839445123 ", | ||||||
| "six fractional digits preserve millis | '2023-06-15T14:30:45.235982Z' | 1686839445235 ", | ||||||
| "nine fractional digits truncate to millis | '2023-06-15T14:30:45.123456789Z' | 1686839445123 ", | ||||||
| "one fractional digit | '2023-06-15T14:30:45.1Z' | 1686839445100 ", | ||||||
| "two fractional digits | '2023-06-15T14:30:45.12Z' | 1686839445120 ", | ||||||
| "positive offset | '2023-01-01T01:00:00+01:00' | 1672531200000 ", | ||||||
| "negative offset | '2023-01-01T00:00:00-05:00' | 1672549200000 ", | ||||||
| "date only | '2023-01-01' | ", | ||||||
| "invalid | 'invalid-date' | ", | ||||||
| "empty string | '' | ", | ||||||
| "not a date | 'not-a-date' | ", | ||||||
| "slash date | '2023/01/01T00:00:00Z' | ", | ||||||
| "null | | " | ||||||
| "scenario | value | expectedInstant ", | ||||||
| "utc second | '2023-01-01T00:00:00Z' | '2023-01-01T00:00:00Z' ", | ||||||
| "utc end of year | '2023-12-31T23:59:59Z' | '2023-12-31T23:59:59Z' ", | ||||||
| "leap day | '2024-02-29T12:00:00Z' | '2024-02-29T12:00:00Z' ", | ||||||
| "millisecond precision | '2023-01-01T00:00:00.000Z' | '2023-01-01T00:00:00Z' ", | ||||||
| "three fractional digits | '2023-06-15T14:30:45.123Z' | '2023-06-15T14:30:45.123Z' ", | ||||||
| "six fractional digits | '2023-06-15T14:30:45.123456Z' | '2023-06-15T14:30:45.123456Z' ", | ||||||
| "six fractional digits distinct | '2023-06-15T14:30:45.235982Z' | '2023-06-15T14:30:45.235982Z' ", | ||||||
| "nine fractional digits | '2023-06-15T14:30:45.123456789Z' | '2023-06-15T14:30:45.123456789Z'", | ||||||
| "one fractional digit | '2023-06-15T14:30:45.1Z' | '2023-06-15T14:30:45.100Z' ", | ||||||
| "two fractional digits | '2023-06-15T14:30:45.12Z' | '2023-06-15T14:30:45.120Z' ", | ||||||
| "positive offset | '2023-01-01T01:00:00+01:00' | '2023-01-01T00:00:00Z' ", | ||||||
| "negative offset | '2023-01-01T00:00:00-05:00' | '2023-01-01T05:00:00Z' ", | ||||||
| "date only | '2023-01-01' | ", | ||||||
| "invalid | 'invalid-date' | ", | ||||||
| "empty string | '' | ", | ||||||
| "not a date | 'not-a-date' | ", | ||||||
| "slash date | '2023/01/01T00:00:00Z' | ", | ||||||
| "null | | " | ||||||
| }) | ||||||
| void testDateParsing(final String value, final Long expectedEpochMilli) throws Exception { | ||||||
| void testInstantParsing(final String value, final String expectedInstant) throws Exception { | ||||||
| final JsonReader reader = mock(JsonReader.class); | ||||||
| when(reader.nextString()).thenReturn(value); | ||||||
| final RemoteConfigServiceImpl.DateAdapter adapter = new RemoteConfigServiceImpl.DateAdapter(); | ||||||
| final RemoteConfigServiceImpl.InstantAdapter adapter = | ||||||
| new RemoteConfigServiceImpl.InstantAdapter(); | ||||||
|
|
||||||
| final Date parsed = adapter.fromJson(reader); | ||||||
| if (expectedEpochMilli == null) { | ||||||
| final Instant parsed = adapter.fromJson(reader); | ||||||
| if (expectedInstant == null) { | ||||||
| assertNull(parsed); | ||||||
| } else { | ||||||
| assertNotNull(parsed); | ||||||
| assertEquals(Instant.ofEpochMilli(expectedEpochMilli), parsed.toInstant()); | ||||||
| assertEquals(Instant.parse(expectedInstant), parsed); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: There's also a Another option could be change the assertion to compare the value directly rather than parsing the expected value as well, e.g. in pseudo code
Suggested change
This assertion could also work using |
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| @Test | ||||||
| void testParsingOnlyAdapter() { | ||||||
| final RemoteConfigServiceImpl.DateAdapter adapter = new RemoteConfigServiceImpl.DateAdapter(); | ||||||
| final RemoteConfigServiceImpl.InstantAdapter adapter = | ||||||
| new RemoteConfigServiceImpl.InstantAdapter(); | ||||||
|
|
||||||
| assertThrows( | ||||||
| UnsupportedOperationException.class, | ||||||
| () -> adapter.toJson(mock(JsonWriter.class), new Date())); | ||||||
| () -> adapter.toJson(mock(JsonWriter.class), Instant.EPOCH)); | ||||||
| } | ||||||
|
|
||||||
| @SuppressWarnings("unchecked") | ||||||
|
|
||||||
Oops, something went wrong.
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.
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.
nitpick: I think
parseInstantcan be inlined asInstant.parse(value)is short enough.