Skip to content

Commit 3fa867e

Browse files
authored
[System Tests] fix operator change detection ST and cert manager installation/uninstallation (kroxylicious#2307)
* fix operator change detection ST and cert manager installation/uninstallation Signed-off-by: Francisco Vila <fvila@redhat.com> * add renovate Signed-off-by: Francisco Vila <fvila@redhat.com> * remove cert manager url Signed-off-by: Francisco Vila <fvila@redhat.com> * fix renovate Signed-off-by: Francisco Vila <fvila@redhat.com> * fix format Signed-off-by: Francisco Vila <fvila@redhat.com> * added also component checking Signed-off-by: Francisco Vila <fvila@redhat.com> --------- Signed-off-by: Francisco Vila <fvila@redhat.com>
1 parent 55706b4 commit 3fa867e

File tree

5 files changed

+47
-25
lines changed

5 files changed

+47
-25
lines changed

.github/renovate.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
"depNameTemplate": "hashicorp/vault",
3131
"datasourceTemplate": "docker"
3232
},
33+
{
34+
"customType": "regex",
35+
"fileMatch": [
36+
"kroxylicious-systemtests/src/main/resources/helm_cert_manager_overrides.yaml"
37+
],
38+
"matchStrings": [
39+
"tag:.*(?<currentValue>\\d+\\.\\d+.\\d+)"
40+
],
41+
"depNameTemplate": "cert-manager/cert-manager",
42+
"datasourceTemplate": "github-releases"
43+
},
3344
{
3445
"customType": "regex",
3546
"fileMatch": [

kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/Constants.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ private Constants() {
119119
public static final String KCAT_CLIENT_IMAGE = "quay.io/kroxylicious/kcat:1.7.1";
120120
public static final String KAF_CLIENT_IMAGE = "quay.io/kroxylicious/kaf:v0.2.7";
121121

122-
/**
123-
* The cert manager url to install it on kubernetes
124-
*/
125-
public static final String CERT_MANAGER_URL = "https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml";
126122
/**
127123
* the kubernetes labels used to identify the test kafka clients pods
128124
*/

kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/installation/kroxylicious/CertManager.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@
77
package io.kroxylicious.systemtests.installation.kroxylicious;
88

99
import java.io.IOException;
10+
import java.nio.file.Path;
1011
import java.util.ArrayList;
1112
import java.util.List;
13+
import java.util.Map;
14+
import java.util.Optional;
1215

1316
import org.slf4j.Logger;
1417
import org.slf4j.LoggerFactory;
1518

1619
import io.fabric8.certmanager.api.model.v1.CertificateBuilder;
1720
import io.fabric8.certmanager.api.model.v1.IssuerBuilder;
18-
import io.fabric8.kubernetes.api.model.HasMetadata;
19-
import io.fabric8.kubernetes.client.dsl.NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable;
2021

2122
import io.kroxylicious.systemtests.Constants;
2223
import io.kroxylicious.systemtests.resources.manager.ResourceManager;
23-
import io.kroxylicious.systemtests.utils.DeploymentUtils;
2424
import io.kroxylicious.systemtests.utils.NamespaceUtils;
25+
import io.kroxylicious.systemtests.utils.TestUtils;
2526

2627
import static io.kroxylicious.systemtests.k8s.KubeClusterResource.kubeClient;
2728

@@ -32,17 +33,21 @@ public class CertManager {
3233
private static final Logger LOGGER = LoggerFactory.getLogger(CertManager.class);
3334
public static final String SELF_SINGED_ISSUER_NAME = "self-signed-issuer";
3435

35-
private final NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata> deployment;
36+
public static final String CERT_MANAGER_SERVICE_NAME = "cert-manager";
37+
public static final String CERT_MANAGER_HELM_REPOSITORY_URL = "https://charts.jetstack.io";
38+
public static final String CERT_MANAGER_HELM_REPOSITORY_NAME = "jetstack";
39+
public static final String CERT_MANAGER_HELM_CHART_NAME = "jetstack/cert-manager";
40+
3641
private boolean deleteCertManager = true;
42+
private final String deploymentNamespace;
3743

3844
/**
3945
* Instantiates a new Cert manager.
4046
*
4147
* @throws IOException the io exception
4248
*/
4349
public CertManager() throws IOException {
44-
deployment = kubeClient().getClient()
45-
.load(DeploymentUtils.getDeploymentFileFromURL(Constants.CERT_MANAGER_URL));
50+
deploymentNamespace = Constants.CERT_MANAGER_NAMESPACE;
4651
}
4752

4853
public IssuerBuilder issuer(String namespace) {
@@ -103,10 +108,15 @@ public void deploy() {
103108
deleteCertManager = false;
104109
return;
105110
}
111+
106112
LOGGER.info("Deploy cert manager in {} namespace", Constants.CERT_MANAGER_NAMESPACE);
107-
deployment.create();
108-
DeploymentUtils.waitForDeploymentReady(Constants.CERT_MANAGER_NAMESPACE, "cert-manager-webhook");
109-
NamespaceUtils.addNamespaceToSet(Constants.CERT_MANAGER_NAMESPACE, ResourceManager.getTestContext().getRequiredTestClass().getName());
113+
NamespaceUtils.createNamespaceAndPrepare(deploymentNamespace);
114+
ResourceManager.helmClient().addRepository(CERT_MANAGER_HELM_REPOSITORY_NAME, CERT_MANAGER_HELM_REPOSITORY_URL);
115+
ResourceManager.helmClient().namespace(deploymentNamespace).install(CERT_MANAGER_HELM_CHART_NAME, CERT_MANAGER_SERVICE_NAME,
116+
Optional.empty(),
117+
Optional.of(Path.of(TestUtils.getResourcesURI("helm_cert_manager_overrides.yaml"))),
118+
Optional.of(Map.of("crds.enabled", "true",
119+
"crds.keep", "false")));
110120
}
111121

112122
/**
@@ -118,8 +128,7 @@ public void delete() {
118128
return;
119129
}
120130
LOGGER.info("Deleting Cert Manager in {} namespace", Constants.CERT_MANAGER_NAMESPACE);
121-
deployment.withGracePeriod(0).delete();
122-
DeploymentUtils.waitForDeploymentDeletion(Constants.CERT_MANAGER_NAMESPACE, "cert-manager-webhook");
131+
ResourceManager.helmClient().delete(deploymentNamespace, CERT_MANAGER_SERVICE_NAME);
123132
NamespaceUtils.deleteNamespaceWithWaitAndRemoveFromSet(Constants.CERT_MANAGER_NAMESPACE, ResourceManager.getTestContext().getRequiredTestClass().getName());
124133
}
125134
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# Copyright Kroxylicious Authors.
3+
#
4+
# Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+
#
6+
7+
# Helm Overrides File for cert manager used by the system tests.
8+
image:
9+
tag: v1.18.0

kroxylicious-systemtests/src/test/java/io/kroxylicious/systemtests/OperatorChangeDetectionST.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,8 @@ void shouldUpdateDeploymentWhenVirtualKafkaClusterChanges(String namespace) {
122122
}
123123

124124
@Test
125-
void shouldUpdateDeploymentWhenDownstreamTlsCertUpdated(String namespace) throws IOException {
125+
void shouldUpdateDeploymentWhenDownstreamTlsCertUpdated(String namespace) {
126126
// Given
127-
certManager = new CertManager();
128-
certManager.deploy();
129-
130127
var issuer = certManager.issuer(namespace);
131128
var cert = certManager.certFor(namespace, "my-cluster-cluster-ip." + namespace + ".svc.cluster.local");
132129

@@ -151,11 +148,8 @@ void shouldUpdateDeploymentWhenDownstreamTlsCertUpdated(String namespace) throws
151148
}
152149

153150
@Test
154-
void shouldUpdateDeploymentWhenDownstreamTrustUpdated(String namespace) throws IOException {
151+
void shouldUpdateDeploymentWhenDownstreamTrustUpdated(String namespace) {
155152
// Given
156-
certManager = new CertManager();
157-
certManager.deploy();
158-
159153
var issuer = certManager.issuer(namespace);
160154
var cert = certManager.certFor(namespace, "my-cluster-cluster-ip." + namespace + ".svc.cluster.local");
161155

@@ -285,8 +279,10 @@ private static void assertDeploymentUpdated(String namespace, String originalChe
285279
}
286280

287281
@BeforeEach
288-
void setUp(String namespace) {
282+
void setUp(String namespace) throws IOException {
289283
kroxylicious = new Kroxylicious(namespace);
284+
certManager = new CertManager();
285+
certManager.deploy();
290286
}
291287

292288
@AfterAll
@@ -309,7 +305,8 @@ private String getInitialChecksum(String namespace) {
309305
var kubeClient = kubeClient(namespace);
310306
AtomicReference<String> checksumFromAnnotation = new AtomicReference<>();
311307
await().atMost(Duration.ofSeconds(90))
312-
.untilAsserted(() -> kubeClient.listPods(namespace, "app.kubernetes.io/name", "kroxylicious-proxy"),
308+
.untilAsserted(() -> kubeClient.listPods(namespace, "app.kubernetes.io/name", "kroxylicious")
309+
.stream().filter(p -> p.getMetadata().getLabels().get("app.kubernetes.io/component").equalsIgnoreCase("proxy")).toList(),
313310
proxyPods -> {
314311
assertThat(proxyPods)
315312
.singleElement()

0 commit comments

Comments
 (0)