Search in sources :

Example 1 with CCMVersionRequirement

use of com.datastax.oss.dsbulk.tests.ccm.annotations.CCMVersionRequirement in project dsbulk by datastax.

the class CCMExtension method evaluateExecutionCondition.

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
    if (DefaultCCMCluster.CCM_TYPE == DSE && PlatformUtils.isWindows()) {
        return ConditionEvaluationResult.disabled("CCM tests are configured to use DSE which is not compatible with Windows");
    }
    Class<?> testClass = context.getRequiredTestClass();
    CCMRequirements requirements = ReflectionUtils.locateClassAnnotation(testClass, CCMRequirements.class);
    if (requirements != null) {
        if (!Arrays.asList(requirements.compatibleTypes()).contains(DefaultCCMCluster.CCM_TYPE)) {
            return ConditionEvaluationResult.disabled(String.format("Test is not compatible with CCM cluster type in use: %s.", DefaultCCMCluster.CCM_TYPE));
        }
        for (CCMVersionRequirement requirement : requirements.versionRequirements()) {
            if (requirement.type() == DefaultCCMCluster.CCM_TYPE) {
                Version min = requirement.min().isEmpty() ? null : Version.parse(requirement.min());
                Version max = requirement.max().isEmpty() ? null : Version.parse(requirement.max());
                if (!VersionUtils.isWithinRange(DefaultCCMCluster.CCM_VERSION, min, max)) {
                    return ConditionEvaluationResult.disabled(String.format("Test requires version in range [%s,%s[ but %s is configured.", requirement.min(), requirement.max(), DefaultCCMCluster.CCM_VERSION));
                }
            }
        }
    }
    return ConditionEvaluationResult.enabled("OK");
}
Also used : CCMRequirements(com.datastax.oss.dsbulk.tests.ccm.annotations.CCMRequirements) CCMVersionRequirement(com.datastax.oss.dsbulk.tests.ccm.annotations.CCMVersionRequirement) Version(com.datastax.oss.driver.api.core.Version)

Aggregations

Version (com.datastax.oss.driver.api.core.Version)1 CCMRequirements (com.datastax.oss.dsbulk.tests.ccm.annotations.CCMRequirements)1 CCMVersionRequirement (com.datastax.oss.dsbulk.tests.ccm.annotations.CCMVersionRequirement)1