This example demonstrates how to use the TestStand gRPC API from a client application to get status, and control a TestStand user interface (UI) or a TestStand Windows service running a gRPC service on a local or remote machine. This example consists of three C# .NET projects: a client, a UI server, and a Windows service, which you can run on separate machines to remotely execute TestStand sequence files.
Subject to change without notice.
Complete the following steps to configure both the client and server machines.
-
Install the following software:
Software Server Client Visual Studio 2019, or 2022 with the .NET and C++ desktop development workloads Yes Yes Git Yes Yes TestStand 2021 SP1 or later. Earlier versions of TestStand are untested. Yes No -
Clone the TestStand gRPC API Example Git repository on both the client and server machines.
The UI server is a simple TestStand C# User Interface that uses a gRPC service using ASP.NET Core. The server supports secure connections using server-side TLS or mutual TLS, and non-secure connections.
Complete the following steps to prepare the server to accept requests from the client and run TestStand sequence files.
- Activate the TestStand license to prevent NI License Manager dialogs upon starting the server.
- Open the TestStand Sequence Editor, and wait for the NI License Manager dialog to appear. If no dialog appears, then the TestStand license is activated and you may continue to the next procedure.
- Select Log in to Activate or Begin 7 Day Trial options to activate the TestStand License.
- Close and reopen the TestStand Sequence Editor.
- You may continue to the next procedure if no NI License Manger dialog appeared after reopening the Sequence Editor. If however a dialog appeared, continue to the next step.
- If you selected Begin 7 Day Trial, then in the License Activation dialog select the Remind Me When They Expire option.
- Close and reopen the TestStand Sequence Editor and ensure no NI License Manager dialog appears.
- Configure TestStand Station Options to prevent dialogs from appearing during execution.
- Open the TestStand Sequence Editor, then click Configure>Station Options to open the Station Options dialog box.
- In User Manager, deselect Check User Privileges.
- In Execution, set On Run-Time Error to Run Cleanup.
- In Time Limits, ensure that none of the properties are set to Prompt for Action.
- In Preferences, deselect Prompt to Find Files.
- (Optional) Configure a server-side TLS connection or mutual TLS connection. Refer to Encrypting Connections to the Server for more information. If you do not configure a secure connection, the client and server connection is not secure.
- In Visual Studio, open
Server/UI/TestExecServer.sln
. Open the .sln file. Do not select Open Folder. - Build and run the solution. Type F5 or select the Start Debugging item from the DEBUG menu to run the solution. If you are using 32-bit TestStand, select the x86 Solution Platform before building.
The Windows service is a .NET Worker Service application that enables gRPC and runs TestStand as a background service. The server supports secure connections using server-side TLS or mutual TLS, and non-secure connections.
Complete the following steps to prepare the server to accept requests from the client and run TestStand sequence files.
- Follow step 1 from section Configure and Run the UI Server
- (Optional) Configure a server-side TLS connection or mutual TLS connection. Refer to Encrypting Connections to the Server for more information. If you do not configure a secure connection, the client and server connection is not secure.
- Build and install the Windows service using instructions in Readme.md.
The client is a C# GUI application that demonstrates using the TestStand gRPC API to remotely execute sequence files and perform other operations.
Complete the following steps to connect the client to the server.
- (Optional) Configure a server-side TLS connection or mutual TLS connection. Refer to Encrypting Connections to the Server for more information. If you do not configure a secure connection, the client and server connection is not secure.
- Build and run the solution in a new instance of Visual Studio. Open the
Client/ExampleClient.sln
file. Do not select Open Folder. Type F5 or select the Start Debugging item from the DEBUG menu to run the solution. - In the Example TestStand API Client Application window, enter the server IP address in Server Address, then click Connect. The Status field indicates whether a connection is established. If you have successfully established a secure connection, the IP address field displays a green shield icon.
The server application has example files that the client can run. When building the server project, all the files under Server/ExampleFiles
are distributed with the executable.
To add additional example files, do one or all of the following:
- Add files to the
Server\ExampleFiles
directory and rebuild the server. - Copy files to the
<server executable>\ExampleFiles
directory. - Add files to a directory that is part of TestStand's search directories.
The client application has a list of files that can be run on the server. The list of files is configured in the client_config.json
file.
To add additional example files that can be run on the server, modify the property example_files
in the client_config.json
file.
Complete the following steps in the client to run a sequence file on the server.
- In the client application window, select the sequence file you want to run. The list of sequence files is hard coded, and any sequence file in the list needs to be present on the server.
- Select the Model, Station Model, and Entry Point you want to use.
- Click Run Remote Sequence File. The sequence file runs on the server.
- While the sequence file is running, you can break, resume, and terminate the execution.
After running the sequence file on a server, you can optionally use the TestMonitor plugin to upload test data to the cloud.
Nuget Package Version | Comment |
---|---|
15 | The namespace changed from NationalInstruments.TestStand.gRPC.Server to NationalInstruments.TestStand.Grpc.Server |
16 | None |
17 | All services with suffix "Class" had that suffix removed. Their corresponding interfaces were also deleted. For example, EngineClass has been renamed to Engine and IEngine has been deleted. |
18 | None |
19 | None |
20 | None |
21 | None |
22 | Wrappers for all array parameters have been created. The wrappers have the name <ObjectType>Collection. To pass a non-null array, an instance of the collection needs to be created and populated. See Arrays section in APIMapping document. |
23 | The namespace TSSync.Grpc was renamed to NationalInstruments.TestStand.Synchronization.Grpc . Also, the name of the proto file TSSync.proto was renamed to NationalInstruments.TestStand.Synchronization.proto. |