Skip to content

Commit

Permalink
Merge pull request #1839 from HubSpot/get_port_fix
Browse files Browse the repository at this point in the history
Remove sort in getPortByIndex
  • Loading branch information
ssalinas authored Sep 10, 2018
2 parents 3a5291d + 50b304e commit 2c77825
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public Optional<Long> getPortByIndex(int index) {
if (index >= ports.size() || index < 0) {
return Optional.absent();
} else {
Collections.sort(ports); // ports are always in ascending order
return Optional.of(ports.get(index));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,10 @@ public void testGetPortByIndex() throws Exception{
.setName("ports")
.setType(Protos.Value.Type.RANGES)
.setRanges(Protos.Value.Ranges.newBuilder()
.addRange(Protos.Value.Range.newBuilder()
.setBegin(31003)
.setEnd(31004).build())
.addRange(Protos.Value.Range.newBuilder()
.setBegin(31000)
.setEnd(31001).build())
.addRange(
Protos.Value.Range.newBuilder()
.setBegin(31003)
.setEnd(31006).build())
.build()).build();

final SingularityRequest request = new SingularityRequestBuilder("test", RequestType.WORKER).build();
Expand All @@ -299,7 +297,7 @@ public void testGetPortByIndex() throws Exception{
.build();
final SingularityTaskRequest taskRequest = new SingularityTaskRequest(request, deploy, pendingTask);
final SingularityMesosTaskHolder task = builder.buildTask(offerHolder, Collections.singletonList(portsResource), taskRequest, taskResources, executorResources);
assertEquals(31003L, task.getTask().getPortByIndex(2).get().longValue());
assertEquals(31005L, task.getTask().getPortByIndex(2).get().longValue());
}

@Test
Expand Down

0 comments on commit 2c77825

Please sign in to comment.