Rate This Document
Findability
Accuracy
Completeness
Readability

Sample Code for GitLab Pipeline Compatibility Testing

Before running the Compatibility Testing tool, you need to set related parameters.

  1. Set the tool parameters.

    To run the tool, you need to set parameters in the installation directory ${HOME}/.local/compatibility_testing/Chinese/compatibility_testing.conf.

    vim ${HOME}/.local/compatibility_testing/Chinese/compatibility_testing.conf

    File content:

    ##################################################################################
    # Function description: A metric and log collection tool used for compatibility and performance tests.
    # Version: Huawei Technologies Co., Ltd., Copyright (C) 2020-2024
    # Change history: updated on 2024-08-31
    # Usage: Before performing automatic collection, configure compatibility_testing.conf.
    #         In application_names, enter the name of the application to be tested.
    #         In start_app_commands, set the command for starting the application to be tested.
    #         In stop_app_commands, set the command for stopping the application to be tested.
    #         In start_performance_scripts, set the command for starting the stress test tool of the application to be tested.
    #         Confirm the settings.
    #         On the CentOS, NeoKylin, SUSE, or openEuler OS, run sh compatibility_testing.sh as the root user.
    #         On the Ubuntu, Kylin, or UOS OS, run bash compatibility_testing.sh as the root user.
    #         For multi-node cluster deployment, configure password-free SSH access from each node to itself and all other nodes. Then run the script on the controller node (master node).
    ###################################################################################
     
    # Process name of the application to be tested.
    # You can use the ps or docker top command to find the background process name in the CMD column. In a Kubernetes cluster environment, specify the pod name.
    application_names=test_app
    # Command for starting the application to be tested.
    start_app_commands=nohup python3 /root/test/test_app.py &
    # No-load collection time (minutes).
    idle_performance_time=1
    # Command for stopping the application to be tested.
    stop_app_commands=
    # Command for starting the stress test tool of the application to be tested.
    start_performance_scripts=
    # Running time (minutes) of the stress test tool for the application to be tested.
    start_performance_time=
    # For a Kubernetes cluster, enter Y. In other environments, this parameter can be left blank.
    kubernetes_env=
    # For multi-node cluster deployment, fill in the information as required, which is not required for single-node deployment.
    # List of IP addresses in the cluster. Use commas (,) to separate IP addresses from each other. Do not add the IP address of the server where the current script is located.
    cluster_ip_lists=
    # The following information is required for a Validated certification test. It is not required for a Compatible certification test.
    # Directories for CVE vulnerability scanning, separated by commas (,). This parameter is not required for a Validated certification test, as it uses its own CVE vulnerability scanning tool.
    # In a cluster environment, for servers other than the one where the current script is running, specify the directory in the format IP_address:Directory, for example, 192.168.2.2:/root/tomcat.
    cve_scan_path=
    # Directories for ClamAV virus scanning, separated by commas (,). This parameter is not required for a Validated certification test, as it uses its own commercial antivirus software.
    # In a cluster environment, for servers other than the one where the current script is running, specify the directory in the format IP_address:Directory, for example, 192.168.2.2:/root/tomcat.
    clamav_scan_path=
    # The following information is required for HPC application solution certification. For HPC application tests, enter Y. For other application certification tests, leave this parameter blank.
    hpc_certificate=
    # The following information is required for C/C++. Enter the absolute path to the binary file of the application to be tested.
    binary_file=

    In the example, the application process name is test_app and the startup command is nohup python3 /root/test/test_app.py &. Replace them with the actual ones.

  2. Run the Compatibility Testing tool.
    ${HOME}/.local/compatibility_testing/bin/compatibility_test
    • In the test report, the result of the Reliability_Exception_Kill test item may be empty, which is normal.
    • During the startup of compatibility_test, it is normal if the following log messages are displayed.
      1. The log file data/test/performance/test_perf_cpu_1.log does not exist in the data directory.
      2. The log file data/test/performance/test_perf_disk_1.log does not exist in the data directory.
      3. The log file data/test/performance/test_perf_mem_1.log does not exist in the data directory.
      4. The log file data/test/performance/test_perf_net_1.log does not exist in the data directory.
  3. View the result. Check whether a new HTML file is generated in the ${HOME}/.local/compatibility_testing/ directory. If a new HTML file is generated, the Compatibility Testing tool has run successfully.
  4. Run the GitLab pipeline task based on the sample code.

    The sample code is as follows:

    stages:          # List of stages for jobs, and their order of execution
      - build
      - test
      - deploy
    build-job:       # This job runs in the build stage, which runs first.
      stage: test
      tags:
        - kunpeng_executor # This is the tag used during gitlab-runner registration. Multiple tags may be selected.
      script:
        - CURDIR=$(pwd)
        - echo $CURDIR
        - /bin/cp -rf /root/.local/compatibility_testing/template.html.template /root/.local/compatibility_testing/template.html
        # Before running the Compatibility Testing tool, configure tool parameters based on the actual application software process.
        - /bin/bash /root/.local/compatibility_testing/bin/compatibility_test
        # If you are a common user, add the sudo command, for example, sudo /bin/bash /root/.local/compatibility_testing/bin/compatibility_test.
        - /bin/cp -rf /root/.local/compatibility_testing/compatibility_report.html $CURDIR/compatibility_report.html
        - echo "Go to ${CURDIR}'/compatibility_report.html to view the report."
      artifacts:
        paths:
          - compatibility_report.html     
        name: compatibility_report

    /root/.local/ indicates the Compatibility Testing tool installation directory. Replace it with the actual directory. You can obtain the template.html.template file from this directory.