Search in sources :

Example 1 with KubernetesDescribeJobsCache

use of pipelite.executor.describe.cache.KubernetesDescribeJobsCache in project pipelite by enasequence.

the class KubernetesDescribeJobsCacheTest method test.

@Test
public void test() {
    KubernetesDescribeJobsCache cache = new KubernetesDescribeJobsCache(Mockito.mock(ServiceConfiguration.class), Mockito.mock(InternalErrorService.class));
    KubernetesExecutorParameters namespace1 = KubernetesExecutorParameters.builder().namespace("1").build();
    KubernetesExecutorParameters namespace2 = KubernetesExecutorParameters.builder().namespace("2").build();
    KubernetesExecutor executor1Namespace1 = new KubernetesExecutor();
    KubernetesExecutor executor2Namespace1 = new KubernetesExecutor();
    KubernetesExecutor executor3Namespace2 = new KubernetesExecutor();
    KubernetesExecutor executor4Namespace1 = new KubernetesExecutor();
    executor1Namespace1.setExecutorParams(namespace1);
    executor2Namespace1.setExecutorParams(namespace1);
    executor3Namespace2.setExecutorParams(namespace2);
    executor4Namespace1.setExecutorParams(namespace1);
    assertThat(cache.getCacheContext(executor1Namespace1).getNamespace()).isEqualTo(namespace1.getNamespace());
    assertThat(cache.getCacheContext(executor2Namespace1).getNamespace()).isEqualTo(namespace1.getNamespace());
    assertThat(cache.getCacheContext(executor3Namespace2).getNamespace()).isEqualTo(namespace2.getNamespace());
    assertThat(cache.getCacheContext(executor4Namespace1).getNamespace()).isEqualTo(namespace1.getNamespace());
    DescribeJobs<String, KubernetesDescribeJobsCache.ExecutorContext> describeJobs1 = cache.getDescribeJobs(executor1Namespace1);
    DescribeJobs<String, KubernetesDescribeJobsCache.ExecutorContext> describeJobs2 = cache.getDescribeJobs(executor2Namespace1);
    DescribeJobs<String, KubernetesDescribeJobsCache.ExecutorContext> describeJobs3 = cache.getDescribeJobs(executor3Namespace2);
    DescribeJobs<String, KubernetesDescribeJobsCache.ExecutorContext> describeJobs4 = cache.getDescribeJobs(executor4Namespace1);
    assertThat(describeJobs1 == describeJobs2).isTrue();
    assertThat(describeJobs1 != describeJobs3).isTrue();
    assertThat(describeJobs1 == describeJobs4).isTrue();
}
Also used : ServiceConfiguration(pipelite.configuration.ServiceConfiguration) KubernetesDescribeJobsCache(pipelite.executor.describe.cache.KubernetesDescribeJobsCache) InternalErrorService(pipelite.service.InternalErrorService) KubernetesExecutorParameters(pipelite.stage.parameters.KubernetesExecutorParameters) KubernetesExecutor(pipelite.executor.KubernetesExecutor) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 ServiceConfiguration (pipelite.configuration.ServiceConfiguration)1 KubernetesExecutor (pipelite.executor.KubernetesExecutor)1 KubernetesDescribeJobsCache (pipelite.executor.describe.cache.KubernetesDescribeJobsCache)1 InternalErrorService (pipelite.service.InternalErrorService)1 KubernetesExecutorParameters (pipelite.stage.parameters.KubernetesExecutorParameters)1