2
2
3
3
import static io .restassured .RestAssured .when ;
4
4
5
- import com .fasterxml .jackson .databind .ObjectMapper ;
6
- import com .fasterxml .jackson .databind .ObjectReader ;
7
5
import dev .openfeature .contrib .providers .flagd .Config ;
8
6
import dev .openfeature .contrib .providers .flagd .FlagdProvider ;
9
7
import dev .openfeature .contrib .providers .flagd .e2e .FlagdContainer ;
21
19
import java .nio .file .Files ;
22
20
import java .nio .file .Path ;
23
21
import java .nio .file .Paths ;
24
- import java .util .Objects ;
25
22
import lombok .extern .slf4j .Slf4j ;
26
23
import org .apache .commons .lang3 .RandomStringUtils ;
27
24
import org .junit .jupiter .api .parallel .Isolated ;
@@ -47,7 +44,7 @@ public static void beforeAll() throws IOException {
47
44
sharedTempDir = Files .createDirectories (
48
45
Paths .get ("tmp/" + RandomStringUtils .randomAlphanumeric (8 ).toLowerCase () + "/" ));
49
46
container = new FlagdContainer ()
50
- .withFileSystemBind (sharedTempDir .toAbsolutePath ().toString (), "/tmp " , BindMode .READ_WRITE );
47
+ .withFileSystemBind (sharedTempDir .toAbsolutePath ().toString (), "/flags " , BindMode .READ_WRITE );
51
48
}
52
49
53
50
@ AfterAll
@@ -78,15 +75,7 @@ public void setupProvider(String providerType) throws IOException, InterruptedEx
78
75
String flagdConfig = "default" ;
79
76
state .builder .deadline (1000 ).keepAlive (0 ).retryGracePeriod (2 );
80
77
boolean wait = true ;
81
- File flags = new File ("test-harness/flags" );
82
- ObjectMapper objectMapper = new ObjectMapper ();
83
- Object merged = new Object ();
84
- for (File listFile : Objects .requireNonNull (flags .listFiles ())) {
85
- ObjectReader updater = objectMapper .readerForUpdating (merged );
86
- merged = updater .readValue (listFile , Object .class );
87
- }
88
- Path offlinePath = Files .createTempFile ("flags" , ".json" );
89
- objectMapper .writeValue (offlinePath .toFile (), merged );
78
+
90
79
switch (providerType ) {
91
80
case "unavailable" :
92
81
this .state .providerType = ProviderType .SOCKET ;
@@ -123,7 +112,7 @@ public void setupProvider(String providerType) throws IOException, InterruptedEx
123
112
124
113
state .builder
125
114
.port (UNAVAILABLE_PORT )
126
- .offlineFlagSourcePath (offlinePath .toAbsolutePath ().toString ());
115
+ .offlineFlagSourcePath (sharedTempDir . resolve ( "allFlags.json" ) .toAbsolutePath ().toString ());
127
116
} else {
128
117
state .builder .port (container .getPort (State .resolverType ));
129
118
}
@@ -134,7 +123,7 @@ public void setupProvider(String providerType) throws IOException, InterruptedEx
134
123
.statusCode (200 );
135
124
136
125
// giving flagd a little time to start
137
- Thread .sleep (100 );
126
+ Thread .sleep (30 );
138
127
FeatureProvider provider =
139
128
new FlagdProvider (state .builder .resolverType (State .resolverType ).build ());
140
129
@@ -163,10 +152,9 @@ public void the_connection_is_lost_for(int seconds) throws InterruptedException
163
152
164
153
@ When ("the flag was modified" )
165
154
public void the_flag_was_modded () throws InterruptedException {
166
-
167
155
when ().post ("http://" + container .getLaunchpadUrl () + "/change" ).then ().statusCode (200 );
168
156
169
157
// we might be too fast in the execution
170
- Thread .sleep (100 );
158
+ Thread .sleep (1000 );
171
159
}
172
160
}
0 commit comments