Skip to content

Commit

Permalink
use spring in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cmendesce committed Mar 31, 2024
1 parent 67660ff commit 8ec9661
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
package io.resiliencebench.resources.benchmark;

import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.javaoperatorsdk.operator.junit.AbstractOperatorExtension;
import io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension;
import io.resiliencebench.BenchmarkReconciler;
import io.resiliencebench.ResilienceServiceReconciler;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.event.annotation.BeforeTestClass;

import static org.junit.jupiter.api.Assertions.assertNotNull;

@SpringBootTest
public class BenchmarkE2ETest {

private static final KubernetesClient kubernetesClient = new KubernetesClientBuilder().build();
@BeforeTestClass
public static void setUpClass() {
System.setProperty("AWS_ACCESS_KEY", "test");
System.setProperty("AWS_SECRET_KEY", "test");
}

@Autowired
private BenchmarkReconciler benchmarkReconciler;

@Autowired
private ResilienceServiceReconciler resilienceServiceReconciler;

@BeforeEach
public void setUp() {
if (operator == null) {
operator = LocallyRunOperatorExtension.builder()
.waitForNamespaceDeletion(true)
.oneNamespacePerClass(true)
.withReconciler(resilienceServiceReconciler)
.withReconciler(benchmarkReconciler)
.build();
}
}

@RegisterExtension
static AbstractOperatorExtension operator = LocallyRunOperatorExtension.builder()
.waitForNamespaceDeletion(true)
.oneNamespacePerClass(true)
.withReconciler(new ResilienceServiceReconciler())
.withReconciler(new BenchmarkReconciler(kubernetesClient))
.build();
// @RegisterExtension
static AbstractOperatorExtension operator;

@Test
public void creationTest() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.resiliencebench.resources.scenario;

import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.javaoperatorsdk.operator.junit.AbstractOperatorExtension;
import io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension;
import io.resiliencebench.BenchmarkReconciler;
Expand All @@ -11,22 +9,30 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Map;

import static java.util.concurrent.TimeUnit.MINUTES;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
public class ScenarioE2ETest {

private static final KubernetesClient kubernetesClient = new KubernetesClientBuilder().build();
@Autowired
private static BenchmarkReconciler benchmarkReconciler;

@Autowired
private static ResilienceServiceReconciler resilienceServiceReconciler;

@RegisterExtension
static AbstractOperatorExtension operator = LocallyRunOperatorExtension.builder()
.waitForNamespaceDeletion(false)
.oneNamespacePerClass(true)
.withReconciler(new ResilienceServiceReconciler())
.withReconciler(new BenchmarkReconciler(kubernetesClient))
.withReconciler(resilienceServiceReconciler)
.withReconciler(benchmarkReconciler)
.build();

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@

import io.fabric8.kubernetes.api.model.LabelSelector;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.javaoperatorsdk.operator.junit.AbstractOperatorExtension;
import io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension;
import io.resiliencebench.BenchmarkReconciler;
import io.resiliencebench.ResilienceServiceReconciler;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

public class ResilientServiceE2ETest {

private static final KubernetesClient kubernetesClient = new KubernetesClientBuilder().build();
@Autowired
private static BenchmarkReconciler benchmarkReconciler;

@Autowired
private static ResilienceServiceReconciler resilienceServiceReconciler;

@RegisterExtension
static AbstractOperatorExtension operator = LocallyRunOperatorExtension.builder()
.waitForNamespaceDeletion(false)
.oneNamespacePerClass(true)
.withReconciler(new ResilienceServiceReconciler())
.withReconciler(new BenchmarkReconciler(kubernetesClient))
.withReconciler(resilienceServiceReconciler)
.withReconciler(benchmarkReconciler)
.build();

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.resiliencebench.resources.workload;

import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.javaoperatorsdk.operator.junit.AbstractOperatorExtension;
import io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension;
Expand All @@ -13,18 +11,24 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class WorkloadE2ETest {

private static final KubernetesClient kubernetesClient = new KubernetesClientBuilder().build();
@Autowired
private static BenchmarkReconciler benchmarkReconciler;

@Autowired
private static ResilienceServiceReconciler resilienceServiceReconciler;

@RegisterExtension
static AbstractOperatorExtension operator = LocallyRunOperatorExtension.builder()
.waitForNamespaceDeletion(false)
.oneNamespacePerClass(true)
.withReconciler(new ResilienceServiceReconciler())
.withReconciler(new BenchmarkReconciler(kubernetesClient))
.withReconciler(resilienceServiceReconciler)
.withReconciler(benchmarkReconciler)
.build();

@Test
Expand Down

0 comments on commit 8ec9661

Please sign in to comment.