Skip to content
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
Expand Up @@ -12,13 +12,11 @@
*/
package io.dapr.durabletask;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.io.IOException;
import java.time.Duration;
Expand All @@ -42,11 +40,13 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* These integration tests are designed to exercise the core, high-level features of
Expand Down Expand Up @@ -118,11 +118,11 @@ void singleTimer() throws IOException, TimeoutException {
assertEquals(2, counter.get());

// Verify that each timer is the expected length
int[] secondsElapsed = new int[1];
long[] millisElapsed = new long[1];
for (int i = 0; i < timestamps.length() - 1; i++) {
secondsElapsed[i] = timestamps.get(i + 1).getSecond() - timestamps.get(i).getSecond();
millisElapsed[i] = Duration.between(timestamps.get(i), timestamps.get(i + 1)).toMillis();
}
assertEquals(3, secondsElapsed[0]);
assertEquals(3000, millisElapsed[0], 50);

}
}
Expand Down Expand Up @@ -163,19 +163,17 @@ void loopWithTimer() throws IOException, TimeoutException {
assertEquals(3, counter.get());

// Verify that each timer is the expected length
int[] secondsElapsed = new int[timestamps.length()];
long[] millisElapsed = new long[timestamps.length()];
for (int i = 0; i < timestamps.length() - 1; i++) {
if (timestamps.get(i + 1) != null && timestamps.get(i) != null) {
secondsElapsed[i] = timestamps.get(i + 1).getSecond() - timestamps.get(i).getSecond();
millisElapsed[i] = Duration.between(timestamps.get(i), timestamps.get(i + 1)).toMillis();
} else {
secondsElapsed[i] = -1;
millisElapsed[i] = -1;
}
}
assertEquals(2, secondsElapsed[0]);
assertEquals(2, secondsElapsed[1]);
assertEquals(-1, secondsElapsed[2]);


assertEquals(2000, millisElapsed[0], 50);
assertEquals(2000, millisElapsed[1], 50);
assertEquals(-1, millisElapsed[2]);
}
}

Expand All @@ -195,7 +193,6 @@ void loopWithWaitForEvent() throws IOException, TimeoutException {
timestamps.set(counter.get(), LocalDateTime.now());
counter.incrementAndGet();
}

}
}
})
Expand All @@ -218,18 +215,20 @@ void loopWithWaitForEvent() throws IOException, TimeoutException {
assertEquals(4, counter.get());

// Verify that each timer is the expected length
int[] secondsElapsed = new int[timestamps.length()];
long[] millisElapsed = new long[timestamps.length()];
for (int i = 0; i < timestamps.length() - 1; i++) {
if (timestamps.get(i + 1) != null && timestamps.get(i) != null) {
secondsElapsed[i] = timestamps.get(i + 1).getSecond() - timestamps.get(i).getSecond();
millisElapsed[i] =
java.time.Duration.between(timestamps.get(i), timestamps.get(i + 1)).toMillis();
} else {
secondsElapsed[i] = -1;
millisElapsed[i] = -1;
}
}
assertEquals(2, secondsElapsed[0]);
assertEquals(2, secondsElapsed[1]);
assertEquals(2, secondsElapsed[2]);
assertEquals(0, secondsElapsed[3]);

assertEquals(2000, millisElapsed[0], 50);
assertEquals(2000, millisElapsed[1], 50);
assertEquals(2000, millisElapsed[2], 50);
assertEquals(0, millisElapsed[3]);


}
Expand Down Expand Up @@ -269,13 +268,13 @@ void longTimer() throws TimeoutException {
assertEquals(4, counter.get());

// Verify that each timer is the expected length
int[] secondsElapsed = new int[3];
long[] millisElapsed = new long[3];
for (int i = 0; i < timestamps.length() - 1; i++) {
secondsElapsed[i] = timestamps.get(i + 1).getSecond() - timestamps.get(i).getSecond();
millisElapsed[i] = Duration.between(timestamps.get(i), timestamps.get(i + 1)).toMillis();
}
assertEquals(secondsElapsed[0], 3);
assertEquals(secondsElapsed[1], 3);
assertEquals(secondsElapsed[2], 1);
assertEquals(3000, millisElapsed[0], 50);
assertEquals(3000, millisElapsed[1], 50);
assertEquals(1000, millisElapsed[2], 50);
}
}

Expand Down
Loading