aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--resources/libraries/python/VPPUtil.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py
index 9d2a2b9dd3..3714d3b780 100644
--- a/resources/libraries/python/VPPUtil.py
+++ b/resources/libraries/python/VPPUtil.py
@@ -12,9 +12,12 @@
# limitations under the License.
"""VPP util library."""
+
+import time
+
from resources.libraries.python.constants import Constants
from resources.libraries.python.DUTSetup import DUTSetup
-from resources.libraries.python.ssh import exec_cmd_no_error
+from resources.libraries.python.ssh import exec_cmd, exec_cmd_no_error
from resources.libraries.python.topology import NodeType
from resources.libraries.python.VatExecutor import VatExecutor
@@ -52,14 +55,27 @@ class VPPUtil(object):
exec_cmd_no_error(node, command, timeout=30, sudo=True)
@staticmethod
- def start_vpp_service(node):
+ def start_vpp_service(node, retries=60):
"""Start VPP service on the specified node.
:param node: VPP node.
+ :param retries: Number of times (default 60) to re-try waiting.
:type node: dict
+ :type retries: int
:raises RuntimeError: If VPP service fails to start.
"""
DUTSetup.start_service(node, Constants.VPP_UNIT)
+ # Sleep 1 second, up to <retry> times,
+ # and verify if VPP is running.
+ for _ in range(retries):
+ time.sleep(1)
+ command = 'vppctl show pci'
+ ret, stdout, _ = exec_cmd(node, command, timeout=30, sudo=True)
+ if not ret and 'Connection refused' not in stdout:
+ break
+ else:
+ raise RuntimeError('VPP failed to start on host {name}'.
+ format(name=node['host']))
DUTSetup.get_service_logs(node, Constants.VPP_UNIT)
@staticmethod
@@ -69,7 +85,9 @@ class VPPUtil(object):
:param nodes: Nodes in the topology.
:type nodes: dict
"""
- DUTSetup.start_service_on_all_duts(nodes, Constants.VPP_UNIT)
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ VPPUtil.start_vpp_service(node)
@staticmethod
def stop_vpp_service(node):
@@ -88,7 +106,9 @@ class VPPUtil(object):
:param nodes: Nodes in the topology.
:type nodes: dict
"""
- DUTSetup.stop_service_on_all_duts(nodes, Constants.VPP_UNIT)
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ VPPUtil.stop_vpp_service(node)
@staticmethod
def verify_vpp_on_dut(node):
@@ -111,9 +131,8 @@ class VPPUtil(object):
"""
for node in nodes.values():
if node['type'] == NodeType.DUT:
- DUTSetup.start_service(node, Constants.VPP_UNIT)
- VPPUtil.vpp_show_version_verbose(node)
- VPPUtil.vpp_show_interfaces(node)
+ VPPUtil.start_vpp_service(node)
+ VPPUtil.verify_vpp_on_dut(node)
@staticmethod
def vpp_show_version_verbose(node):
id='n389' href='#n389'>389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596