Skip to content

Commit c84c0de

Browse files
committed
test(flagd): use newest testbed launchpad
Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
1 parent b4fe2f4 commit c84c0de

File tree

13 files changed

+76
-152
lines changed

13 files changed

+76
-152
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[submodule "providers/flagd/test-harness"]
55
path = providers/flagd/test-harness
66
url = https://github.com/open-feature/test-harness.git
7-
branch = v1.1.1
7+
branch = v1.3.2
88
[submodule "providers/flagd/spec"]
99
path = providers/flagd/spec
1010
url = https://github.com/open-feature/spec.git

providers/flagd/pom.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,13 @@
150150
<scope>test</scope>
151151
</dependency>
152152
<dependency>
153-
<groupId>org.testcontainers</groupId>
154-
<artifactId>toxiproxy</artifactId>
155-
<version>1.20.4</version>
153+
<groupId>io.rest-assured</groupId>
154+
<artifactId>rest-assured</artifactId>
155+
<version>5.5.0</version>
156156
<scope>test</scope>
157157
</dependency>
158158
<!-- uncomment for logoutput during test runs -->
159-
160-
<dependency>
159+
<dependency>
161160
<groupId>org.slf4j</groupId>
162161
<artifactId>slf4j-simple</artifactId>
163162
<version>2.0.16</version>
@@ -254,7 +253,7 @@
254253
<configuration>
255254
<protocArtifact>com.google.protobuf:protoc:3.25.5:exe:${os.detected.classifier}</protocArtifact>
256255
<pluginId>grpc-java</pluginId>
257-
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.68.2:exe:${os.detected.classifier}</pluginArtifact>
256+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.69.1:exe:${os.detected.classifier}</pluginArtifact>
258257
<protoSourceRoot>${project.basedir}/schemas/protobuf/</protoSourceRoot>
259258
</configuration>
260259
<executions>

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/storage/connector/grpc/GrpcStreamConnector.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ void observeEventStream(final BlockingQueue<QueuePayload> writeTo, final AtomicB
118118
metadataException = e;
119119
}
120120

