Skip to content

Commit 53eac62

Browse files
committed
[main] Fix history absence tests.
1 parent f82d352 commit 53eac62

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

interop/servers/openrtrd.pl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ sub write_state
432432
stop_server($pids);
433433
}
434434

435+
# Reset on absence of history.
435436
{
436437
my $pids = start_server();
437438

@@ -455,9 +456,7 @@ sub write_state
455456
$client->reset();
456457

457458
# openrtrd retains only 10 history entries, so adding 13 here will
458-
# mean that the client can't refresh. (The check below assumes
459-
# that this is what happens, which is the case at the moment at
460-
# least, but the test could be more robust.)
459+
# mean that the client can't refresh.
461460
my $common = "0.0.0/24 maxlen 32 source-as 4608 expires $expiry";
462461
my @current = (
463462
"1.$common",
@@ -475,15 +474,22 @@ sub write_state
475474
write_state($state);
476475
sleep(0.25);
477476
}
478-
477+
478+
my $got_reset = 0;
479+
$client->{'pdu_cb'} = sub {
480+
my ($pdu) = @_;
481+
if ($pdu->type() == PDU_CACHE_RESET()) {
482+
$got_reset = 1;
483+
}
484+
};
479485
eval {
480486
$client->refresh(1);
481487
};
482488
my $error = $@;
483-
if (not $error) {
489+
if (not $error and $got_reset) {
484490
print "$preamble,reset_on_absence_of_history,success\n";
485491
} else {
486-
warn "$error";
492+
warn "$error, '$got_reset'";
487493
print "$preamble,reset_on_absence_of_history,failure\n";
488494
}
489495

interop/servers/rtrtr.pl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,7 @@
326326
$client->reset();
327327

328328
# rtrtr retains only 10 history entries, so adding 13 here will
329-
# mean that the client can't refresh. (The check below assumes
330-
# that this is what happens, which is the case at the moment at
331-
# least, but the test could be more robust.)
329+
# mean that the client can't refresh.
332330
for my $i (3..15) {
333331
my $changeset = APNIC::RPKI::RTR::Changeset->new();
334332
my $pdu =
@@ -347,14 +345,21 @@
347345
sleep(2);
348346
}
349347
sleep(2);
348+
my $got_reset = 0;
349+
$client->{'pdu_cb'} = sub {
350+
my ($pdu) = @_;
351+
if ($pdu->type() == PDU_CACHE_RESET()) {
352+
$got_reset = 1;
353+
}
354+
};
350355
eval {
351356
$client->refresh(1);
352357
};
353358
$error = $@;
354-
if (not $error) {
359+
if (not $error and $got_reset) {
355360
print "$preamble,reset_on_absence_of_history,success\n";
356361
} else {
357-
warn "$error";
362+
warn "$error, '$got_reset'";
358363
print "$preamble,reset_on_absence_of_history,failure\n";
359364
}
360365

0 commit comments

Comments
 (0)