use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaResourceType method isDeleted.
public static void isDeleted(ManagedKafka mk) {
TestUtils.waitFor("Managed kafka is removed", 1_000, 600_000, () -> {
ManagedKafka m = ManagedKafkaResourceType.getOperation().inNamespace(mk.getMetadata().getNamespace()).withName(mk.getMetadata().getName()).get();
List<Pod> pods = KubeClient.getInstance().client().pods().inNamespace(mk.getMetadata().getNamespace()).list().getItems();
return m == null && pods.size() == 0;
});
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class StrimziManagerTest method testStrimziVersionChange.
@Test
public void testStrimziVersionChange() {
ManagedKafka mk = ManagedKafka.getDummyInstance(1);
mk.getSpec().getVersions().setStrimzi("strimzi-cluster-operator.v1");
Kafka kafka = this.kafkaCluster.kafkaFrom(mk, null);
kafkaClient.create(kafka);
// Kafka reconcile not paused and current label version as the ManagedKafka one
assertFalse(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_RECONCILE_ANNOTATION));
assertEquals(kafka.getMetadata().getLabels().get(this.strimziManager.getVersionLabel()), mk.getSpec().getVersions().getStrimzi());
// ManagedKafka and Kafka updated their status information
mk.setStatus(new ManagedKafkaStatusBuilder().withVersions(new VersionsBuilder().withStrimzi("strimzi-cluster-operator.v1").build()).build());
kafka.setStatus(new KafkaStatusBuilder().withConditions(new ConditionBuilder().withType("Ready").withStatus("True").build()).build());
kafkaClient.replaceStatus(kafka);
// ask for a Strimzi version change on ManagedKafka
mk.getSpec().getVersions().setStrimzi("strimzi-cluster-operator.v2");
kafka = this.kafkaCluster.kafkaFrom(mk, kafka);
// Kafka reconcile paused but label is still the current version
assertTrue(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_RECONCILE_ANNOTATION));
assertTrue(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_REASON_ANNOTATION));
assertEquals(kafka.getMetadata().getLabels().get(this.strimziManager.getVersionLabel()), mk.getStatus().getVersions().getStrimzi());
// nothing should change after an intermediate reconcile
kafka = this.kafkaCluster.kafkaFrom(mk, kafka);
assertTrue(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_REASON_ANNOTATION));
// Kafka moves to be paused
kafka.setStatus(new KafkaStatusBuilder().withConditions(new ConditionBuilder().withType("ReconciliationPaused").withStatus("True").build()).build());
kafkaClient.replaceStatus(kafka);
kafka = this.kafkaCluster.kafkaFrom(mk, kafka);
// Kafka reconcile not paused and Kafka label updated to requested Strimzi version
assertFalse(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_RECONCILE_ANNOTATION));
// the pause reason should stay until strimzi updates to ready
assertTrue(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_REASON_ANNOTATION));
assertEquals(kafka.getMetadata().getLabels().get(this.strimziManager.getVersionLabel()), "strimzi-cluster-operator.v2");
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class AdminServerTest method createAdminServerDeployment.
@ParameterizedTest
@CsvSource({ "test-mk-q, 1, true, false, /expected/adminserver-quarkus.yml", "test-mk-tls-q, 2, true, true, /expected/adminserver-tls-quarkus.yml", "test-mk, 3, false, false, /expected/adminserver.yml", "test-mk-tls, 4, false, true, /expected/adminserver-tls.yml" })
void createAdminServerDeployment(String name, String versionString, boolean quarkusBased, boolean tls, String expectedResource) throws Exception {
ManagedKafka mk = buildBasicManagedKafka(name, versionString, tls ? new TlsKeyPair() : null);
OperandOverride override = new OperandOverride();
override.setImage("quay.io/mk-ci-cd/kafka-admin-api:0.7.0");
override.setAdditionalProperty("quarkus-based", quarkusBased);
OperandOverrideManager overrideManager = Mockito.mock(OperandOverrideManager.class);
Mockito.when(overrideManager.getAdminServerOverride(versionString)).thenReturn(override);
Mockito.when(overrideManager.getAdminServerImage(versionString)).thenReturn(override.image);
QuarkusMock.installMockForType(overrideManager, OperandOverrideManager.class);
Deployment adminServerDeployment = adminServer.deploymentFrom(mk, null);
server.getClient().apps().deployments().create(adminServerDeployment);
assertNotNull(server.getClient().apps().deployments().inNamespace(adminServerDeployment.getMetadata().getNamespace()).withName(adminServerDeployment.getMetadata().getName()).get());
KafkaClusterTest.diffToExpected(adminServerDeployment, expectedResource);
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaClusterTest method testExistingStorageClassOverridesDontGetUpdated.
@Test
void testExistingStorageClassOverridesDontGetUpdated() {
ManagedKafka mk = exampleManagedKafka("60Gi");
Kafka defaultKafka = kafkaCluster.kafkaFrom(mk, null);
JbodStorage defaultKafkaStorage = (JbodStorage) defaultKafka.getSpec().getKafka().getStorage();
PersistentClaimStorage defaultZookeeperStorage = (PersistentClaimStorage) defaultKafka.getSpec().getZookeeper().getStorage();
JbodStorage kafkaStorageWithOverrides = new JbodStorageBuilder(defaultKafkaStorage).withVolumes(defaultKafkaStorage.getVolumes().stream().map(v -> {
PersistentClaimStorage pcs = (PersistentClaimStorage) v;
pcs.setStorageClass(null);
pcs.setOverrides(buildStorageOverrides());
return pcs;
}).collect(Collectors.toList())).build();
PersistentClaimStorage zookeeperStorageWithOverrides = new PersistentClaimStorageBuilder(defaultZookeeperStorage).withStorageClass(null).withOverrides(buildStorageOverrides()).build();
Kafka kafkaWithOverrides = new KafkaBuilder(defaultKafka).editSpec().editKafka().withStorage(kafkaStorageWithOverrides).endKafka().editZookeeper().withStorage(zookeeperStorageWithOverrides).endZookeeper().endSpec().build();
Kafka reconciledKafka = kafkaCluster.kafkaFrom(mk, kafkaWithOverrides);
assertNull(((PersistentClaimStorage) reconciledKafka.getSpec().getZookeeper().getStorage()).getStorageClass());
assertEquals(buildStorageOverrides(), ((PersistentClaimStorage) reconciledKafka.getSpec().getZookeeper().getStorage()).getOverrides());
((JbodStorage) reconciledKafka.getSpec().getKafka().getStorage()).getVolumes().stream().forEach(v -> {
assertNull(((PersistentClaimStorage) v).getStorageClass());
assertEquals(buildStorageOverrides(), ((PersistentClaimStorage) v).getOverrides());
});
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaClusterTest method testManagedKafkaMaximumSessionLifetimeMapping.
@ParameterizedTest
@CsvSource({ // Default to 4m 59s
", 299000", // No less than zero
"-1, 0", "0, 0", "1, 1", "299000, 299000" })
void testManagedKafkaMaximumSessionLifetimeMapping(Long maximumSessionLifetime, long maxReauthMs) throws IOException {
ManagedKafka mk = exampleManagedKafka("60Gi");
mk.getSpec().getOauth().setMaximumSessionLifetime(maximumSessionLifetime);
Kafka kafka = kafkaCluster.kafkaFrom(mk, null);
assertEquals(maxReauthMs, kafka.getSpec().getKafka().getConfig().get("connections.max.reauth.ms"));
}
Aggregations