Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable testScheduleCleanup_WithScheduledExecutor_UsingMultipleConcurrentCleaners_IntegrationTest on all platforms #554

Merged
merged 2 commits into from
Apr 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.kiwiproject.dropwizard.config;

import static com.google.common.base.Preconditions.checkState;
import static org.apache.commons.lang3.SystemUtils.IS_OS_MAC;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.SoftAssertions.assertSoftly;
import static org.awaitility.Awaitility.await;
Expand All @@ -26,11 +27,10 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.kiwiproject.base.DefaultEnvironment;
import org.kiwiproject.dropwizard.metrics.health.TimeBasedDirectoryCleanerHealthCheck;
import org.kiwiproject.io.TimeBasedDirectoryCleaner;
import org.kiwiproject.io.TimeBasedDirectoryCleanerTestHelper;
Expand Down Expand Up @@ -136,7 +136,6 @@ private void shutdownAndAwaitTermination(ScheduledExecutorService executorServic
*/
@ParameterizedTest
@ValueSource(ints = { 500, 2000 })
@EnabledOnOs(OS.LINUX)
void testScheduleCleanup_WithScheduledExecutor_UsingMultipleConcurrentCleaners_IntegrationTest(int totalFileCount) throws InterruptedException {
assertThat(TimeBasedDirectoryCleaner.capacityOfRecentDeleteErrors())
.describedAs("Assumption of cleaner error queue capacity of 500 is invalid; @ValueSource values need to be adjusted")
Expand All @@ -155,6 +154,7 @@ void testScheduleCleanup_WithScheduledExecutor_UsingMultipleConcurrentCleaners_I
testHelper.createDirectoriesWithFiles(1, 100);

var cleaner1 = cleanerConfig.scheduleCleanupUsing(executorService1);
addDelayOnMacOS();
var cleaner2 = cleanerConfig.scheduleCleanupUsing(executorService2);

testHelper.createDirectoriesWithFiles(101, 200);
Expand Down Expand Up @@ -185,6 +185,13 @@ void testScheduleCleanup_WithScheduledExecutor_UsingMultipleConcurrentCleaners_I
}
}

private static void addDelayOnMacOS() {
// Add a slight delay on macOS to avoid the issues seen in #143
if (IS_OS_MAC) {
new DefaultEnvironment().sleepQuietly(400);
}
}

private void waitUntilReachExpectedDeleteCount(TimeBasedDirectoryCleaner cleaner1,
TimeBasedDirectoryCleaner cleaner2,
int expectedDeleteCount) {
Expand Down