mirror of https://github.com/dapr/java-sdk.git
Test long vals (#717)
* run IT test for long values Signed-off-by: tanvigour <tanvi.gour@gmail.com> * Fix the class name Signed-off-by: tanvigour <tanvi.gour@gmail.com> * assert for all messages and fix class name Signed-off-by: tanvigour <tanvi.gour@gmail.com> * test for Long.MAX_VALUE Signed-off-by: tanvigour <tanvi.gour@gmail.com> * revert back long number and print Signed-off-by: tanvigour <tanvi.gour@gmail.com> * fix the typo Signed-off-by: tanvigour <tanvi.gour@gmail.com> * update the latest dapr commit in workflow files Signed-off-by: tanvigour <tanvi.gour@gmail.com> * log some more data to debug Signed-off-by: tanvigour <tanvi.gour@gmail.com> * debug Signed-off-by: tanvigour <tanvi.gour@gmail.com> * get the value from messages Signed-off-by: tanvigour <tanvi.gour@gmail.com> * fix long values assert Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> * increasing TTL Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Co-authored-by: tanvigour <tanvi.gour@gmail.com> Co-authored-by: tanvigour <60332928+tanvigour@users.noreply.github.com>
This commit is contained in:
parent
940ee971b0
commit
51878c24b5
|
|
@ -26,6 +26,7 @@ import io.dapr.it.DaprRun;
|
||||||
import io.dapr.serializer.DaprObjectSerializer;
|
import io.dapr.serializer.DaprObjectSerializer;
|
||||||
import io.dapr.utils.TypeRef;
|
import io.dapr.utils.TypeRef;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
|
@ -35,12 +36,13 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static io.dapr.it.Retry.callWithRetry;
|
import static io.dapr.it.Retry.callWithRetry;
|
||||||
import static io.dapr.it.TestUtils.assertThrowsDaprException;
|
import static io.dapr.it.TestUtils.assertThrowsDaprException;
|
||||||
|
|
@ -426,29 +428,27 @@ public class PubSubIT extends BaseIT {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConvertToLong toLong = new ConvertToLong();
|
Random random = new Random(590518626939830271L);
|
||||||
HashSet<ConvertToLong> expected = new HashSet<>();
|
Set<ConvertToLong> values = new HashSet<>();
|
||||||
Random random = new Random();
|
values.add(new ConvertToLong().setVal(590518626939830271L));
|
||||||
Long randomLong = 590518626939830271L;
|
ConvertToLong val;
|
||||||
random.setSeed(randomLong);
|
for (int i = 0; i < NUM_MESSAGES - 1; i++) {
|
||||||
toLong.setValue(randomLong);
|
do {
|
||||||
expected.add(toLong);
|
val = new ConvertToLong().setVal(random.nextLong());
|
||||||
for (int i = 1; i < NUM_MESSAGES; i++) {
|
} while (values.contains(val));
|
||||||
ConvertToLong value = new ConvertToLong();
|
values.add(val);
|
||||||
randomLong = random.nextLong();
|
|
||||||
value.setValue(randomLong);
|
|
||||||
expected.add(value);
|
|
||||||
System.out.println("expected value is : " +value);
|
|
||||||
}
|
}
|
||||||
Iterator expectVal = expected.iterator();
|
Iterator<ConvertToLong> valuesIt = values.iterator();
|
||||||
try (DaprClient client = new DaprClientBuilder().build()) {
|
try (DaprClient client = new DaprClientBuilder().build()) {
|
||||||
while(expectVal.hasNext()) {
|
for (int i = 0; i < NUM_MESSAGES; i++) {
|
||||||
|
ConvertToLong value = valuesIt.next();
|
||||||
|
System.out.println("The long value sent " + value.getValue());
|
||||||
//Publishing messages
|
//Publishing messages
|
||||||
client.publishEvent(
|
client.publishEvent(
|
||||||
PUBSUB_NAME,
|
PUBSUB_NAME,
|
||||||
LONG_TOPIC_NAME,
|
LONG_TOPIC_NAME,
|
||||||
expectVal.next(),
|
value,
|
||||||
Collections.singletonMap(Metadata.TTL_IN_SECONDS, "1")).block();
|
Collections.singletonMap(Metadata.TTL_IN_SECONDS, "30")).block();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep((long) (1000 * Math.random()));
|
Thread.sleep((long) (1000 * Math.random()));
|
||||||
|
|
@ -460,7 +460,7 @@ public class PubSubIT extends BaseIT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet<ConvertToLong> actual = new HashSet<>();
|
Set<ConvertToLong> actual = new HashSet<>();
|
||||||
try (DaprClient client = new DaprClientBuilder().build()) {
|
try (DaprClient client = new DaprClientBuilder().build()) {
|
||||||
callWithRetry(() -> {
|
callWithRetry(() -> {
|
||||||
System.out.println("Checking results for topic " + LONG_TOPIC_NAME);
|
System.out.println("Checking results for topic " + LONG_TOPIC_NAME);
|
||||||
|
|
@ -469,12 +469,12 @@ public class PubSubIT extends BaseIT {
|
||||||
"messages/testinglongvalues",
|
"messages/testinglongvalues",
|
||||||
null,
|
null,
|
||||||
HttpExtension.GET, CLOUD_EVENT_LONG_LIST_TYPE_REF).block();
|
HttpExtension.GET, CLOUD_EVENT_LONG_LIST_TYPE_REF).block();
|
||||||
assertNotNull(messages);
|
Assert.assertNotNull(messages);
|
||||||
for (int i = 0; i < NUM_MESSAGES; i++) {
|
for (CloudEvent<ConvertToLong> message : messages) {
|
||||||
actual.add(messages.get(i).getData());
|
actual.add(message.getData());
|
||||||
}
|
}
|
||||||
assertEquals(expected,actual);
|
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
Assert.assertEquals(values, actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -493,13 +493,15 @@ public class PubSubIT extends BaseIT {
|
||||||
public static class ConvertToLong {
|
public static class ConvertToLong {
|
||||||
private Long value;
|
private Long value;
|
||||||
|
|
||||||
|
public ConvertToLong setVal(Long value) {
|
||||||
|
this.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getValue() {
|
public Long getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(Long value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue