Skip to content
Merged
Changes from all commits
Commits
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 @@ -17,13 +17,17 @@

import java.time.Duration;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

import org.junit.jupiter.api.Test;

import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.Secret;
import io.javaoperatorsdk.operator.api.monitoring.Metrics;
import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResourceFactory;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
Expand All @@ -33,7 +37,7 @@
private static final Metrics METRICS = new Metrics() {};

private static final LeaderElectionConfiguration LEADER_ELECTION_CONFIGURATION =
new LeaderElectionConfiguration("foo", "fooNS");

Check warning on line 40 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/kotlin-operator)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 40 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/tomcat-operator)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 40 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/mysql-schema)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 40 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/webpage)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 40 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/leader-election)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 40 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/operations)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 40 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / build / integration_tests (25, v1.34.5) / Integration tests (25, v1.34.5, vertx)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

private static final Cloner CLONER =
new Cloner() {
Expand Down Expand Up @@ -85,7 +89,7 @@
.withConcurrentReconciliationThreads(25)
.withMetrics(new Metrics() {})
.withLeaderElectionConfiguration(
new LeaderElectionConfiguration("newLease", "newLeaseNS"))

Check warning on line 92 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/kotlin-operator)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 92 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/tomcat-operator)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 92 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/mysql-schema)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 92 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/webpage)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 92 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/leader-election)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 92 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / sample_operators_tests (sample-operators/operations)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal

Check warning on line 92 in operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

View workflow job for this annotation

GitHub Actions / build / integration_tests (25, v1.34.5) / Integration tests (25, v1.34.5, vertx)

LeaderElectionConfiguration(java.lang.String,java.lang.String) in io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration has been deprecated and marked for removal
.withInformerStoppedHandler((informer, ex) -> {})
.withReconciliationTerminationTimeout(Duration.ofSeconds(30))
.build();
Expand All @@ -98,10 +102,10 @@
assertNotEquals(config.getExecutorService(), overridden.getExecutorService());
assertNotEquals(config.getWorkflowExecutorService(), overridden.getWorkflowExecutorService());
assertNotEquals(config.getMetrics(), overridden.getMetrics());
assertNotEquals(config.getResourceCloner(), overridden.getResourceCloner());
assertNotEquals(
config.getLeaderElectionConfiguration(), overridden.getLeaderElectionConfiguration());
assertNotEquals(
config.getInformerStoppedHandler(), overridden.getLeaderElectionConfiguration());
assertNotEquals(config.getInformerStoppedHandler(), overridden.getInformerStoppedHandler());
assertNotEquals(
config.reconciliationTerminationTimeout(), overridden.reconciliationTerminationTimeout());
}
Expand All @@ -118,4 +122,30 @@
assertThat(((ThreadPoolExecutor) overridden.getWorkflowExecutorService()).getMaximumPoolSize())
.isEqualTo(14);
}

@SuppressWarnings("rawtypes")
@Test
void dependentResourceFactoryDefaultsToTheSharedOneAndCanBeOverridden() {
final var factory = new DependentResourceFactory() {};

assertThat(config.dependentResourceFactory()).isSameAs(DependentResourceFactory.DEFAULT);
assertThat(
new ConfigurationServiceOverrider(config)
.withDependentResourceFactory(factory)
.build()
.dependentResourceFactory())
.isSameAs(factory);
}

@Test
void defaultNonSSAResourcesDefaultToConfigMapsAndSecretsAndCanBeOverridden() {
assertThat(config.defaultNonSSAResources())
.containsExactlyInAnyOrder(ConfigMap.class, Secret.class);
assertThat(
new ConfigurationServiceOverrider(config)
.withDefaultNonSSAResource(Set.of())
.build()
.defaultNonSSAResources())
.isEmpty();
}
}
Loading