C VUGen Grid Client
Examples - C VUGen Grid Execution For SeeTest
SeeTest C VUGen Client - Using Grid Execution
#include "grid_api.h"
/* Callback which is invoked whenever an ic_... command fails: */
static void exceptionCB(image_client* client)
{
if (client->latest_result.status == IC_INTERNAL_EXCEPTION) {
lr_error_message ("Internal exception of type %s was raised: %s",
client->latest_result.details.internal_exception.cause_id,
client->latest_result.details.internal_exception.message);
}
/* Generates a report of this test case and releases the client so that other clients can approach the agent in the near future: */
/* For more information - https://docs.digital.ai/bundle/TC/page/as-_report_of_executed_test.html */
ic_generate_report(client, IC_TRUE);
lr_abort();
}
/* Callback which is invoked whenever an grid_... command fails: */
static void exceptionGCB(grid_client *grid_client)
{
if (grid_client->latest_result.status == IC_INTERNAL_EXCEPTION) {
lr_error_message ("Internal exception of type %s was raised: %s",
grid_client->latest_result.details.internal_exception.cause_id,
grid_client->latest_result.details.internal_exception.message);
}
lr_abort();
}
Action()
{
image_client c = {IC_DONE, NULL, NULL};
grid_client gc = {IC_DONE, NULL, NULL};
lr_load_dll("C:\\Users\\User\\Documents\\VuGen\\Scripts\\CVuser1\\imageClient_C_API.dll");
grid_init(&gc, <user_name>, <password>, <project_name>, "192.168.4.63", 80, IC_FALSE, &exceptionGCB);
grid_lock_device_for_execution(&gc, &c, <test_name>, <device_query>, 10, 40000, &exceptionCB);
.
.
.
ic_release_client(&c);
return 0;
}
Initializing a VUGen Grid Client
A VuGen Grid client handler, i.e., a grid_client object must be initialized prior to accessing its fields or call commands over it.
This should be done using one of Grid init commands:
const char *grid_init(grid_client *gridClient, const char * userName, const char * password, const char * projectName, const char * domain, int port, ic_bool isSecured, void(*exception_callback)(struct grid_client_t *))
const char *grid_access_key_init(grid_client *gridClient, const char * accessKey, const char * domain, int port, ic_bool isSecured, void(*exception_callback)(struct grid_client_t *))
const char *grid_url_init(grid_client *gridClient, const char * userName, const char * password, const char * projectName, const char * url, void(*exception_callback)(struct grid_client_t *))
const char *grid_url_access_key_init(grid_client *gridClient, const char * accessKey, const char * url, void(*exception_callback)(struct grid_client_t *))
This command initializes the given handler of a VUGen grid client (grid*_client *gridClient*) and associates it with a SeeTestCloud Grid execution. The handler must be a pointer to structure grid_client located in a valid memory area, i.e., grid*_init* does not allocate memory for the handler. The last parameter is a pointer to a callback function which will be invoked once a test step fails. The function is expected to be a void function having a single parameter, which is a pointer to structure grid_client. Value NULL passed into the parameter means you do not wish to register a callback.
Parameters
- gridClient: The handler to be initialized
- accessKey: See more in Use Access Keys for Authentication.
- userName: Name of cloud user with which to execute the test
- password: Password of cloud user with which to execute the test
- projectName: Name of project to use
- url: URL of cloud user with which to execute the test
- domain: The hostname or the IP-address of the cloud server
- port: The port listened by the cloud server
- isSecured: Is the secure connection to a cloud server
- exception_callback: A pointer to a failure-callback function.
This command, as well as other VUGen-grid client commands, is declared in header grid_api.h, which can be found in <SeeTestAutomation_installation_directory>/clients/vugen/grid_api.h.
Initializing A VUGen Grid Execution Client
A VuGen Grid Execution client handler, i.e., an image_client object must be initialized prior you access its fields or call commands over it.
This should be done using command grid_lock_device_for_execution:
const char *grid_lock_device_for_execution(grid_client *gridClient, image_client *client, const char * testName, const char * deviceQuery, int reservationTimeInMinutes, long long timeout, void(*exception_callback)(struct image_client_t *))
This command initializes the given handler of a VUGen grid execution client (image_client *client) and associates it with a SeeTestCloud Grid execution node. The handler must be a pointer to structure grid_client located in a valid memory area, i.e., grid_lock_device_for_execution does not allocate memory for the handler. The last parameter is a pointer to a callback function which will be invoked once a test step fails. The function is expected to be a void function having a single parameter, which is a pointer to structure image_client. Value NULL passed into the parameter means you do not wish to register a callback.
Parameters
- gridClient: The handler to be grid client
- Client: The handler to be initialized
- testName: Name of the test to be shown in Cloud UI and Report
- deviceQuery: XPath Search query to look up devices for test execution. More info can be found in the documentation.
- reservationTimeInMinutes: Name of the test to be shown in Cloud UI and Report
- timeout: Timeout in milliseconds to wait for an available device according to the search query.
- exception_callback: A pointer to a failure-callback function.
This command, as well as other VUGen-grid client commands, is declared in header grid_api.h, which can be found in <installation_directory>/clients/vugen/grid_api.h.