-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add leader election configuration (#54)
- Loading branch information
1 parent
53cb404
commit 3a29e71
Showing
6 changed files
with
104 additions
and
19 deletions.
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
13 changes: 13 additions & 0 deletions
13
src/main/java/org/tkit/onecx/k8s/db/postgresql/operator/LeaderConfiguration.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,13 @@ | ||
package org.tkit.onecx.k8s.db.postgresql.operator; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
import io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration; | ||
|
||
@Singleton | ||
public class LeaderConfiguration extends LeaderElectionConfiguration { | ||
|
||
public LeaderConfiguration(DatabaseConfig config) { | ||
super(config.leaderElectionConfig().leaseName()); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/test/java/org/tkit/onecx/k8s/db/postgresql/operator/LeaderConfigurationTest.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,27 @@ | ||
package org.tkit.onecx.k8s.db.postgresql.operator; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
class LeaderConfigurationTest { | ||
|
||
@Inject | ||
DatabaseConfig dataConfig; | ||
|
||
@Inject | ||
LeaderConfiguration leaderConfiguration; | ||
|
||
@Test | ||
void testLeaderConfiguration() { | ||
assertThat(dataConfig).isNotNull(); | ||
assertThat(dataConfig.leaderElectionConfig()).isNotNull(); | ||
assertThat(leaderConfiguration).isNotNull(); | ||
assertThat(leaderConfiguration.getLeaseName()).isNotNull().isEqualTo(dataConfig.leaderElectionConfig().leaseName()); | ||
} | ||
} |