Skip to content

Commit

Permalink
src/test/.../e2e: add cluster variant
Browse files Browse the repository at this point in the history
  • Loading branch information
ansarhun committed Jun 27, 2024
1 parent f51812c commit 19b5067
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public class Versions {
public static String K3S_VERSION = "rancher/k3s:v1.30.1-k3s1";
public static String MINIO_VERSION = "bitnami/minio:2024.5.10";
public static String RESTIC_VERSION = "restic/restic:0.16.4";
public static String HELM_VERSION = "alpine/helm:3.15.2";

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public abstract class TestProvisioning {
@Container
protected static final K3sContainer K3S_CONTAINER =
new K3sContainer(DockerImageName.parse(Versions.K3S_VERSION))
.withCreateContainerCmdModifier(cmd -> cmd.withHostName("k3s"))
.withNetworkAliases("k3s")
.withNetwork(network);

@Container
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.github.ansarhun.resticvolumepopulator.e2e;

import com.github.ansarhun.resticvolumepopulator.Versions;
import org.junit.jupiter.api.BeforeAll;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.startupcheck.OneShotStartupCheckStrategy;
import org.testcontainers.images.builder.Transferable;
import org.testcontainers.utility.DockerImageName;

import java.time.Duration;

public class TestProvisioningCluster extends TestProvisioning {

@BeforeAll
static void beforeAll() {
try (GenericContainer<?> helmContainer = new GenericContainer<>(DockerImageName.parse(Versions.HELM_VERSION))) {
helmContainer.withNetwork(network);

helmContainer.withCopyToContainer(
Transferable.of(K3S_CONTAINER.generateInternalKubeConfigYaml("k3s")),
"/root/.kube/config"
);

helmContainer.withCommand("install --wait restic-volume-populator oci://ghcr.io/ansarhun/charts/restic-volume-populator --version v0.2.0");

helmContainer.withStartupCheckStrategy(
new OneShotStartupCheckStrategy().withTimeout(Duration.ofSeconds(30))
);

helmContainer.start();

System.out.println("-------------------------------------");
System.out.println("Executed helm");
System.out.println(helmContainer.getLogs());
System.out.println("-------------------------------------");
}
}

}

0 comments on commit 19b5067

Please sign in to comment.