<commit_before>/*
 * Copyright Strimzi authors.
 * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
 */
package io.strimzi.systemtest.resources.operator;

import io.strimzi.systemtest.Constants;
import io.strimzi.systemtest.Environment;
import io.strimzi.systemtest.resources.ResourceManager;
import io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils;
import io.strimzi.systemtest.utils.specific.BridgeUtils;
import io.strimzi.test.TestUtils;
import io.strimzi.test.k8s.KubeClusterResource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Map;
import java.util.stream.Stream;

import static io.strimzi.test.TestUtils.entry;
import static io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient;

public class HelmResource {
    private static final Logger LOGGER = LogManager.getLogger(HelmResource.class);

    public static final String HELM_CHART = TestUtils.USER_PATH + "/../helm-charts/helm3/strimzi-kafka-operator/";
    public static final String HELM_RELEASE_NAME = "strimzi-systemtests";

    public static final String REQUESTS_MEMORY = "512Mi";
    public static final String REQUESTS_CPU = "200m";
    public static final String LIMITS_MEMORY = "512Mi";
    public static final String LIMITS_CPU = "1000m";

    public static void clusterOperator() {
        clusterOperator(Constants.CO_OPERATION_TIMEOUT_DEFAULT);
    }

    public static void clusterOperator(long operationTimeout) {
        clusterOperator(operationTimeout, Constants.RECONCILIATION_INTERVAL);
    }

