Search in sources :

Example 1 with HelmResource

use of io.strimzi.systemtest.resources.operator.specific.HelmResource in project strimzi by strimzi.

the class SetupClusterOperator method runInstallation.

/**
 * This method install Strimzi Cluster Operator based on environment variable configuration.
 * It can install operator by classic way (apply bundle yamls) or use OLM. For OLM you need to set all other OLM env variables.
 * Don't use this method in tests, where specific configuration of CO is needed.
 */
@SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public SetupClusterOperator runInstallation() {
    LOGGER.info("Cluster operator installation configuration:\n{}", this::prettyPrint);
    LOGGER.debug("Cluster operator installation configuration:\n{}", this::toString);
    // if it's shared context (before suite) skip
    if (BeforeAllOnce.getSharedExtensionContext() != extensionContext) {
        testClassName = extensionContext.getRequiredTestClass() != null ? extensionContext.getRequiredTestClass().getName() : "";
        testMethodName = extensionContext.getDisplayName() != null ? extensionContext.getDisplayName() : "";
    }
    if (Environment.isOlmInstall()) {
        LOGGER.info("Install ClusterOperator via OLM");
        // cluster-wide olm co-operator or multi-namespaces in once we also deploy cluster-wide
        if (IS_OLM_CLUSTER_WIDE.test(namespaceToWatch)) {
            // if RBAC is enable we don't run tests in parallel mode and with that said we don't create another namespaces
            if (!Environment.isNamespaceRbacScope()) {
                if (isClusterOperatorNamespaceNotCreated()) {
                    cluster.setNamespace(namespaceInstallTo);
                    cluster.createNamespaces(CollectorElement.createCollectorElement(testClassName, testMethodName), namespaceInstallTo, bindingsNamespaces);
                    extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).put(Constants.PREPARE_OPERATOR_ENV_KEY + namespaceInstallTo, false);
                }
                createClusterRoleBindings();
                namespaceInstallTo = cluster.getDefaultOlmNamespace();
                olmResource = new OlmResource(namespaceInstallTo);
                olmResource.create(extensionContext, operationTimeout, reconciliationInterval);
            }
        // single-namespace olm co-operator
        } else {
            if (isClusterOperatorNamespaceNotCreated()) {
                cluster.setNamespace(namespaceInstallTo);
                cluster.createNamespaces(CollectorElement.createCollectorElement(testClassName, testMethodName), namespaceInstallTo, bindingsNamespaces);
                extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).put(Constants.PREPARE_OPERATOR_ENV_KEY + namespaceInstallTo, false);
            }
            olmResource = new OlmResource(namespaceInstallTo);
            olmResource.create(extensionContext, operationTimeout, reconciliationInterval);
        }
    } else if (Environment.isHelmInstall()) {
        LOGGER.info("Install ClusterOperator via Helm");
        helmResource = new HelmResource(namespaceInstallTo, namespaceToWatch);
        if (isClusterOperatorNamespaceNotCreated()) {
            cluster.setNamespace(namespaceInstallTo);
            cluster.createNamespaces(CollectorElement.createCollectorElement(testClassName, testMethodName), namespaceInstallTo, bindingsNamespaces);
            extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).put(Constants.PREPARE_OPERATOR_ENV_KEY + namespaceInstallTo, false);
        }
        helmResource.create(extensionContext, operationTimeout, reconciliationInterval);
    } else {
        bundleInstallation();
    }
    return this;
}
Also used : OlmResource(io.strimzi.systemtest.resources.operator.specific.OlmResource) HelmResource(io.strimzi.systemtest.resources.operator.specific.HelmResource) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 2 with HelmResource

use of io.strimzi.systemtest.resources.operator.specific.HelmResource in project strimzi-kafka-operator by strimzi.

the class SetupClusterOperator method runInstallation.

/**
 * This method install Strimzi Cluster Operator based on environment variable configuration.
 * It can install operator by classic way (apply bundle yamls) or use OLM. For OLM you need to set all other OLM env variables.
 * Don't use this method in tests, where specific configuration of CO is needed.
 */
@SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public SetupClusterOperator runInstallation() {
    LOGGER.info("Cluster operator installation configuration:\n{}", this::prettyPrint);
    LOGGER.debug("Cluster operator installation configuration:\n{}", this::toString);
    // if it's shared context (before suite) skip
    if (BeforeAllOnce.getSharedExtensionContext() != extensionContext) {
        testClassName = extensionContext.getRequiredTestClass() != null ? extensionContext.getRequiredTestClass().getName() : "";
        testMethodName = extensionContext.getDisplayName() != null ? extensionContext.getDisplayName() : "";
    }
    if (Environment.isOlmInstall()) {
        LOGGER.info("Install ClusterOperator via OLM");
        // cluster-wide olm co-operator or multi-namespaces in once we also deploy cluster-wide
        if (IS_OLM_CLUSTER_WIDE.test(namespaceToWatch)) {
            // if RBAC is enable we don't run tests in parallel mode and with that said we don't create another namespaces
            if (!Environment.isNamespaceRbacScope()) {
                if (isClusterOperatorNamespaceNotCreated()) {
                    cluster.setNamespace(namespaceInstallTo);
                    cluster.createNamespaces(CollectorElement.createCollectorElement(testClassName, testMethodName), namespaceInstallTo, bindingsNamespaces);
                    extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).put(Constants.PREPARE_OPERATOR_ENV_KEY + namespaceInstallTo, false);
                }
                createClusterRoleBindings();
                namespaceInstallTo = cluster.getDefaultOlmNamespace();
                olmResource = new OlmResource(namespaceInstallTo);
                olmResource.create(extensionContext, operationTimeout, reconciliationInterval);
            }
        // single-namespace olm co-operator
        } else {
            if (isClusterOperatorNamespaceNotCreated()) {
                cluster.setNamespace(namespaceInstallTo);
                cluster.createNamespaces(CollectorElement.createCollectorElement(testClassName, testMethodName), namespaceInstallTo, bindingsNamespaces);
                extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).put(Constants.PREPARE_OPERATOR_ENV_KEY + namespaceInstallTo, false);
            }
            olmResource = new OlmResource(namespaceInstallTo);
            olmResource.create(extensionContext, operationTimeout, reconciliationInterval);
        }
    } else if (Environment.isHelmInstall()) {
        LOGGER.info("Install ClusterOperator via Helm");
        helmResource = new HelmResource(namespaceInstallTo, namespaceToWatch);
        if (isClusterOperatorNamespaceNotCreated()) {
            cluster.setNamespace(namespaceInstallTo);
            cluster.createNamespaces(CollectorElement.createCollectorElement(testClassName, testMethodName), namespaceInstallTo, bindingsNamespaces);
            extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).put(Constants.PREPARE_OPERATOR_ENV_KEY + namespaceInstallTo, false);
        }
        helmResource.create(extensionContext, operationTimeout, reconciliationInterval);
    } else {
        bundleInstallation();
    }
    return this;
}
Also used : OlmResource(io.strimzi.systemtest.resources.operator.specific.OlmResource) HelmResource(io.strimzi.systemtest.resources.operator.specific.HelmResource) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 HelmResource (io.strimzi.systemtest.resources.operator.specific.HelmResource)2 OlmResource (io.strimzi.systemtest.resources.operator.specific.OlmResource)2