2.11. remote_test module

class remote_test.RemoteClass(cls, *args, **kwargs)

Bases: multiprocessing.context.Process

This class can wrap around and adapt the interface of another class, and then delegate its execution to a newly forked child process.

Usage:

  1. Create a remotely executed instance of MyClass.

    object = RemoteClass(MyClass, arg1='foo', arg2='bar')
    object.start_remote()
    
  2. Access the object normally as if it was an instance of your class.

    object.my_attribute = 20
    print object.my_attribute
    print object.my_method(object.my_attribute)
    object.my_attribute.nested_attribute = 'test'
    
  3. If you need the value of a remote attribute, use .get_remote_value method. This method is automatically called when needed in the context of a remotely executed class. E.g.

    if (object.my_attribute.get_remote_value() > 20):
        object.my_attribute2 = object.my_attribute
    
  4. Destroy the instance.

    object.quit_remote()
    object.terminate()
    
CALL = 1
DEFAULT_TIMEOUT = 2
GET = 0
PIPE_CHILD = 1
PIPE_PARENT = 0
QUIT = 5
REPR = 3
SETATTR = 2
STR = 4
get_remote_value()

Get value of a remotely held object

quit_remote()

Quit remote execution

run()

Create instance of the wrapped class and execute operations on it as requested by the parent process.

set_request_timeout(timeout)

Change request timeout

start_remote()

Start remote execution

class remote_test.RemoteClassAttr(remote, attr)

Bases: object

Wrapper around attribute of a remotely executed class.

get_remote_value()
path_to_str()
class remote_test.RemoteVppTestCase

Bases: framework.VppTestCase

Re-use VppTestCase to create remote VPP segment

In your test case:

@classmethod
def setUpClass(cls):
    # fork new process before client connects to VPP
    cls.remote_test = RemoteClass(RemoteVppTestCase)

    # start remote process
    cls.remote_test.start_remote()

    # set up your test case
    super(MyTestCase, cls).setUpClass()

    # set up remote test
    cls.remote_test.setUpClass(cls.tempdir)

@classmethod
def tearDownClass(cls):
    # tear down remote test
    cls.remote_test.tearDownClass()

    # stop remote process
    cls.remote_test.quit_remote()

    # tear down your test case
    super(MyTestCase, cls).tearDownClass()
emptyTest()

Do nothing

setTestFunctionInfo(name, doc)

Store the name and documentation string of currently executed test in the main VPP for logging purposes.

classmethod setUpClass(tempdir)

Perform class setup before running the testcase Remove shared memory files, start vpp and connect the vpp-api

classmethod tearDownClass()

Perform final cleanup after running all tests in this test-case

class remote_test.SerializableClassCopy

Bases: object

Empty class used as a basis for a serializable copy of another class.