-
Notifications
You must be signed in to change notification settings - Fork 340
Migrate feature-flagging groovy tests to java #11716
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
Merged
gh-worker-dd-mergequeue-cf854d
merged 14 commits into
master
from
sarahchen6/migrate-feature-flagging-tests-to-java
Jun 26, 2026
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3a78887
Migrate feature-flagging groovy tests to java
sarahchen6 a3b2ee7
Address flaky test
sarahchen6 f8a8e04
Merge branch 'master' into sarahchen6/migrate-feature-flagging-tests-…
sarahchen6 cdb382b
Merge branch 'master' into sarahchen6/migrate-feature-flagging-tests-…
sarahchen6 b5345af
Merge branch 'master' into sarahchen6/migrate-feature-flagging-tests-…
sarahchen6 6c9c1f2
Clean up pt1
sarahchen6 9a511ee
Clean up pt2
sarahchen6 5439d23
Clean up pt3
sarahchen6 93e94dc
Clean up pt4
sarahchen6 3eea11d
Wait for flush in both cases of testFailuresAreRetried
sarahchen6 ebbebf7
Add VisibleForTesting annotation
sarahchen6 1b43b4b
Merge branch 'master' into sarahchen6/migrate-feature-flagging-tests-…
sarahchen6 0ba57de
Merge branch 'master' into sarahchen6/migrate-feature-flagging-tests-…
sarahchen6 c06b654
Update to use test-utils polling
sarahchen6 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
60 changes: 0 additions & 60 deletions
60
...e-flagging-agent/src/test/groovy/com/datadog/featureflag/FeatureFlaggingSystemTest.groovy
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
...ature-flagging-agent/src/test/java/com/datadog/featureflag/FeatureFlaggingSystemTest.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package com.datadog.featureflag; | ||
|
|
||
| import static datadog.trace.api.config.RemoteConfigConfig.REMOTE_CONFIGURATION_ENABLED; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.ArgumentMatchers.eq; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.verify; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import datadog.communication.ddagent.DDAgentFeaturesDiscovery; | ||
| import datadog.communication.ddagent.SharedCommunicationObjects; | ||
| import datadog.remoteconfig.Capabilities; | ||
| import datadog.remoteconfig.ConfigurationDeserializer; | ||
| import datadog.remoteconfig.ConfigurationPoller; | ||
| import datadog.remoteconfig.Product; | ||
| import datadog.trace.api.Config; | ||
| import datadog.trace.junit.utils.config.WithConfig; | ||
| import okhttp3.HttpUrl; | ||
| import okhttp3.OkHttpClient; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class FeatureFlaggingSystemTest { | ||
|
|
||
| @AfterEach | ||
| void stopFeatureFlaggingSystem() { | ||
| FeatureFlaggingSystem.stop(); | ||
| } | ||
|
|
||
| @Test | ||
| void testFeatureFlagSystemInitialization() { | ||
| ConfigurationPoller poller = mock(ConfigurationPoller.class); | ||
| DDAgentFeaturesDiscovery discovery = mock(DDAgentFeaturesDiscovery.class); | ||
| SharedCommunicationObjects sharedCommunicationObjects = mock(SharedCommunicationObjects.class); | ||
| when(discovery.supportsEvpProxy()).thenReturn(true); | ||
| when(discovery.getEvpProxyEndpoint()).thenReturn("/evp_proxy/"); | ||
| when(sharedCommunicationObjects.configurationPoller(any(Config.class))).thenReturn(poller); | ||
| when(sharedCommunicationObjects.featuresDiscovery(any(Config.class))).thenReturn(discovery); | ||
| sharedCommunicationObjects.agentUrl = HttpUrl.get("http://localhost"); | ||
| sharedCommunicationObjects.agentHttpClient = new OkHttpClient.Builder().build(); | ||
|
|
||
| FeatureFlaggingSystem.start(sharedCommunicationObjects); | ||
|
|
||
| verify(poller).addCapabilities(Capabilities.CAPABILITY_FFE_FLAG_CONFIGURATION_RULES); | ||
| verify(poller).addListener(eq(Product.FFE_FLAGS), any(ConfigurationDeserializer.class), any()); | ||
| verify(poller).start(); | ||
|
|
||
| FeatureFlaggingSystem.stop(); | ||
|
|
||
| verify(poller).removeCapabilities(Capabilities.CAPABILITY_FFE_FLAG_CONFIGURATION_RULES); | ||
| verify(poller).removeListeners(Product.FFE_FLAGS); | ||
| verify(poller).stop(); | ||
| } | ||
|
|
||
| @Test | ||
| @WithConfig(key = REMOTE_CONFIGURATION_ENABLED, value = "false") | ||
| void testThatRemoteConfigIsRequired() { | ||
| SharedCommunicationObjects sharedCommunicationObjects = mock(SharedCommunicationObjects.class); | ||
|
|
||
| assertThrows( | ||
| IllegalStateException.class, () -> FeatureFlaggingSystem.start(sharedCommunicationObjects)); | ||
| } | ||
| } | ||
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
76 changes: 0 additions & 76 deletions
76
...bootstrap/src/test/groovy/datadog/trace/api/featureflag/FeatureFlaggingGatewayTest.groovy
This file was deleted.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
...ing-bootstrap/src/test/java/datadog/trace/api/featureflag/FeatureFlaggingGatewayTest.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package datadog.trace.api.featureflag; | ||
|
|
||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.verify; | ||
| import static org.mockito.Mockito.verifyNoMoreInteractions; | ||
|
|
||
| import datadog.trace.api.featureflag.exposure.ExposureEvent; | ||
| import datadog.trace.api.featureflag.ufc.v1.ServerConfiguration; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class FeatureFlaggingGatewayTest { | ||
|
|
||
| @BeforeEach | ||
| @AfterEach | ||
| void resetCurrentConfiguration() { | ||
| FeatureFlaggingGateway.dispatch((ServerConfiguration) null); | ||
| } | ||
|
sarahchen6 marked this conversation as resolved.
Outdated
|
||
|
|
||
| @Test | ||
| void testAttachingAConfigListener() { | ||
| FeatureFlaggingGateway.ConfigListener listener = | ||
| mock(FeatureFlaggingGateway.ConfigListener.class); | ||
| ServerConfiguration first = mock(ServerConfiguration.class); | ||
| ServerConfiguration second = mock(ServerConfiguration.class); | ||
|
sarahchen6 marked this conversation as resolved.
Outdated
|
||
|
|
||
| try { | ||
| FeatureFlaggingGateway.addConfigListener(listener); | ||
| FeatureFlaggingGateway.dispatch(first); | ||
|
|
||
| verify(listener).accept(first); | ||
| verifyNoMoreInteractions(listener); | ||
|
|
||
| FeatureFlaggingGateway.dispatch(second); | ||
|
|
||
| verify(listener).accept(second); | ||
| verifyNoMoreInteractions(listener); | ||
| } finally { | ||
| FeatureFlaggingGateway.removeConfigListener(listener); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void testAttachingAListenerAfterConfigured() { | ||
| FeatureFlaggingGateway.ConfigListener listener = | ||
| mock(FeatureFlaggingGateway.ConfigListener.class); | ||
| ServerConfiguration first = mock(ServerConfiguration.class); | ||
|
|
||
| try { | ||
| FeatureFlaggingGateway.dispatch(first); | ||
| FeatureFlaggingGateway.addConfigListener(listener); | ||
|
|
||
| verify(listener).accept(first); | ||
| verifyNoMoreInteractions(listener); | ||
| } finally { | ||
| FeatureFlaggingGateway.removeConfigListener(listener); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void testAttachingAnExposureListener() { | ||
| FeatureFlaggingGateway.ExposureListener listener = | ||
| mock(FeatureFlaggingGateway.ExposureListener.class); | ||
| ExposureEvent first = mock(ExposureEvent.class); | ||
| ExposureEvent second = mock(ExposureEvent.class); | ||
|
|
||
| try { | ||
| FeatureFlaggingGateway.addExposureListener(listener); | ||
| FeatureFlaggingGateway.dispatch(first); | ||
|
|
||
| verify(listener).accept(first); | ||
| verifyNoMoreInteractions(listener); | ||
|
|
||
| FeatureFlaggingGateway.dispatch(second); | ||
|
|
||
| verify(listener).accept(second); | ||
| verifyNoMoreInteractions(listener); | ||
| } finally { | ||
| FeatureFlaggingGateway.removeExposureListener(listener); | ||
| } | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.