Skip to content

Commit 135fcbd

Browse files
Fix smoke tests
1 parent a216a21 commit 135fcbd

File tree

9 files changed

+28
-6
lines changed

9 files changed

+28
-6
lines changed

dd-java-agent/agent-featureflag/src/main/java/com/datadog/featureflag/FeatureFlagSystem.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.datadog.featureflag;
22

3+
import datadog.communication.ddagent.DDAgentFeaturesDiscovery;
34
import datadog.communication.ddagent.SharedCommunicationObjects;
45
import datadog.remoteconfig.ConfigurationPoller;
56
import datadog.trace.api.Config;
@@ -25,8 +26,13 @@ public static void start(final SharedCommunicationObjects sco) {
2526
"Feature flags evaluation won't be started, remote config is likely disabled");
2627
}
2728

28-
EXPOSURE_WRITER = new ExposureWriterImpl(sco.agentUrl, config);
29-
EXPOSURE_WRITER.init();
29+
final DDAgentFeaturesDiscovery features = sco.featuresDiscovery(config);
30+
if (features.supportsEvpProxy()) {
31+
EXPOSURE_WRITER = new ExposureWriterImpl(sco.agentUrl, config);
32+
EXPOSURE_WRITER.init();
33+
} else {
34+
LOGGER.debug("Feature Flag exposures won't be submitted");
35+
}
3036

3137
CONFIG_SERVICE = new FeatureFlagRemoteConfigServiceImpl(poller);
3238
CONFIG_SERVICE.init();
@@ -35,8 +41,14 @@ public static void start(final SharedCommunicationObjects sco) {
3541
}
3642

3743
public static void stop() {
38-
EXPOSURE_WRITER.close();
39-
CONFIG_SERVICE.close();
44+
if (EXPOSURE_WRITER != null) {
45+
EXPOSURE_WRITER.close();
46+
EXPOSURE_WRITER = null;
47+
}
48+
if (CONFIG_SERVICE != null) {
49+
CONFIG_SERVICE.close();
50+
CONFIG_SERVICE = null;
51+
}
4052
LOGGER.debug("Feature Flag system stopped");
4153
}
4254
}

dd-java-agent/agent-featureflag/src/test/groovy/com/datadog/featureflag/FeatureFlagSystemTest.groovy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.datadog.featureflag
22

3+
import datadog.communication.ddagent.DDAgentFeaturesDiscovery
34
import datadog.communication.ddagent.SharedCommunicationObjects
45
import datadog.remoteconfig.Capabilities
56
import datadog.remoteconfig.ConfigurationDeserializer
@@ -15,12 +16,15 @@ class FeatureFlagSystemTest extends DDSpecification {
1516
setup:
1617
final poller = Mock(ConfigurationPoller)
1718
final sco = Mock(SharedCommunicationObjects)
19+
final featuresDiscovery = Mock(DDAgentFeaturesDiscovery)
1820
sco.agentUrl = HttpUrl.get('http://localhost')
1921

2022
when:
2123
FeatureFlagSystem.start(sco)
2224

2325
then:
26+
1 * sco.featuresDiscovery(_ as Config) >> featuresDiscovery
27+
1 * featuresDiscovery.supportsEvpProxy() >> evpProxy
2428
1 * sco.configurationPoller(_ as Config) >> { poller }
2529
1 * poller.addCapabilities(Capabilities.CAPABILITY_FFE_FLAG_CONFIGURATION_RULES)
2630
1 * poller.addListener(Product.FFE_FLAGS, _ as ConfigurationDeserializer, _)
@@ -34,6 +38,9 @@ class FeatureFlagSystemTest extends DDSpecification {
3438
1 * poller.removeCapabilities(Capabilities.CAPABILITY_FFE_FLAG_CONFIGURATION_RULES)
3539
1 * poller.stop()
3640
0 * _
41+
42+
where:
43+
evpProxy << [true, false]
3744
}
3845

3946
void 'test that a poller is required'() {
@@ -48,5 +55,8 @@ class FeatureFlagSystemTest extends DDSpecification {
4855

4956
then:
5057
thrown(IllegalStateException)
58+
59+
cleanup:
60+
FeatureFlagSystem.stop()
5161
}
5262
}

dd-smoke-tests/openfeature/build.gradle renamed to dd-smoke-tests/featureflag/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tasks.named("compileJava", JavaCompile) {
2121
dependencies {
2222
implementation project(':products:openfeature')
2323
implementation 'org.springframework.boot:spring-boot-starter-web'
24+
2425
testImplementation project(':dd-smoke-tests')
2526
}
2627

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class OpenFeatureProviderSmokeTest extends AbstractServerSmokeTest {
2121

2222
final springBootShadowJar = System.getProperty("datadog.smoketest.springboot.shadowJar.path")
2323
final command = [javaPath()]
24-
command.add('-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005')
2524
command.addAll(defaultJavaProperties)
2625
command.add('-Ddd.trace.debug=true')
2726
command.add('-Ddd.remote_config.enabled=true')

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ include(
172172
":dd-smoke-tests:crashtracking",
173173
":dd-smoke-tests:custom-systemloader",
174174
":dd-smoke-tests:dynamic-config",
175+
":dd-smoke-tests:featureflag",
175176
":dd-smoke-tests:field-injection",
176177
":dd-smoke-tests:gradle",
177178
":dd-smoke-tests:grpc-1.5",
@@ -185,7 +186,6 @@ include(
185186
":dd-smoke-tests:lib-injection",
186187
":dd-smoke-tests:log-injection",
187188
":dd-smoke-tests:maven",
188-
":dd-smoke-tests:openfeature",
189189
":dd-smoke-tests:opentracing",
190190
":dd-smoke-tests:opentelemetry",
191191
":dd-smoke-tests:osgi",

0 commit comments

Comments
 (0)