-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62a246a
commit 98a748a
Showing
5 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
66 changes: 66 additions & 0 deletions
66
src/test/java/io/quarkus/search/app/indexing/SchedulerTest.java
This file contains 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,66 @@ | ||
package io.quarkus.search.app.indexing; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.Duration; | ||
import java.util.Map; | ||
|
||
import io.quarkus.search.app.SearchService; | ||
import io.quarkus.search.app.dto.GuideSearchHit; | ||
import io.quarkus.search.app.dto.SearchResult; | ||
import io.quarkus.search.app.testsupport.QuarkusIOSample; | ||
|
||
import io.quarkus.test.common.http.TestHTTPEndpoint; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
|
||
import org.awaitility.Awaitility; | ||
|
||
import io.restassured.common.mapper.TypeRef; | ||
|
||
@QuarkusTest | ||
@TestProfile(SchedulerTest.Profile.class) | ||
@TestHTTPEndpoint(SearchService.class) | ||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@QuarkusIOSample.Setup(filter = QuarkusIOSample.SearchServiceFilterDefinition.class) | ||
class SchedulerTest { | ||
public static class Profile implements QuarkusTestProfile { | ||
@Override | ||
public Map<String, String> getConfigOverrides() { | ||
return Map.of("indexing.on-startup.enabled", "false", | ||
// Every 10 seconds starting at second 00, every minute starting at minute :00, of every hour: | ||
"indexing.scheduled.cron", "0/10 0/1 * ? * * *"); | ||
} | ||
} | ||
|
||
private static final TypeRef<SearchResult<GuideSearchHit>> SEARCH_RESULT_SEARCH_HITS = new TypeRef<>() { | ||
}; | ||
private static final String GUIDES_SEARCH = "/guides/search"; | ||
|
||
protected int managementPort() { | ||
if (getClass().getName().endsWith("IT")) { | ||
return 9000; | ||
} else { | ||
return 9001; | ||
} | ||
} | ||
|
||
@Test | ||
void scheduler() { | ||
// since we've disabled the index-on-start there should be no indexes until the scheduler kicks in: | ||
Awaitility.await().timeout(Duration.ofMinutes(1)).pollDelay(Duration.ofSeconds(15)).untilAsserted(() -> { | ||
assertThat(given() | ||
.when().get(GUIDES_SEARCH) | ||
.then() | ||
.statusCode(200) | ||
.extract().body().as(SEARCH_RESULT_SEARCH_HITS) | ||
.total()).isPositive(); | ||
}); | ||
} | ||
|
||
} |