You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

<Work In Progress>


Approach to Integrate ByteBlower with Automatics

Integration Goal

ByteBlower is a network testing tool that helps in testing network devices. Apart from the UI, it exposes a set of Python API’s which can help automation. Our goal is to leverage the API’s exposed by ByteBlower and integrate it with automatics for testing RDKB devices.

API documentation of ByteBlower is available in https://api.byteblower.com/python/

High level Integration approach overview

Configuration of Devices

  • The details of the server and the DUT is configured in Device Manager in Automatics.
  • Ensure that the DUT and the server are mapped to the same account ID and in the same network.     
  • A dedicated infrastructure for the ByteBlower testcases is preferred.

Create a wrapper class to execute the Python scripts.

Jpype framework has to be used to  import all the java dependencies (e.g.: to update the result). When a python test is triggered, the python wrapper class will be executed. Inside the wrapper class we are starting a JVM instance.  The required java dependencies (API’s) to execute the testcase will be imported.

Create a Repository for Byte Blower Testcases

A separate repo will be created for ByteBlower testcases.

There are more than 2500 API’s exposed by ByteBlower. To start with , we will be picking the most relevant or the priority APIs for automation , define a class with methods (testcases), with the API’s that correspond to actual or desired ByteBlower functionality.

 Sample Python file in ByteBlower Repo where the implementations are defined.

   
from byteblowerll.byteblower import ByteBlower

class ByteBlowerImplementation:
    def __init__(self, server_ip):
        self.byteblower_instance = ByteBlower.InstanceGet() or ByteBlower()
        self.server = self.byteblower_instance.ServerAdd(server_ip)

    def start_traffic(self):
        # Start the traffic using Byteblower API
        ByteBlower.SchedulesStart()

    def stop_traffic(self):
        # Stop the traffic using Bytebliower API
        ByteBlower.SchedulesStop()

In the above class, we create a ByteBlower instance and the required ByteBlower APIs are encapsulated. The function internally calls the ScheduleStart() and ScheduleStop() ByteBlower API’s.  All the Byte blower reusable functions will be available present in the above ‘ByteBlowerImplementation’ class.

Writing the testcase

Follow some guidelines while writing the testcase

  1. Import the Byte Blower Implementation class mentioned above.
  2. Separate Python file for test case which can use the functions in the above class.
  3. TestNG annotation should be mentioned above the function with the testcase ID [ e.g.: @TestCaseId('TC-BYTEBLOWER-TRAFFICFLOW-001').
  4. The corresponding wrapper function is invoked for each step and the result should be logged.
  5. When the script is added to automatics, ensure that the Test Script Type is selected as ‘Python’ in “Manage Script” page.

Sample Testcase file.


import ByteBlowerImplementation


@TestCaseId('TC_BYTEBLOWER_TRAFFICFLOW_001')
def testTrafficFlow(dut) :
    start_traffic(dut.getIpaddress)

    stop_traffic(dut.getIPaddress)
   

Dependencies

Since the scripts are written in python, please ensure that the below dependencies are met.

  • The Python version should be between 6 & 3.10.
  • Jpype 1.4.1

Jenkins Configuration

  • Please follow the same as mentioned in Jenkins Job configuration for script execution - RDK - RDK Central Wiki
  • Include ‘pip install byteblowerll’ to access the Byte blower APIs from our script.
  • Include ‘pip install scapy’ if packet capture is required in the testcases.
  • Install Jpype pip install jpype1==1.4.1
  • pip install byteblower_test_framework to access the API’s and for reports.
  • pip install <lib_path>/automaticsPythonLib-0.1-py3-none-any.whl [ Python lib]
  • Install HTML plugin in Jenkins using command line.

 

Executing test case

The test cases can be triggered from automatics just like triggering other Python test cases using trigger the execution “Trigger Execution Manually” option in Manage Test Trigger Tab. Continue with the normal flow of execution by selecting the testcase and devices.

Once the python test is triggered, the python wrapper class will be executed. Inside the wrapper class we are starting a JVM and the required java dependencies will are imported.

Similar to CD-Router, we are planning to include “Byte Blower” field in test type to filter ByteBlower testcases.

Jenkins job: 

On triggering the execution, a Jenkins job will be created, and the test scripts will be executed and logged.

Execution Reports

By default, ByteBlower will generate an HTML and JSON report. If the reports can be copied to Jenkins Artifact folder, then the link can be provided along with the result. If the testcase is just to verify some checkpoint meets some predefined KPI values, or checking any Boolean condition , it can be handled in the code.

Jenkins Steps to upload the ByteBlower report to Jenkins.

  • Add a Post-build Action to your Jenkins job.
  • Choose the Execute shell or Execute Windows batch command option.
  • Write a script to copy the report file from its generated location to the desired Jenkins directory.

Challenges Faced

The following are the challenges faced ( will be updated when a new challenge is faced)

  1. Unable to access the ByteBlower Server using VPN.

Firewall issue : Port number 9002 in the server machine was blocking.(Resolved by raising an IT helpdesk ticket)

  1. When the python version got upgraded, the script failed to execute.

Solution: setx PATH "%PATH%;C:\Users\nidhinrv\AppData\Local\Programs\Python\Python310" [ path is set to 3.10]

  1. Jenkins configuration issues: Testcases are not getting executed though both the repos are cloned. Error : Failed to fetch the device for MAC

 

  • No labels