Skip to content

Commit

Permalink
fix: add surefire plugin to POM (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Mason authored Aug 14, 2023
2 parents 9cf745d + 4438b60 commit 9259c55
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ public class TopicConsumerStats {
private final SynchronizedDescriptiveStatistics historicalTopicRates = new SynchronizedDescriptiveStatistics();
@Getter
@Setter
private long minimumConsumerRateMeasurements;
private double consumerRatePercentile = 99D;
@Getter
@Setter
private double consumerRatePercentile;
private long minimumConsumerRateMeasurements = 3;
@Getter
@Setter
private double topicRatePercentile;
private double topicRatePercentile = 99D;
@Getter
@Setter
private long minimumTopicRateMeasurements;
private long minimumTopicRateMeasurements = 3;

public TopicConsumerStats() {
this(System::currentTimeMillis);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
Expand Down Expand Up @@ -50,6 +52,7 @@
import com.brandwatch.kafka_pod_autoscaler.v1alpha1.kafkapodautoscalerspec.ScaleTargetRef;

@Slf4j
@Timeout(value = 4, unit = TimeUnit.MINUTES)
@Testcontainers(parallel = true)
class KafkaPodAutoscalerIT {
private static final String OPERATOR_NAMESPACE = "system-kpa";
Expand All @@ -60,7 +63,7 @@ class KafkaPodAutoscalerIT {
private static final Map<String, Map<String, LogWatch>> watchLogs = new ConcurrentHashMap<>();

@Container
public static K3sContainer k3s = new K3sContainer(DockerImageName.parse("rancher/k3s:v1.23.17-k3s1"))
public static K3sContainer k3s = new K3sContainer(DockerImageName.parse("rancher/k3s:v1.24.16-k3s1"))
.withNetwork(Network.newNetwork())
.withCopyFileToContainer(
MountableFile.forClasspathResource("/k3s-registries.yaml"),
Expand All @@ -73,7 +76,7 @@ class KafkaPodAutoscalerIT {
.withExposedPorts(KUBE_SECURE_PORT, RANCHER_WEBHOOK_PORT, 5005)
.withLogConsumer(new FileConsumer(Path.of("target/k3s.log")));
@Container
public static final GenericContainer<?> registryContainer = new GenericContainer<>(DockerImageName.parse("registry:2.7.1"))
public static final GenericContainer<?> registryContainer = new GenericContainer<>(DockerImageName.parse("registry:2.8"))
.withEnv("REGISTRY_HTTP_SECRET", "secret")
.withNetwork(k3s.getNetwork())
.withNetworkAliases("registry")
Expand All @@ -86,6 +89,7 @@ class KafkaPodAutoscalerIT {
private static KubernetesClient client;

@BeforeAll
@Timeout(value = 4, unit = TimeUnit.MINUTES)
static void beforeAll() throws Exception {
// Use jib to upload the image to the temp registry
Jib.from(DockerDaemonImage.named(IMAGE_NAME))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void beforeEach() {
scaleTargetRef.setName(DEPLOYMENT_NAME);
var spec = new KafkaPodAutoscalerSpec();
spec.setScaleTargetRef(scaleTargetRef);
spec.setMaxScaleIncrements(100);
kpa = new KafkaPodAutoscaler();
kpa.setMetadata(metadata);
kpa.setSpec(spec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import java.io.IOException;
import java.nio.file.Path;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.testcontainers.containers.Network;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
Expand All @@ -26,10 +28,11 @@

import com.brandwatch.kafka_pod_autoscaler.testing.FileConsumer;

@Testcontainers
@Timeout(value = 4, unit = TimeUnit.MINUTES)
@Testcontainers(parallel = true)
class DeploymentScaledResourceTest {
@Container
public static K3sContainer k3s = new K3sContainer(DockerImageName.parse("rancher/k3s:v1.23.17-k3s1"))
public static K3sContainer k3s = new K3sContainer(DockerImageName.parse("rancher/k3s:v1.24.16-k3s1"))
.withNetwork(Network.newNetwork())
.withCopyFileToContainer(
MountableFile.forClasspathResource("/k3s-registries.yaml"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

public class LagModelTest {
public class TopicConsumerStatsTest {
private static final Instant NOW = Instant.parse("2000-01-02T03:04:05.006Z");
private static final TopicPartition PARTITION_1 = new TopicPartition("topic", 1);
private static final TopicPartition PARTITION_2 = new TopicPartition("topic", 2);
Expand All @@ -29,6 +29,9 @@ public void variousScenarios(List<UpdateCallParameters> updateCalls,
var clock = new AtomicLong(NOW.toEpochMilli());
var stats = new TopicConsumerStats(clock::get);

stats.setMinimumTopicRateMeasurements(0L);
stats.setMinimumConsumerRateMeasurements(0L);

for (var call : updateCalls) {
stats.update(call.replicaCount, call.consumerOffsets, call.topicEndOffsets);
clock.addAndGet(1_000);
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/junit-platform.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
junit.jupiter.execution.timeout.default = 30s

junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = same_thread
junit.jupiter.execution.parallel.mode.classes.default = concurrent

0 comments on commit 9259c55

Please sign in to comment.