Conductor Documentation

WRCP Tester Plugin

Requirements

[centos@localhost examples]$ tree
├── blueprint.yaml
├── gather
└── tests
    ├── test1
    │   └── main
    ├── test2
    │   └── main.local
    └── test3        
        └── main

Running using CLI

  1. cfy plugins upload wrcp_tester_plugin.wgn -y plugin.yaml
  2. cfy blueprints upload blueprint.zip -b tester-blueprint
  3. cfy deployments group create wrcp_group
  4. cfy deployment group extend -ar "blueprint_id=wrcp-blueprint" -lr "csys-env-type=Wind-River-Cloud-Platform-System-Controller" wrcp_group
  5. cfy deployment group create -b tester-blueprint tester_group
  6. cfy deployments group extend --into-environments wrcp_group tester_group
  7. cfy executions group start execute_operation -p '{"operation": "windriver.interfaces.test.run_tests"}' -g tester_group

Gather Script

The purpose of the Gather Script is to simplify how the result is shown in the terminal.

./gather tester_group_name

This command returns a list of dictionaries like this

"None":

[{

   "name":"test",
   "passed":true,
   "output":"2023-01-10 20:48:44.895252\n",
   "local":false,
   "started_time":"2023-01-08T11:52:05.107370",
   "end_time":"2023-01-08T11:52:06.016341"
}]

The “None” at first line is the “csys-location-name” label of WRCP target and show the name of target or “None” if no name is defined

Running using UI

The dashboard is the easiest way to run and check the tests results. The dashboard is the last page in Conductor left panel

  1. Go to Precheck Dashboard
  2. Click the “Execute tests” button
  3. A modal is displayed where the user can select a. A “Deployment Group” in a list b. The timeout setting the “Timeout” field c. The list of desired tests to be executed setting the “Tests” field with the name of each test d. The list of tests to be exclude from execution setting the “Exclude” field with the name of each test
  4. Start the test and wait it finishes a. The results must be present in “Results grid”

Precheck Dashboard

Deployment list

Test Results List

Precheck Dashboard

Filter

Include or exclude desired tests appending to a list, or using regex


#just remote-bash will run
cfy executions group start execute_operation -p '{"operation": "windriver.interfaces.test.run_tests", "operation_kwargs": { "tests": ["remote-bash"]}}' -g tester_group
 
#just local test will not run
cfy executions group start execute_operation -p '{"operation": "windriver.interfaces.test.run_tests", "operation_kwargs": { "exclude": ["local"]}}' -g tester_group
 
#just the ones with "remote-" at the name will run
cfy executions groups start execute_operation  -p '{"operation": "windriver.interfaces.test.run_tests", "operation_kwargs": { "tests": ["^remote*$"] } }

Timeout

The timeout value defined in the execution defines how much time a test can run before raising an error


#in this example, 30s timeout has been set
cfy executions groups start execute_operation  -p '{"operation": "windriver.interfaces.test.run_tests", "operation_kwargs": {"timeout": 30}}' -g test_group

Remote vs Local tests

Frequent questions Local Remote
Where the tests run? local conductor WRCP host
Run python scripts? yes, only test with WRCP/K8S API yes
Run bash scripts? no yes
Run tests with WRCP API? yes no
Run tests with Kubernetes API? yes no
Need a file name extension to run ? .local no
Run sudo passwordless script? - yes

Tests with Kubernetes API

#!/usr/bin/env python
from kubernetes import client
from wrcp_tester.common.decorators import with_kubernetes_client
 
 
@with_kubernetes_client
def list_pods(k8s_client):
    core_v1 = client.CoreV1Api(k8s_client)
    pod_result = core_v1.list_pod_for_all_namespaces()
    print("{:<18}{:<20}{}".format("pod_id", "namespace", "name"))
    for pod in pod_result.items:
        print("{:<18}{:<20}{}".format(
            pod.status.pod_ip,
            pod.metadata.namespace,
            pod.metadata.name))
 
 
if __name__ == "__main__":
    list_pods()

Tests with WRCP API

There are two decorators that use WRCP API: @with_system_configuration_management and @with_distributed_cloud_connection


#!/usr/bin/env python
 
from wrcp_tester.common.decorators import with_system_configuration_management
 
@with_system_configuration_management
def sample_test(conn):
    """Sample test using WRCP System Configuration Management (cgts-client) API
 
    Args:
        conn: authenticated client connection
    """
    print("RESPONSE", conn.ihost.list())
 
 
if __name__ == "__main__":
    sample_test()


#!/usr/bin/env python
 
from wrcp_tester.common.decorators import with_distributed_cloud_connection
 
@with_distributed_cloud_connection
def sample_test(conn):
    """Sample test using WRCP Distributed Cloud Client (distcloud-client) API
 
    Args:
        conn: authenticated client connection
    """
    alarms = conn.alarm_manager.list_alarms()
    for alarm in alarms:
        print("STATUS ", alarm.status)
 
 
if __name__ == "__main__":
    sample_test()
	

Tests with Sudo

  1. #!/bin/sh |
  2. echo "Test needs sudo: cat /etc/grub2.cfg"
  3. #echo $SUDO_PWD | sudo -S bash -c <command>
  4. echo $SUDO_PWD | sudo -S bash -c 'cat /etc/grub2.cfg'