121-
log.info("stream");
122121
while (!shutdown.get()) {
123122
final GrpcResponseModel response = streamReceiver.take();
124123
if (response.isComplete()) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dev.openfeature.contrib.providers.flagd.e2e;
1+
package dev.openfeature.contrib.providers.flagd;
22

33
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;
44
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;
@@ -18,5 +18,5 @@
1818
@IncludeEngines("cucumber")
1919
@SelectFile("test-harness/gherkin/config.feature")
2020
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty")
21-
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.contrib.providers.flagd.e2e.steps")
22-
public class RunConfigCucumberTest {}
21+
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.contrib.providers.flagd.e2e.steps.config")
22+
public class ConfigCucumberTest {}

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/FlagdContainer.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package dev.openfeature.contrib.providers.flagd.e2e;
22

3+
import dev.openfeature.contrib.providers.flagd.Config;
34
import java.io.File;
45
import java.nio.file.Files;
56
import java.util.List;
6-
import org.apache.logging.log4j.util.Strings;
77
import org.jetbrains.annotations.NotNull;
88
import org.testcontainers.containers.GenericContainer;
99
import org.testcontainers.containers.Network;
@@ -28,16 +28,25 @@ public class FlagdContainer extends GenericContainer<FlagdContainer> {
2828
private String feature;
2929

3030
public FlagdContainer() {
31-
this("");
31+
super(generateContainerName());
32+
this.feature = feature;
33+
this.addExposedPorts(8013, 8014, 8015, 8080);
3234
}
3335

34-
public FlagdContainer(String feature) {
35-
super(generateContainerName(feature));
36-
this.withReuse(true);
37-
this.feature = feature;
38-
if (!"socket".equals(this.feature)) this.addExposedPorts(8013, 8014, 8015, 8016);
36+
public int getPort(Config.Resolver resolver) {
37+
switch (resolver) {
38+
case RPC:
39+
return getMappedPort(8013);
40+
case IN_PROCESS:
41+
return getMappedPort(8015);
42+
default:
43+
return 0;
44+
}
3945
}
4046

47+
public String getLaunchpadUrl() {
48+
return this.getHost() + ":" + this.getMappedPort(8080);
49+
}
4150
/**
4251
* @return a {@link org.testcontainers.containers.GenericContainer} instance of envoy container using
4352
* flagd sync service as backend expose on port 9211
@@ -52,11 +61,8 @@ public static GenericContainer envoy() {
5261
.withNetworkAliases("envoy");
5362
}
5463

55-
public static @NotNull String generateContainerName(String feature) {
64+
public static @NotNull String generateContainerName() {
5665
String container = "ghcr.io/open-feature/flagd-testbed";
57-
if (!Strings.isBlank(feature)) {
58-
container += "-" + feature;
59-
}
6066
container += ":v" + version;
6167
return container;
6268
}

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/AbstractSteps.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import dev.openfeature.contrib.providers.flagd.e2e.State;
44

5-
abstract class AbstractSteps {
6-
State state;
5+
public abstract class AbstractSteps {
6+
protected State state;
77

8-
public AbstractSteps(State state) {
8+
protected AbstractSteps(State state) {
99
this.state = state;
1010
}
1111
}

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/EnvironmentVariableUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* This class modifies the internals of the environment variables map with reflection. Warning: If
1515
* your {@link SecurityManager} does not allow modifications, it fails.
1616
*/
17-
class EnvironmentVariableUtils {
17+
public class EnvironmentVariableUtils {
1818

1919
private EnvironmentVariableUtils() {
2020
// private constructor to prevent instantiation of utility class

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/EventSteps.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ public void a_stale_event_handler(String eventType) {
4747

4848
@When("a {} event was fired")
4949
public void eventWasFired(String eventType) throws InterruptedException {
50-
eventHandlerShouldBeExecutedWithin(eventType, 10000);
51-
// we might be too fast in the execution
52-
Thread.sleep(500);
50+
eventHandlerShouldBeExecutedWithin(eventType, 8000);
5351
}
5452

5553
@Then("the {} event handler should have been executed")
5654
public void eventHandlerShouldBeExecuted(String eventType) {
57-
eventHandlerShouldBeExecutedWithin(eventType, 30000);
55+
eventHandlerShouldBeExecutedWithin(eventType, 10000);
5856
}
5957

6058
@Then("the {} event handler should have been executed within {int}ms")

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/FlagSteps.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package dev.openfeature.contrib.providers.flagd.e2e.steps;
22

3-
import static java.util.concurrent.TimeUnit.MILLISECONDS;
43
import static org.assertj.core.api.Assertions.assertThat;
5-
import static org.awaitility.Awaitility.await;
64

75
import dev.openfeature.contrib.providers.flagd.e2e.State;
86
import dev.openfeature.sdk.FlagEvaluationDetails;
@@ -70,15 +68,9 @@ public void the_variant_should_be(String variant) {
7068
}
7169

7270
@Then("the flag should be part of the event payload")
73-
@Then("the flag was modified")
7471
public void the_flag_was_modified() {
75-
await().atMost(5000, MILLISECONDS).until(() -> state.events.stream()
76-
.anyMatch(event -> event.type.equals("change")
77-
&& event.details.getFlagsChanged().contains(state.flag.name)));
78-
state.lastEvent = state.events.stream()
79-
.filter(event -> event.type.equals("change")
80-
&& event.details.getFlagsChanged().contains(state.flag.name))
81-
.findFirst();
72+
Event event = state.lastEvent.orElseThrow(AssertionError::new);
73+
assertThat(event.details.getFlagsChanged()).contains(state.flag.name);
8274
}
8375

8476
public class Flag {

0 commit comments

Comments
 (0)