Skip to content

Commit

Permalink
Update system tests
Browse files Browse the repository at this point in the history
Signed-off-by: Katherine Stanley <[email protected]>
  • Loading branch information
katheris committed Jan 8, 2025
1 parent 0f00aff commit 198cd67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,9 @@ void testRegenerateCertExternalAddressChange() {
);
resourceManager.createResourceWithWait(KafkaTemplates.kafkaPersistent(testStorage.getNamespaceName(), testStorage.getClusterName(), 3, 1).build());

final String brokerSecret = testStorage.getClusterName() + "-kafka-brokers";

Secret secretsWithoutExt = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), brokerSecret);
Map<String, Secret> secretsWithoutExt = kubeClient(testStorage.getNamespaceName()).listSecrets()
.stream()
.collect(Collectors.toMap(secret -> secret.getMetadata().getName(), secret -> secret));

LOGGER.info("Editing Kafka with external listener");
KafkaResource.replaceKafkaResourceInSpecificNamespace(testStorage.getNamespaceName(), testStorage.getClusterName(), kafka -> {
Expand All @@ -538,13 +538,12 @@ void testRegenerateCertExternalAddressChange() {

RollingUpdateUtils.waitTillComponentHasRolled(testStorage.getNamespaceName(), testStorage.getBrokerSelector(), 3, PodUtils.podSnapshot(testStorage.getNamespaceName(), testStorage.getBrokerSelector()));

Secret secretsWithExt = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), brokerSecret);

LOGGER.info("Checking Secrets");
kubeClient(testStorage.getNamespaceName()).listPodsByPrefixInName(testStorage.getNamespaceName(), StrimziPodSetResource.getBrokerComponentName(testStorage.getClusterName())).forEach(kafkaPod -> {
String kafkaPodName = kafkaPod.getMetadata().getName();
assertThat(secretsWithExt.getData().get(kafkaPodName + ".crt"), is(not(secretsWithoutExt.getData().get(kafkaPodName + ".crt"))));
assertThat(secretsWithExt.getData().get(kafkaPodName + ".key"), is(not(secretsWithoutExt.getData().get(kafkaPodName + ".key"))));
Secret secretWithExt = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), kafkaPodName);
assertThat(secretWithExt.getData().get(kafkaPodName + ".crt"), is(not(secretsWithoutExt.get(kafkaPodName).getData().get(kafkaPodName + ".crt"))));
assertThat(secretWithExt.getData().get(kafkaPodName + ".key"), is(not(secretsWithoutExt.get(kafkaPodName).getData().get(kafkaPodName + ".key"))));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ void testClusterCACertRenew() {
Date initialCertEndTime = cacert.getNotAfter();

// Check Broker kafka certificate dates
Secret brokerCertCreationSecret = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), testStorage.getClusterName() + "-kafka-brokers");
Secret brokerCertCreationSecret = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), brokerPodName);
X509Certificate kafkaBrokerCert = SecretUtils.getCertificateFromSecret(brokerCertCreationSecret,
brokerPodName + ".crt");
Date initialKafkaBrokerCertStartTime = kafkaBrokerCert.getNotBefore();
Expand Down Expand Up @@ -1367,7 +1367,7 @@ void testClusterCACertRenew() {
Date changedCertEndTime = cacert.getNotAfter();

// Check renewed Broker kafka certificate dates
brokerCertCreationSecret = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), testStorage.getClusterName() + "-kafka-brokers");
brokerCertCreationSecret = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), brokerPodName);
kafkaBrokerCert = SecretUtils.getCertificateFromSecret(brokerCertCreationSecret, brokerPodName + ".crt");
Date changedKafkaBrokerCertStartTime = kafkaBrokerCert.getNotBefore();
Date changedKafkaBrokerCertEndTime = kafkaBrokerCert.getNotAfter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void testCustomClusterCaAndClientsCaCertificates() {
LOGGER.info("Check Kafka(s) and ZooKeeper(s) certificates");
String brokerPodName = kubeClient().listPods(testStorage.getNamespaceName(), testStorage.getBrokerSelector()).get(0).getMetadata().getName();
final X509Certificate kafkaCert = SecretUtils.getCertificateFromSecret(kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(),
testStorage.getClusterName() + "-kafka-brokers"), brokerPodName + ".crt");
brokerPodName), brokerPodName + ".crt");
assertThat("KafkaCert does not have expected test Issuer: " + kafkaCert.getIssuerDN(),
SystemTestCertManager.containsAllDN(kafkaCert.getIssuerX500Principal().getName(), clusterCa.getSubjectDn()));

Expand Down Expand Up @@ -318,7 +318,7 @@ void testReplaceCustomClusterCACertificateValidityToInvokeRenewalProcess() {

// Check Broker kafka certificate dates
String brokerPodName = kubeClient().listPods(testStorage.getNamespaceName(), testStorage.getBrokerSelector()).get(0).getMetadata().getName();
Secret brokerCertCreationSecret = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), testStorage.getClusterName() + "-kafka-brokers");
Secret brokerCertCreationSecret = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), brokerPodName);
X509Certificate kafkaBrokerCert = SecretUtils.getCertificateFromSecret(brokerCertCreationSecret, brokerPodName + ".crt");
final Date initialKafkaBrokerCertStartTime = kafkaBrokerCert.getNotBefore();
final Date initialKafkaBrokerCertEndTime = kafkaBrokerCert.getNotAfter();
Expand Down Expand Up @@ -372,7 +372,7 @@ void testReplaceCustomClusterCACertificateValidityToInvokeRenewalProcess() {
final Date changedCertEndTime = cacert.getNotAfter();

// Check renewed Broker kafka certificate dates
brokerCertCreationSecret = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), testStorage.getClusterName() + "-kafka-brokers");
brokerCertCreationSecret = kubeClient(testStorage.getNamespaceName()).getSecret(testStorage.getNamespaceName(), brokerPodName);
kafkaBrokerCert = SecretUtils.getCertificateFromSecret(brokerCertCreationSecret, brokerPodName + ".crt");
final Date changedKafkaBrokerCertStartTime = kafkaBrokerCert.getNotBefore();
final Date changedKafkaBrokerCertEndTime = kafkaBrokerCert.getNotAfter();
Expand Down

0 comments on commit 198cd67

Please sign in to comment.