Skip to content

Commit

Permalink
disable the test only until the Jan 1 2020
Browse files Browse the repository at this point in the history
  • Loading branch information
lanwen committed Dec 2, 2019
1 parent 8f324ed commit 36182cf
Showing 1 changed file with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,30 @@
import org.apache.pulsar.client.api.PulsarClient;
import org.apache.pulsar.client.impl.Murmur3_32Hash;
import org.apache.pulsar.client.util.MathUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.springframework.context.ApplicationContext;
import org.testcontainers.containers.PulsarContainer;
import reactor.core.publisher.Mono;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.platform.commons.support.AnnotationSupport.findAnnotation;

public class PulsarRecordsStorageTest implements RecordStorageTests {

Expand Down Expand Up @@ -82,7 +92,7 @@ public int getNumberOfPartitions() {

@Override
@Test
@Disabled("#180 - Pulsar should fix the way seek works, not disconnecting consumers (apache/pulsar/pull/5022)")
@DisabledUntil(value = "2020-01-01", comment = "#180 - Pulsar should fix the way seek works, not disconnecting consumers (apache/pulsar/pull/5022)")
public void shouldAlwaysUseEarliestOffsetOnEmptyOffsetsInTheInitialProvider() {
}

Expand All @@ -93,7 +103,7 @@ void shouldPreferEventTimeOverPublishTime() throws Exception {
var key = keyByPartition(partition);
var eventTimestamp = Instant.now().minusSeconds(1000).truncatedTo(ChronoUnit.MILLIS);

try(
try (
var pulsarClient = PulsarClient.builder()
.serviceUrl(pulsar.getPulsarBrokerUrl())
.build()
Expand All @@ -117,4 +127,36 @@ var record = subscribeToPartition(partition)
assertThat(it.getTimestamp()).isEqualTo(eventTimestamp);
});
}


@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(DisabledUntil.DisabledCondition.class)
public @interface DisabledUntil {
String value();

String comment();

class DisabledCondition implements ExecutionCondition {

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
Optional<DisabledUntil> until = findAnnotation(context.getElement(), DisabledUntil.class);
if (until.isPresent()
&& until.map(DisabledUntil::value)
.map(date -> LocalDate.parse(date).isAfter(LocalDate.now()))
.orElse(false)
) {
String reason = until.map(DisabledUntil::comment).orElse("Disabled for now");
return ConditionEvaluationResult.disabled(reason);
}

return ConditionEvaluationResult.enabled("Enabled");
}

}

}


}

0 comments on commit 36182cf

Please sign in to comment.