Skip to content
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

feat: Improve wait logic to a more elegant solution #1160 #1169

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public static void afterAll() throws IOException {
}

@Before
public void before() throws IOException {
public void before() {
if (!container.isRunning()) {
container.start();
}
}

@After
public void tearDown() throws InterruptedException {
public void tearDown() {
if (state.client != null) {
when().post("http://" + container.getLaunchpadUrl() + "/stop")
.then()
Expand All @@ -70,7 +70,7 @@ public void tearDown() throws InterruptedException {
}

@Given("a {} flagd provider")
public void setupProvider(String providerType) throws IOException, InterruptedException {
public void setupProvider(String providerType) throws InterruptedException {
String flagdConfig = "default";
state.builder.deadline(1000).keepAlive(0).retryGracePeriod(2);
boolean wait = true;
Expand Down Expand Up @@ -125,28 +125,26 @@ public void setupProvider(String providerType) throws IOException, InterruptedEx
.statusCode(200);

// giving flagd a little time to start
Thread.sleep(30);
Thread.sleep(100);
FeatureProvider provider =
new FlagdProvider(state.builder.resolverType(State.resolverType).build());

OpenFeatureAPI api = OpenFeatureAPI.getInstance();
String providerName = providerType + Math.random();
if (wait) {
api.setProviderAndWait(providerName, provider);
api.setProviderAndWait(provider);
} else {
api.setProvider(providerName, provider);
api.setProvider(provider);
}
log.info("provider name: {}", providerName);
this.state.client = api.getClient(providerName);
this.state.client = api.getClient();
}

@When("the connection is lost")
public void the_connection_is_lost() throws InterruptedException {
public void the_connection_is_lost() {
when().post("http://" + container.getLaunchpadUrl() + "/stop").then().statusCode(200);
}

@When("the connection is lost for {int}s")
public void the_connection_is_lost_for(int seconds) throws InterruptedException {
public void the_connection_is_lost_for(int seconds) {
when().post("http://" + container.getLaunchpadUrl() + "/restart?seconds={seconds}", seconds)
.then()
.statusCode(200);
Expand Down
Loading