Search in sources :

Example 6 with CollectorElement

use of io.strimzi.test.logs.CollectorElement in project strimzi-kafka-operator by strimzi.

the class TestExecutionWatcher method handleAfterEachMethodExecutionException.

@Override
public void handleAfterEachMethodExecutionException(ExtensionContext extensionContext, Throwable throwable) throws Throwable {
    LOGGER.error("{} - Exception {} has been thrown in @AfterEach. Going to collect logs from components.", extensionContext.getRequiredTestClass().getSimpleName(), throwable.getMessage());
    if (!(throwable instanceof KubernetesClusterUnstableException)) {
        final String testClass = extensionContext.getRequiredTestClass().getName();
        final String testMethod = extensionContext.getRequiredTestMethod().getName();
        collectLogs(extensionContext, new CollectorElement(testClass, testMethod));
    }
    throw throwable;
}
Also used : KubernetesClusterUnstableException(io.strimzi.systemtest.exceptions.KubernetesClusterUnstableException) CollectorElement(io.strimzi.test.logs.CollectorElement)

Example 7 with CollectorElement

use of io.strimzi.test.logs.CollectorElement in project strimzi by strimzi.

the class TestSuiteNamespaceManager method deleteAdditionalNamespaces.

public void deleteAdditionalNamespaces(ExtensionContext extensionContext) {
    CollectorElement collectorElement = CollectorElement.createCollectorElement(extensionContext.getRequiredTestClass().getName());
    if (KubeClusterResource.getMapWithSuiteNamespaces().get(collectorElement) != null) {
        Set<String> namespacesToDelete = new HashSet<>(KubeClusterResource.getMapWithSuiteNamespaces().get(collectorElement));
        // delete namespaces for specific test suite (we can not delete in parallel because of ConcurrentModificationException)
        namespacesToDelete.forEach(ns -> {
            if (!ns.equals(Constants.INFRA_NAMESPACE)) {
                KubeClusterResource.getInstance().deleteNamespace(collectorElement, ns);
            }
        });
    }
}
Also used : CollectorElement(io.strimzi.test.logs.CollectorElement) HashSet(java.util.HashSet)

Example 8 with CollectorElement

use of io.strimzi.test.logs.CollectorElement in project strimzi by strimzi.

the class TestExecutionWatcher method handleAfterAllMethodExecutionException.

@Override
public void handleAfterAllMethodExecutionException(ExtensionContext extensionContext, Throwable throwable) throws Throwable {
    LOGGER.error("{} - Exception {} has been thrown in @AfterAll. Going to collect logs from components.", extensionContext.getRequiredTestClass().getSimpleName(), throwable.getMessage());
    if (!(throwable instanceof KubernetesClusterUnstableException)) {
        final String testClass = extensionContext.getRequiredTestClass().getName();
        SuiteThreadController suiteThreadController = SuiteThreadController.getInstance();
        if (StUtils.isParallelSuite(extensionContext)) {
            suiteThreadController.notifyParallelSuiteToAllowExecution(extensionContext);
            suiteThreadController.removeParallelSuite(extensionContext);
        }
        if (StUtils.isIsolatedSuite(extensionContext)) {
            suiteThreadController.unLockIsolatedSuite();
        }
        collectLogs(extensionContext, new CollectorElement(testClass));
    }
    throw throwable;
}
Also used : KubernetesClusterUnstableException(io.strimzi.systemtest.exceptions.KubernetesClusterUnstableException) SuiteThreadController(io.strimzi.systemtest.parallel.SuiteThreadController) CollectorElement(io.strimzi.test.logs.CollectorElement)

Example 9 with CollectorElement

use of io.strimzi.test.logs.CollectorElement in project strimzi-kafka-operator by strimzi.

the class TestExecutionWatcher method handleTestExecutionException.

@Override
public void handleTestExecutionException(ExtensionContext extensionContext, Throwable throwable) throws Throwable {
    LOGGER.error("{} - Exception {} has been thrown in @Test. Going to collect logs from components.", extensionContext.getRequiredTestClass().getSimpleName(), throwable.getMessage());
    if (!(throwable instanceof TestAbortedException || throwable instanceof KubernetesClusterUnstableException)) {
        final String testClass = extensionContext.getRequiredTestClass().getName();
        final String testMethod = extensionContext.getRequiredTestMethod().getName();
        collectLogs(extensionContext, new CollectorElement(testClass, testMethod));
    }
    throw throwable;
}
Also used : KubernetesClusterUnstableException(io.strimzi.systemtest.exceptions.KubernetesClusterUnstableException) TestAbortedException(org.opentest4j.TestAbortedException) CollectorElement(io.strimzi.test.logs.CollectorElement)

Example 10 with CollectorElement

use of io.strimzi.test.logs.CollectorElement in project strimzi-kafka-operator by strimzi.

the class TestExecutionWatcher method handleAfterAllMethodExecutionException.

@Override
public void handleAfterAllMethodExecutionException(ExtensionContext extensionContext, Throwable throwable) throws Throwable {
    LOGGER.error("{} - Exception {} has been thrown in @AfterAll. Going to collect logs from components.", extensionContext.getRequiredTestClass().getSimpleName(), throwable.getMessage());
    if (!(throwable instanceof KubernetesClusterUnstableException)) {
        final String testClass = extensionContext.getRequiredTestClass().getName();
        SuiteThreadController suiteThreadController = SuiteThreadController.getInstance();
        if (StUtils.isParallelSuite(extensionContext)) {
            suiteThreadController.notifyParallelSuiteToAllowExecution(extensionContext);
            suiteThreadController.removeParallelSuite(extensionContext);
        }
        if (StUtils.isIsolatedSuite(extensionContext)) {
            suiteThreadController.unLockIsolatedSuite();
        }
        collectLogs(extensionContext, new CollectorElement(testClass));
    }
    throw throwable;
}
Also used : KubernetesClusterUnstableException(io.strimzi.systemtest.exceptions.KubernetesClusterUnstableException) SuiteThreadController(io.strimzi.systemtest.parallel.SuiteThreadController) CollectorElement(io.strimzi.test.logs.CollectorElement)

Aggregations

CollectorElement (io.strimzi.test.logs.CollectorElement)12 KubernetesClusterUnstableException (io.strimzi.systemtest.exceptions.KubernetesClusterUnstableException)10 TestAbortedException (org.opentest4j.TestAbortedException)6 SuiteThreadController (io.strimzi.systemtest.parallel.SuiteThreadController)2 HashSet (java.util.HashSet)2