Skip to content

Commit 2c8f054

Browse files
authored
Merge branch 'main' into feature/reset-connector-offsets
2 parents 971c2c9 + 8df11ac commit 2c8f054

File tree

8 files changed

+45
-15
lines changed

8 files changed

+45
-15
lines changed

.github/workflows/frontend_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
- uses: pnpm/action-setup@v4.0.0
2525
with:
26-
version: 9.1.2
26+
version: 9.11.0
2727

2828
- name: Install node
2929
uses: actions/setup-node@v4.0.2

api/src/main/java/io/kafbat/ui/service/ApplicationInfoService.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package io.kafbat.ui.service;
22

33
import static io.kafbat.ui.model.ApplicationInfoDTO.EnabledFeaturesEnum;
4+
import static io.kafbat.ui.util.GithubReleaseInfo.GITHUB_RELEASE_INFO_TIMEOUT;
45

6+
import com.google.common.annotations.VisibleForTesting;
57
import io.kafbat.ui.model.ApplicationInfoBuildDTO;
68
import io.kafbat.ui.model.ApplicationInfoDTO;
79
import io.kafbat.ui.model.ApplicationInfoLatestReleaseDTO;
@@ -13,27 +15,27 @@
1315
import java.util.Optional;
1416
import java.util.Properties;
1517
import org.springframework.beans.factory.annotation.Autowired;
18+
import org.springframework.beans.factory.annotation.Value;
1619
import org.springframework.boot.info.BuildProperties;
1720
import org.springframework.boot.info.GitProperties;
1821
import org.springframework.scheduling.annotation.Scheduled;
1922
import org.springframework.stereotype.Service;
20-
import reactor.core.publisher.Mono;
2123

