summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-01-20 18:33:48 +0100
committerjonmv <venstad@gmail.com>2023-01-20 18:33:48 +0100
commit366c3561d3bd5df18d4a8e05a80c52f6fc2d7007 (patch)
tree3fa9cc78675d4d87fc8615ed3383a712d26bc14e /controller-server
parent10520a6d082dc309d21f5176b37e3a69cd0217fc (diff)
Also match lists which are the tail of the initial
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/dns/NameServiceQueue.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/NameServiceDispatcherTest.java17
2 files changed, 17 insertions, 2 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/dns/NameServiceQueue.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/dns/NameServiceQueue.java
index 9c1390788ca..dbcfa6705ec 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/dns/NameServiceQueue.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/dns/NameServiceQueue.java
@@ -159,7 +159,7 @@ public record NameServiceQueue(List<NameServiceRequest> requests) {
/** Lowest index {@code i} in {@code list} s.t. {@code list.sublist(i, i + sub.size()).equals(sub)}. Naïve implementation. */
static <T> int indexOf(List<T> list, List<T> sub) {
- for (int i = 0; i + sub.size() < list.size(); i++)
+ for (int i = 0; i + sub.size() <= list.size(); i++)
if (list.subList(i, i + sub.size()).equals(sub))
return i;
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/NameServiceDispatcherTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/NameServiceDispatcherTest.java
index 540511dbc7f..cf5567f5f2f 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/NameServiceDispatcherTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/NameServiceDispatcherTest.java
@@ -66,10 +66,25 @@ class NameServiceDispatcherTest {
var req8 = new CreateRecord(owner0, rec3);
// Queue initially contains a subsequence of requests, 3–6.
- // The dispatch of requests owned by owner1 will fail, so the remaining list is subsequence or the original.
var base = new LinkedList<NameServiceRequest>(List.of(req3, req4, req5, req6));
+
+ // Whole queue is consumed by dispatcher the first time, and a few records prepended.
tester.curator().writeNameServiceQueue(new NameServiceQueue(base));
+ expectations.add(name -> assertEquals(rec1.name(), name));
+ expectations.add(name -> assertEquals(rec4.name(), name));
+ expectations.add(name -> assertEquals(rec3.name(), name));
+ expectations.add(name -> {
+ assertEquals(rec4.name(), name);
+ tester.curator().writeNameServiceQueue(tester.curator().readNameServiceQueue()
+ .with(req1, Priority.high)
+ .with(req2, Priority.high)
+ .with(req1, Priority.high));
+ });
+ assertEquals(1.0, dispatcher.maintain());
+ assertEquals(List.of(req1, req2, req1), tester.curator().readNameServiceQueue().requests());
+ // Now, the dispatch of requests owned by owner1 will fail, so the remaining list is subsequence or the original.
+ tester.curator().writeNameServiceQueue(new NameServiceQueue(base));
AtomicReference<Consumer<RecordName>> failOwner1 = new AtomicReference<>();
failOwner1.set(name -> {
assertEquals(rec4.name(), name);