Search in sources :

Example 1 with KubernetesExecutor

use of pipelite.executor.KubernetesExecutor in project pipelite by enasequence.

the class TestType method setNextExitCode.

static void setNextExitCode(TestType testType, Stage stage, StageMapKey key) {
    // Execution count.
    Integer execCount = stageExecCount.get(key);
    if (execCount == null) {
        execCount = 0;
    }
    ++execCount;
    stageExecCount.put(key, execCount);
    // Next exit code.
    String nextExitCode = testType.exitCode(execCount);
    stageNextExitCode.put(key, nextExitCode);
    String pipelineName = key.getPipelineName();
    String processId = key.getProcessId();
    String stageName = key.getStageName();
    if (!nextExitCode.equals("")) {
        if (stage.getExecutor() instanceof KubernetesExecutor) {
            KubernetesExecutor executor = (KubernetesExecutor) stage.getExecutor();
            executor.setImageArgs(testType.nextImageArgs(pipelineName, processId, stageName));
        } else if (stage.getExecutor() instanceof AbstractLsfExecutor<?>) {
            AbstractLsfExecutor<?> executor = (AbstractLsfExecutor<?>) stage.getExecutor();
            executor.setCmd(testType.nextCmd(pipelineName, processId, stageName));
        } else if (stage.getExecutor() instanceof CmdExecutor<?>) {
            CmdExecutor<?> executor = (CmdExecutor<?>) stage.getExecutor();
            executor.setCmd(testType.nextCmd(pipelineName, processId, stageName));
        } else {
            testType.failedAsserts.add("Unexpected executor type when changing executor exit code: " + stage.getExecutor().getClass().getSimpleName());
        }
    }
}
Also used : AbstractLsfExecutor(pipelite.executor.AbstractLsfExecutor) CmdExecutor(pipelite.executor.CmdExecutor) KubernetesExecutor(pipelite.executor.KubernetesExecutor)

Example 2 with KubernetesExecutor

use of pipelite.executor.KubernetesExecutor 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

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