2224
@Service
2325
public class ApplicationInfoService {
24-
25-
private final GithubReleaseInfo githubReleaseInfo = new GithubReleaseInfo();
26-
26+
private final GithubReleaseInfo githubReleaseInfo;
2727
private final DynamicConfigOperations dynamicConfigOperations;
2828
private final BuildProperties buildProperties;
2929
private final GitProperties gitProperties;
3030

3131
public ApplicationInfoService(DynamicConfigOperations dynamicConfigOperations,
3232
@Autowired(required = false) BuildProperties buildProperties,
33-
@Autowired(required = false) GitProperties gitProperties) {
33+
@Autowired(required = false) GitProperties gitProperties,
34+
@Value("${" + GITHUB_RELEASE_INFO_TIMEOUT + ":10}") int githubApiMaxWaitTime) {
3435
this.dynamicConfigOperations = dynamicConfigOperations;
3536
this.buildProperties = Optional.ofNullable(buildProperties).orElse(new BuildProperties(new Properties()));
3637
this.gitProperties = Optional.ofNullable(gitProperties).orElse(new GitProperties(new Properties()));
38+
githubReleaseInfo = new GithubReleaseInfo(githubApiMaxWaitTime);
3739
}
3840

3941
public ApplicationInfoDTO getApplicationInfo() {
@@ -74,4 +76,8 @@ public void updateGithubReleaseInfo() {
7476
githubReleaseInfo.refresh().subscribe();
7577
}
7678

79+
@VisibleForTesting
80+
GithubReleaseInfo githubReleaseInfo() {
81+
return githubReleaseInfo;
82+
}
7783
}

api/src/main/java/io/kafbat/ui/util/GithubReleaseInfo.java

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

33
import com.google.common.annotations.VisibleForTesting;
44
import java.time.Duration;
5+
import lombok.Getter;
56
import lombok.extern.slf4j.Slf4j;
67
import reactor.core.publisher.Mono;
78

89
@Slf4j
910
public class GithubReleaseInfo {
11+
public static final String GITHUB_RELEASE_INFO_TIMEOUT = "github.release.info.timeout";
1012

1113
private static final String GITHUB_LATEST_RELEASE_RETRIEVAL_URL =
1214
"https://api.github.com/repos/kafbat/kafka-ui/releases/latest";
1315

14-
private static final Duration GITHUB_API_MAX_WAIT_TIME = Duration.ofSeconds(10);
15-
1616
public record GithubReleaseDto(String html_url, String tag_name, String published_at) {
1717

1818
static GithubReleaseDto empty() {
@@ -24,17 +24,21 @@ static GithubReleaseDto empty() {
2424

2525
private final Mono<Void> refreshMono;
2626

27-
public GithubReleaseInfo() {
28-
this(GITHUB_LATEST_RELEASE_RETRIEVAL_URL);
27+
@Getter
28+
private final int githubApiMaxWaitTime;
29+
30+
public GithubReleaseInfo(int githubApiMaxWaitTime) {
31+
this(GITHUB_LATEST_RELEASE_RETRIEVAL_URL, githubApiMaxWaitTime);
2932
}
3033

3134
@VisibleForTesting
32-
GithubReleaseInfo(String url) {
35+
GithubReleaseInfo(String url, int githubApiMaxWaitTime) {
36+
this.githubApiMaxWaitTime = githubApiMaxWaitTime;
3337
this.refreshMono = new WebClientConfigurator().build()
3438
.get()
3539
.uri(url)
3640
.exchangeToMono(resp -> resp.bodyToMono(GithubReleaseDto.class))
37-
.timeout(GITHUB_API_MAX_WAIT_TIME)
41+
.timeout(Duration.ofSeconds(this.githubApiMaxWaitTime))
3842
.doOnError(th -> log.trace("Error getting latest github release info", th))
3943
.onErrorResume(th -> true, th -> Mono.just(GithubReleaseDto.empty()))
4044
.doOnNext(release -> this.release = release)

api/src/test/java/io/kafbat/ui/AbstractIntegrationTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.kafbat.ui;
22

3+
import static io.kafbat.ui.util.GithubReleaseInfo.GITHUB_RELEASE_INFO_TIMEOUT;
4+
35
import io.kafbat.ui.container.KafkaConnectContainer;
46
import io.kafbat.ui.container.KsqlDbContainer;
57
import io.kafbat.ui.container.SchemaRegistryContainer;
@@ -98,6 +100,7 @@ public void initialize(@NotNull ConfigurableApplicationContext context) {
98100

99101
System.setProperty("dynamic.config.enabled", "true");
100102
System.setProperty("config.related.uploads.dir", tmpDir.toString());
103+
System.setProperty(GITHUB_RELEASE_INFO_TIMEOUT, String.valueOf(100));
101104
}
102105
}
103106

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.kafbat.ui.service;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import io.kafbat.ui.AbstractIntegrationTest;
6+
import org.junit.jupiter.api.Test;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
9+
public class ApplicationInfoServiceTest extends AbstractIntegrationTest {
10+
@Autowired
11+
private ApplicationInfoService service;
12+
13+
@Test
14+
public void testCustomGithubReleaseInfoTimeout() {
15+
assertEquals(100, service.githubReleaseInfo().getGithubApiMaxWaitTime());
16+
}
17+
}

api/src/test/java/io/kafbat/ui/util/GithubReleaseInfoTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void test() {
3737
"""));
3838
var url = mockWebServer.url("repos/kafbat/kafka-ui/releases/latest").toString();
3939

40-
var infoHolder = new GithubReleaseInfo(url);
40+
var infoHolder = new GithubReleaseInfo(url, 10);
4141
infoHolder.refresh().block();
4242

4343
var i = infoHolder.get();

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
},
105105
"engines": {
106106
"node": "v18.17.1",
107-
"pnpm": "v9.1.2"
107+
"pnpm": "v9.11.0"
108108
},
109109
"pnpm": {
110110
"overrides": {

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
<!-- Frontend dependency versions -->
6262
<node.version>v18.17.1</node.version>
63-
<pnpm.version>v9.1.2</pnpm.version>
63+
<pnpm.version>v9.11.0</pnpm.version>
6464

6565
<!-- Plugin versions -->
6666
<fabric8-maven-plugin.version>0.42.1</fabric8-maven-plugin.version>

0 commit comments

Comments
 (0)