BotellaA
(Arnaud Botella)
February 5, 2024, 10:19am
1
Hello,
I’m having trouble setting up a test server with VTK web, ie not testing the Python function in the protocols but the exported rpc.
So far, I have read these pages:
r"""
This module provides some testing functionality for paraview and
vtk web applications. It provides the ability to run an arbitrary
test script in a separate thread and communicate the results back
to the service so that the CTest framework can be notified of the
success or failure of the test.
This test harness will notice when the test script has finished
running and will notify the service to stop. At this point, the
test results will be checked in the main thread which ran the
service, and in the case of failure an exception will be raised
to notify CTest of the failure.
Test scripts need to follow some simple rules in order to work
within the test harness framework:
1) implement a function called "runTest(args)", where the args
parameter contains all the arguments given to the web application
upon starting. Among other important items, args will contain the
port number where the web application is listening.
This file has been truncated. show original
import json
from vtkmodules.vtkFiltersSources import vtkConeSource
from vtkmodules.vtkRenderingCore import (
vtkActor,
vtkPolyDataMapper,
vtkRenderWindow,
vtkRenderer,
)
import vtkmodules.vtkRenderingFreeType
import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.web import render_window_serializer as rws
from vtkmodules.test import Testing
class TestSerializeRenderWindow(Testing.vtkTest):
def testSerializeRenderWindow(self):
cone = vtkConeSource()
coneMapper = vtkPolyDataMapper()
coneMapper.SetInputConnection(cone.GetOutputPort())
This file has been truncated. show original
https://docs.vtk.org/en/latest/api/python/vtkmodules/vtkmodules.test.Testing.html
Those only seem to talk about the functions testing, not the server testing.
Do you have any code or do you know of any code that tests this part?
Thanks!
I know we have some cmake tests that start a server and a client that connect to it. But it has been a while and I don’t remember when those are.
The latest set of tests are on the trame side (same tech), which just script the browser from Python and run via pytest. trame-client/tests at master · Kitware/trame-client · GitHub
You can find also some in trame-vtk where we do image comparison too.
HTH,
Seb
BotellaA
(Arnaud Botella)
February 6, 2024, 3:30pm
3
Thanks for the resource!
We managed to launch the server using the FixtureHelper. Then, we connect to it via websocket but we can’t figure out a way to call a Rpc, do you have any example for that? Is there another way to call a protocol from the server?
ws = websocket.WebSocket()
ws.connect("ws://localhost:1234/ws")
ws.send("create_visualization")
response = ws.recv()
A while back we were creating a “test” client app which you can drive from python (click - run test button, check results)…
In other words, we never (re-)implemented the wslink protocol in Python from the client point of view.