Skip to content

Commit 76a0e36

Browse files
test: adjust wait times for pfctl rules to read
1 parent 9fdfbab commit 76a0e36

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsFirewallRuleTestCase.inc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class APIModelsFirewallRuleTestCase extends TestCase {
4141

4242
# If pfctl is ready and either no needle was specified or the needle was found, return the output
4343
if ($ready and (!$needle or str_contains($cmd->output, $needle))) {
44+
sleep(1);
4445
return $cmd;
4546
}
4647

@@ -516,6 +517,7 @@ class APIModelsFirewallRuleTestCase extends TestCase {
516517
scheduler: 'FAIRQ',
517518
bandwidth: 100,
518519
bandwidthtype: 'Mb',
520+
async: false,
519521
queue: [
520522
[
521523
'name' => 'TestQueue1',
@@ -550,13 +552,13 @@ class APIModelsFirewallRuleTestCase extends TestCase {
550552
$rule->create(apply: true);
551553

552554
# Ensure the rule with the queue is seen in pfctl
553-
$pfctl = $this->read_pfctl_rules();
555+
$pfctl = $this->read_pfctl_rules(needle: $rule->tracker->value);
554556
$this->assert_str_contains($pfctl->output, 'ridentifier ' . $rule->tracker->value . ' queue TestQueue1');
555557

556558
# Update the rule to use a different queue and ensure it is seen in pfctl
557559
$rule->defaultqueue->value = 'TestQueue2';
558560
$rule->update(apply: true);
559-
$pfctl = $this->read_pfctl_rules();
561+
$pfctl = $this->read_pfctl_rules(needle: $rule->tracker->value);
560562
$this->assert_str_contains($pfctl->output, 'ridentifier ' . $rule->tracker->value . ' queue TestQueue2');
561563

562564
# Delete the rule and ensure the rule referencing the queue no longer exists
@@ -584,6 +586,7 @@ class APIModelsFirewallRuleTestCase extends TestCase {
584586
scheduler: 'FAIRQ',
585587
bandwidth: 100,
586588
bandwidthtype: 'Mb',
589+
async: false,
587590
queue: [
588591
[
589592
'name' => 'TestQueue1',
@@ -619,7 +622,7 @@ class APIModelsFirewallRuleTestCase extends TestCase {
619622
$rule->create(apply: true);
620623

621624
# Ensure the rule with the queue is seen in pfctl
622-
$pfctl = $this->read_pfctl_rules();
625+
$pfctl = $this->read_pfctl_rules(needle: $rule->tracker->value);
623626
$this->assert_str_contains(
624627
$pfctl->output,
625628
'ridentifier ' . $rule->tracker->value . ' queue(TestQueue1, TestQueue2)',
@@ -886,7 +889,7 @@ class APIModelsFirewallRuleTestCase extends TestCase {
886889
$rule->create(apply: true);
887890

888891
# Check pfctl rules and ensure the dnpipe is correctly represented
889-
$pfctl = $this->read_pfctl_rules();
892+
$pfctl = $this->read_pfctl_rules(needle: $rule->tracker->value);
890893
$this->assert_str_contains(
891894
$pfctl->output,
892895
"ridentifier {$rule->tracker->value} dnqueue {$queue->number->value}",
@@ -936,7 +939,7 @@ class APIModelsFirewallRuleTestCase extends TestCase {
936939
$rule->create(apply: true);
937940

938941
# Check pfctl rules and ensure the dnpipe is correctly represented
939-
$pfctl = $this->read_pfctl_rules();
942+
$pfctl = $this->read_pfctl_rules(needle: $rule->tracker->value);
940943
$this->assert_str_contains(
941944
$pfctl->output,
942945
"ridentifier {$rule->tracker->value} dnpipe({$limiter1->number->value}, {$limiter2->number->value})",

0 commit comments

Comments
 (0)