Skip to content

Commit

Permalink
Fixed few non deterministic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yug Vajani committed Nov 7, 2024
1 parent f5d1832 commit b1db605
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
Expand Down Expand Up @@ -878,7 +879,7 @@ public void testInsertTabletsWithSessionBroken() throws StatementExecutionExcept
Tablet tablet2 = new Tablet(allDeviceIds.get(2), schemaList, 100);
Tablet tablet3 = new Tablet(allDeviceIds.get(3), schemaList, 100);

Map<String, Tablet> tabletMap = new HashMap<>();
Map<String, Tablet> tabletMap = new LinkedHashMap<>();
tabletMap.put(allDeviceIds.get(1), tablet1);
tabletMap.put(allDeviceIds.get(2), tablet2);
tabletMap.put(allDeviceIds.get(3), tablet3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -139,16 +141,24 @@ public void testGetAllFileNamesByPath() {
root.setStorageGroup(new PartialPath("root.laptop.d1"));
root.setStorageGroup(new PartialPath("root.laptop.d2"));

final List<PartialPath> list = new ArrayList<>();
List<PartialPath> list1 = Collections.singletonList(new PartialPath("root.laptop.d1"));
assertEquals(
new HashSet<>(list1),
new HashSet<>(root.getBelongedDatabases(new PartialPath("root.laptop.d1.s1"))));
assertEquals(
new HashSet<>(list1),
new HashSet<>(root.getBelongedDatabases(new PartialPath("root.laptop.d1"))));

list.add(new PartialPath("root.laptop.d1"));
assertEquals(list, root.getBelongedDatabases(new PartialPath("root.laptop.d1.s1")));
assertEquals(list, root.getBelongedDatabases(new PartialPath("root.laptop.d1")));
List<PartialPath> list2 =
Arrays.asList(new PartialPath("root.laptop.d1"), new PartialPath("root.laptop.d2"));
assertEquals(
new HashSet<>(list2),
new HashSet<>(root.getBelongedDatabases(new PartialPath("root.laptop.**"))));
assertEquals(
new HashSet<>(list2),
new HashSet<>(root.getBelongedDatabases(new PartialPath("root.**"))));

list.add(new PartialPath("root.laptop.d2"));
assertEquals(list, root.getBelongedDatabases(new PartialPath("root.laptop.**")));
assertEquals(list, root.getBelongedDatabases(new PartialPath("root.**")));
} catch (final MetadataException e) {
} catch (MetadataException e) {
e.printStackTrace();
fail(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,20 @@ public void testPathPatternTreeSplit() throws Exception {
patternTree.appendPathPattern(path);
}
patternTree.constructTree();
List<PartialPath> expectedPatterns =
Arrays.asList(new PartialPath("root.sg1.*.t1.s1"), new PartialPath("root.sg1.d1.t2.s2"));

Assert.assertEquals(
Arrays.asList(new PartialPath("root.sg1.*.t1.s1"), new PartialPath("root.sg1.d1.t2.s2")),
patternTree.getAllPathPatterns());
List<PartialPath> actualPatterns =
patternTree.getAllPathPatterns().stream()
.sorted((p1, p2) -> p1.toString().compareTo(p2.toString()))
.collect(Collectors.toList());

List<PartialPath> sortedExpectedPatterns =
expectedPatterns.stream()
.sorted((p1, p2) -> p1.toString().compareTo(p2.toString()))
.collect(Collectors.toList());

Assert.assertEquals(sortedExpectedPatterns, actualPatterns);
}

@Test
Expand Down

0 comments on commit b1db605

Please sign in to comment.