Skip to content

Commit

Permalink
Merge pull request #149 from fabiobrz/fix.missing-factories-and-test
Browse files Browse the repository at this point in the history
[issue 148] - Fixing missing factories and test
  • Loading branch information
marekkopecky authored Feb 20, 2024
2 parents 32d9491 + f30b0fb commit 3cd5bf8
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .ci/openshift-ci/build-root/e2e-test-prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ mvn test -Dmaven.repo.local=./local-repo-prod -pl testsuite/integration-tests -P
-Dintersmash.wildfly.operators.channel=stable \
-Dintersmash.wildfly.operators.index_image='' \
-Dintersmash.wildfly.helm.charts.repo=https://github.com/jbossas/eap-charts.git \
-Dintersmash.wildfly.helm.charts.branch=eap8-1.1.0 \
-Dintersmash.wildfly.helm.charts.branch=eap8-1.1.2 \
-Dintersmash.wildfly.helm.charts.name=eap8 \
-Dintersmash.eap7.image=registry.redhat.io/jboss-eap-7/eap74-openjdk17-openshift-rhel8:latest \
-Dintersmash.eap7.runtime.image=registry.redhat.io/jboss-eap-7/eap74-openjdk17-runtime-openshift-rhel8:latest \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
*/
public abstract class HelmChartOpenShiftProvisioner<A extends HelmChartOpenShiftApplication>
implements OpenShiftProvisioner<A> {
protected static final HelmBinary helmBinary = HelmClients.adminBinary();
private static HelmBinary helmBinary;
protected final A application;
protected FailFastCheck ffCheck = () -> false;

Expand All @@ -69,6 +69,18 @@ public HelmChartOpenShiftProvisioner(@NonNull A application) {
this.application = application;
}

/**
* Lazily initialize the XTF Helm binary client, we prefer this instead of static initialization
* since the latter no cluster interaction should implicitly occur, theoretically.
* @return A static instance of {@link HelmBinary} to execute operations via the Helm CLI.
*/
protected HelmBinary helmBinary() {
if (helmBinary == null) {
helmBinary = HelmClients.adminBinary();
}
return helmBinary;
}

@Override
public A getApplication() {
return application;
Expand All @@ -91,15 +103,15 @@ public void deploy() {
this.getApplication().getHelmChartsRepositoryName(),
this.getApplication().getName()));
}
helmBinary.execute(getHelmChartInstallArguments(this.getApplication(), helmChartsPath));
helmBinary().execute(getHelmChartInstallArguments(this.getApplication(), helmChartsPath));
if (this.getApplication().getRelease().getReplicas() > 0) {
waitForReplicas(this.getApplication().getRelease().getReplicas());
}
}

@Override
public void undeploy() {
helmBinary.execute(getHelmChartUninstallArguments(this.getApplication().getName()));
helmBinary().execute(getHelmChartUninstallArguments(this.getApplication().getName()));
OpenShiftWaiters.get(openShift, ffCheck).areNoPodsPresent("app.kubernetes.io/instance", application.getName())
.level(Level.DEBUG)
.waitFor();
Expand All @@ -114,7 +126,7 @@ public List<Pod> getPods() {
public void scale(int replicas, boolean wait) {
this.getApplication().getRelease().setReplicas(replicas);
final Path helmChartsPath = this.getHelmCharts().get(this.getApplication().getHelmChartsRepositoryName());
helmBinary.execute(getHelmChartUpgradeArguments(this.getApplication(), helmChartsPath));
helmBinary().execute(getHelmChartUpgradeArguments(this.getApplication(), helmChartsPath));
if (wait) {
waitForReplicas(replicas);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (C) 2023 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.intersmash.provision.openshift;

import org.jboss.intersmash.application.Application;
import org.jboss.intersmash.application.openshift.Eap7TemplateOpenShiftApplication;
import org.jboss.intersmash.provision.ProvisionerFactory;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Eap7TemplateOpenShiftProvisionerFactory implements ProvisionerFactory<Eap7TemplateOpenShiftProvisioner> {

@Override
public Eap7TemplateOpenShiftProvisioner getProvisioner(Application application) {
if (Eap7TemplateOpenShiftApplication.class.isAssignableFrom(application.getClass()))
return new Eap7TemplateOpenShiftProvisioner((Eap7TemplateOpenShiftApplication) application);
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (C) 2023 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.intersmash.provision.openshift;

import org.jboss.intersmash.application.Application;
import org.jboss.intersmash.application.openshift.HyperfoilOperatorApplication;
import org.jboss.intersmash.provision.ProvisionerFactory;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class HyperfoilOperatorProvisionerFactory implements ProvisionerFactory<HyperfoilOperatorProvisioner> {

@Override
public HyperfoilOperatorProvisioner getProvisioner(Application application) {
if (HyperfoilOperatorApplication.class.isAssignableFrom(application.getClass()))
return new HyperfoilOperatorProvisioner((HyperfoilOperatorApplication) application);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ org.jboss.intersmash.provision.helm.wildfly.WildflyHelmChartOpenShiftProvisioner
org.jboss.intersmash.provision.openshift.MysqlImageOpenShiftProvisionerFactory
org.jboss.intersmash.provision.openshift.PostgreSQLImageOpenShiftProvisionerFactory
org.jboss.intersmash.provision.openshift.InfinispanOperatorProvisionerFactory
org.jboss.intersmash.provision.openshift.KeycloakOperatorProvisionerFactory
org.jboss.intersmash.provision.openshift.RhSsoOperatorProvisionerFactory
org.jboss.intersmash.provision.openshift.RhSsoTemplateOpenShiftProvisionerFactory
org.jboss.intersmash.provision.openshift.PostgreSQLTemplateOpenShiftProvisionerFactory
org.jboss.intersmash.provision.openshift.Eap7ImageOpenShiftProvisionerFactory
org.jboss.intersmash.provision.openshift.Eap7LegacyS2iBuildTemplateProvisionerFactory
org.jboss.intersmash.provision.openshift.Eap7TemplateOpenShiftProvisionerFactory
org.jboss.intersmash.provision.openshift.HyperfoilOperatorProvisionerFactory

Loading

0 comments on commit 3cd5bf8

Please sign in to comment.