Skip to content

Commit

Permalink
Merge pull request #191 from fabiobrz/issue-190.infinispan-op-no-cach…
Browse files Browse the repository at this point in the history
…e-service

[issue 190] - Fix InfinispanOperatorProvisionerTest in order not to use .spec.service.type=cache and .spec.autoscale
  • Loading branch information
marekkopecky authored Sep 2, 2024
2 parents e927347 + da20467 commit 9b66020
Showing 1 changed file with 0 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.jboss.intersmash.provision.openshift.InfinispanOperatorProvisioner;
import org.jboss.intersmash.provision.openshift.operator.infinispan.cache.CacheBuilder;
import org.jboss.intersmash.provision.openshift.operator.infinispan.infinispan.InfinispanBuilder;
import org.jboss.intersmash.provision.openshift.operator.infinispan.infinispan.spec.AutoscaleBuilder;
import org.jboss.intersmash.provision.openshift.operator.infinispan.infinispan.spec.InfinispanServiceSpecBuilder;
import org.jboss.intersmash.provision.openshift.operator.resources.OperatorGroup;
import org.junit.jupiter.api.AfterAll;
Expand Down Expand Up @@ -166,60 +165,6 @@ public void testMinimalTwoReplicasInfinispan() {
}
}

/**
* This test case creates and validates a basic {@link Infinispan} CR, configured for using Cache service type
* explicitly
*
* This is not an integration test, the goal here is to assess that the created CRs are configured as per the
* model specification.
*/
@Test
public void testMinimalTwoReplicasCacheServiceInfinispan() {
INFINISPAN_OPERATOR_PROVISIONER.subscribe();
try {
name = "example-infinispan";
Infinispan infinispan = new InfinispanBuilder(name, matchLabels)
.replicas(2)
.service(new InfinispanServiceSpecBuilder().type(Service.Type.Cache)
.build())
.build();

verifyMinimalTwoReplicasInfinispan(infinispan, true);
} finally {
INFINISPAN_OPERATOR_PROVISIONER.unsubscribe();
}
}

/**
* This test case creates and validates a basic {@link Infinispan} CR, configured for using Cache service type
* and autoscale functionality
*
* This is not an integration test, the goal here is to assess that the created CRs are configured as per the
* model specification.
*/
@Test
public void testMinimalCacheServiceInfinispanWithAutoscale() {
INFINISPAN_OPERATOR_PROVISIONER.subscribe();
try {
name = "example-infinispan";
Infinispan infinispan = new InfinispanBuilder(name, matchLabels)
.replicas(2)
.service(new InfinispanServiceSpecBuilder()
.type(Service.Type.Cache)
.build())
.autoscale(new AutoscaleBuilder()
.maxReplicas(5)
.maxMemUsagePercent(70L)
.minReplicas(2)
.minMemUsagePercent(30L).build())
.build();

verifyMinimalCacheServiceInfinispanWithAutoscale(infinispan, true);
} finally {
INFINISPAN_OPERATOR_PROVISIONER.unsubscribe();
}
}

/**
* This test case creates and validates a basic {@link Infinispan} CR, configured for using DataGrid service type
* and a cache secret
Expand Down Expand Up @@ -379,24 +324,6 @@ private void verifyMinimalTwoReplicasInfinispan(Infinispan infinispan, boolean w
deleteAndVerifyMinimalInfinispan(waitForPods);
}

/**
* Verify that two replicas are up and running and that have the relevant properties set to the same values
*/
private void verifyMinimalCacheServiceInfinispanWithAutoscale(Infinispan infinispan, boolean waitForPods) {
createAndVerifyInfinispan(infinispan);
if (waitForPods) {
// a correct number of Infinispan CRs has been created
new SimpleWaiter(
() -> InfinispanOperatorProvisioner.getInfinispanPods(name).size() == infinispan.getSpec().getReplicas())
.level(Level.DEBUG).waitFor();
log.debug(INFINISPAN_OPERATOR_PROVISIONER.infinispansClient().withName(name).get().getStatus().toString());
}
assertMinimalInfinispanWithAutoscaleCreation(infinispan);

// delete and verify that object was removed
deleteAndVerifyMinimalInfinispan(waitForPods);
}

/**
* Verify that two replicas are up and running and that have the relevant properties set to the same values
*/
Expand All @@ -409,38 +336,6 @@ private void verifyCacheWithBasicSecretFromTemplate(Cache cache, boolean waitFor
deleteAndVerifyCache(waitForPods);
}

/**
* Minimal setup + autoscale verification involves: <br>
* - the created Infinispan .metadata.name == the CRD .metadata.name <br>
* - the created Infinispan .spec.replicas == the CRD .spec.replicas <br>
* - the created Infinispan .spec.autoscale properties == the CRD .spec.autoscale properties
*
* Created Infinispan .spec.autoscale and CRD .spec aren't equal because aggregated props are null in CRD .spec.autoscale
*
* @param infinispan the Infinispan resource which configuration has to be verified
*/
private void assertMinimalInfinispanWithAutoscaleCreation(Infinispan infinispan) {
Assertions.assertEquals(infinispan.getMetadata().getName(),
INFINISPAN_OPERATOR_PROVISIONER.infinispansClient().withName(name).get().getMetadata().getName());
Assertions.assertEquals(infinispan.getSpec().getReplicas(),
INFINISPAN_OPERATOR_PROVISIONER.infinispansClient().withName(name).get().getSpec().getReplicas());
Assertions.assertEquals(infinispan.getSpec().getService().getType(),
INFINISPAN_OPERATOR_PROVISIONER.infinispansClient().withName(name).get().getSpec().getService().getType());
Assertions.assertEquals(infinispan.getSpec().getAutoscale().getMaxReplicas(),
INFINISPAN_OPERATOR_PROVISIONER.infinispansClient().withName(name).get().getSpec().getAutoscale()
.getMaxReplicas());
Assertions.assertEquals(infinispan.getSpec().getAutoscale().getMaxMemUsagePercent(),
INFINISPAN_OPERATOR_PROVISIONER.infinispansClient().withName(name).get().getSpec().getAutoscale()
.getMaxMemUsagePercent());
Assertions.assertEquals(infinispan.getSpec().getAutoscale().getMinReplicas(),
INFINISPAN_OPERATOR_PROVISIONER.infinispansClient().withName(name).get().getSpec().getAutoscale()
.getMinReplicas());
Assertions.assertEquals(infinispan.getSpec().getAutoscale().getMinMemUsagePercent(),
INFINISPAN_OPERATOR_PROVISIONER.infinispansClient().withName(name).get().getSpec().getAutoscale()
.getMinMemUsagePercent());
// NOTE: created Infinispan .spec.autoscale and CRD .spec.autoscale aren't equal because aggregated props are null in CRD .spec
}

/**
* Minimal setup verification involves: <br>
* - the created Infinispan .metadata.name == the CRD .metadata.name <br>
Expand Down

0 comments on commit 9b66020

Please sign in to comment.