    public static void clusterOperator(long operationTimeout, long reconciliationInterval) {
        Map<String, String> values = Collections.unmodifiableMap(Stream.of(
                // image repository config
                entry("image.repository", Environment.STRIMZI_REGISTRY + "/" + Environment.STRIMZI_ORG),
                entry("topicOperator.image.repository", Environment.STRIMZI_REGISTRY + "/" + Environment.STRIMZI_ORG),
                entry("userOperator.image.repository", Environment.STRIMZI_REGISTRY + "/" + Environment.STRIMZI_ORG),
                entry("kafkaInit.image.repository", Environment.STRIMZI_REGISTRY + "/" + Environment.STRIMZI_ORG),
                entry("jmxTrans.image.repository", Environment.STRIMZI_REGISTRY + "/" + Environment.STRIMZI_ORG),
                entry("kafkaBridge.image.repository", Environment.STRIMZI_REGISTRY_DEFAULT + "/" + Environment.STRIMZI_ORG_DEFAULT),
                // image tags config
                entry("image.tag", Environment.STRIMZI_TAG),
                entry("topicOperator.image.tag", Environment.STRIMZI_TAG),
                entry("userOperator.image.tag", Environment.STRIMZI_TAG),
                entry("kafkaInit.image.tag", Environment.STRIMZI_TAG),
                entry("jmxTrans.image.tag", Environment.STRIMZI_TAG),
                entry("kafkaBridge.image.tag", Environment.useLatestReleasedBridge() ? "latest" : BridgeUtils.getBridgeVersion()),
                // Additional config
                entry("image.imagePullPolicy", Environment.OPERATOR_IMAGE_PULL_POLICY),
                entry("resources.requests.memory", REQUESTS_MEMORY),
                entry("resources.requests.cpu", REQUESTS_CPU),
                entry("resources.limits.memory", LIMITS_MEMORY),
                entry("resources.limits.cpu", LIMITS_CPU),
                entry("logLevelOverride", Environment.STRIMZI_LOG_LEVEL),
                entry("fullReconciliationIntervalMs", Long.toString(reconciliationInterval)),
                entry("operationTimeoutMs", Long.toString(operationTimeout)))
                .collect(TestUtils.entriesToMap()));

        Path pathToChart = new File(HELM_CHART).toPath();
        String oldNamespace = KubeClusterResource.getInstance().setNamespace("kube-system");
        InputStream helmAccountAsStream = HelmResource.class.getClassLoader().getResourceAsStream("helm/helm-service-account.yaml");
        String helmServiceAccount = TestUtils.readResource(helmAccountAsStream);
        cmdKubeClient().applyContent(helmServiceAccount);
        KubeClusterResource.getInstance().setNamespace(oldNamespace);
        ResourceManager.getPointerResources().push(HelmResource::deleteClusterOperator);
        ResourceManager.helmClient().install(pathToChart, HELM_RELEASE_NAME, values);<commit_msg>Fix configuration for helm releases for system tests (#3994)<commit_after>/*
 * Copyright Strimzi authors.
 * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
 */
package io.strimzi.systemtest.resources.operator;

import io.strimzi.systemtest.Constants;
import io.strimzi.systemtest.Environment;
import io.strimzi.systemtest.resources.ResourceManager;
import io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils;
import io.strimzi.systemtest.utils.specific.BridgeUtils;
import io.strimzi.test.TestUtils;
import io.strimzi.test.k8s.KubeClusterResource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Map;
import java.util.stream.Stream;

import static io.strimzi.test.TestUtils.entry;
import static io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient;

public class HelmResource {
    private static final Logger LOGGER = LogManager.getLogger(HelmResource.class);

    public static final String HELM_CHART = TestUtils.USER_PATH + "/../helm-charts/helm3/strimzi-kafka-operator/";
    public static final String HELM_RELEASE_NAME = "strimzi-systemtests";

    public static final String REQUESTS_MEMORY = "512Mi";
    public static final String REQUESTS_CPU = "200m";
    public static final String LIMITS_MEMORY = "512Mi";
    public static final String LIMITS_CPU = "1000m";

    public static void clusterOperator() {
        clusterOperator(Constants.CO_OPERATION_TIMEOUT_DEFAULT);
    }

    public static void clusterOperator(long operationTimeout) {
        clusterOperator(operationTimeout, Constants.RECONCILIATION_INTERVAL);
    }

    public static void clusterOperator(long operationTimeout, long reconciliationInterval) {
        Map<String, String> values = Collections.unmodifiableMap(Stream.of(
                // image registry config
                entry("image.registry", Environment.STRIMZI_REGISTRY),
                entry("topicOperator.image.registry", Environment.STRIMZI_REGISTRY),
                entry("userOperator.image.registry", Environment.STRIMZI_REGISTRY),
                entry("kafkaInit.image.registry", Environment.STRIMZI_REGISTRY),
                entry("jmxTrans.image.registry", Environment.STRIMZI_REGISTRY),
                entry("kafkaBridge.image.registry", Environment.STRIMZI_REGISTRY_DEFAULT),
                // image repository config
                entry("image.repository", Environment.STRIMZI_ORG),
                entry("topicOperator.image.repository", Environment.STRIMZI_ORG),
                entry("userOperator.image.repository", Environment.STRIMZI_ORG),
                entry("kafkaInit.image.repository", Environment.STRIMZI_ORG),
                entry("jmxTrans.image.repository", Environment.STRIMZI_ORG),
                entry("kafkaBridge.image.repository", Environment.STRIMZI_ORG_DEFAULT),
                // image tags config
                entry("image.tag", Environment.STRIMZI_TAG),
                entry("topicOperator.image.tag", Environment.STRIMZI_TAG),
                entry("userOperator.image.tag", Environment.STRIMZI_TAG),
                entry("kafkaInit.image.tag", Environment.STRIMZI_TAG),
                entry("jmxTrans.image.tag", Environment.STRIMZI_TAG),
                entry("kafkaBridge.image.tag", Environment.useLatestReleasedBridge() ? "latest" : BridgeUtils.getBridgeVersion()),
                // Additional config
                entry("image.imagePullPolicy", Environment.OPERATOR_IMAGE_PULL_POLICY),
                entry("resources.requests.memory", REQUESTS_MEMORY),
                entry("resources.requests.cpu", REQUESTS_CPU),
                entry("resources.limits.memory", LIMITS_MEMORY),
                entry("resources.limits.cpu", LIMITS_CPU),
                entry("logLevelOverride", Environment.STRIMZI_LOG_LEVEL),
                entry("fullReconciliationIntervalMs", Long.toString(reconciliationInterval)),
                entry("operationTimeoutMs", Long.toString(operationTimeout)))
                .collect(TestUtils.entriesToMap()));

        Path pathToChart = new File(HELM_CHART).toPath();
        String oldNamespace = KubeClusterResource.getInstance().setNamespace("kube-system");
        InputStream helmAccountAsStream = HelmResource.class.getClassLoader().getResourceAsStream("helm/helm-service-account.yaml");
        String helmServiceAccount = TestUtils.readResource(helmAccountAsStream);
        cmdKubeClient().applyContent(helmServiceAccount);
        KubeClusterResource.getInstance().setNamespace(oldNamespace);
        ResourceManager.getPointerResources().push(HelmResource::deleteClusterOperator);
        ResourceManager.helmClient().install(pathToChart, HELM_RELEASE_NAME, values);
{'fraction_non_alphanumeric': 0.10434038913833654, 'fraction_numerical': 0.005131494547787043, 'mean_word_length': 3.6083743842364533, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6544903', 'n_tokens_mistral': 2692, 'n_tokens_neox': 2548, 'n_words': 410}