Run tests

How to use the ArmoniK C++ SDK

Build worker and dynamic worker (Linux only)

To use ArmoniK with the C++ SDK, a dynamic worker image must be built. This worker image is then deployed along with the other ArmoniK components during the deployment phase. The worker runtime provides to ArmoniK clients a set of business services. The worker must be configured to load a shared library containing the implementation of the calculation library related to the provided services.

In order to build the dynamic worker image (armonik-sdk-cpp-dynamicworker) and the worker test (libArmoniK.SDK.Worker.Test.so), please run the following script:

./build-deploy-end2end.sh

This script generates the dynamic worker image that is used to deploy ArmoniK with. The script also generates the shared library used by the worker to perform the ArmoniK call on the desired services. The script will also copy this shared library into the right folder so it can be loaded by the ArmoniK worker. It is also possible to use the worker image available in the docker hub ANEO and build the shared library separately.

The dynamic worker search the shared library to be loaded in a the ArmoniK deployment data directory. The ARMONIK_SHARED_FOLDER variable points to that directory and the script build-deploy-end2end.sh uses this variable to copy the built shared library in that folder. In case this script is launched without having ArmoniK deployed then, the environnement variable should be set manually to the right directory.

Deploy ArmoniK

The ArmoniK infrastructure must be deployed with the C++ worker image. To do so, perform the following:

  • Fetch ArmoniK infra from github.
  • Add the C++ worker image, either by:
    • Replacing the default partition image with the C++ dynamic worker image (dockerhubaneo/armonik-sdk-cpp-dynamicworker or locally built armonik-sdk-cpp-dynamicworker). This is done by modifying the parameters.tfvars file with the C++ image and tag for the desired deployment method (all-in-one or multi-stage). or
    • Creating a new partition for the C++ worker by adding in the same parameters.tfvars file the new partition with the right image name and tag. This choice requires specifying in the C++ code the partition name in the task options in order to run correctly. If no partition is given in task options, the default partition is targeted.
    • Then follow the ArmoniK guide to deploy.

Build the client test and submit jobs

Once the worker is built and ArmoniK is deployed, It is possible to submit jobs by using the client test in the repository. In order to do so, build the client test by launching the cmake at the project root with the flags BUILD_CLIENT=ON and BUILD_END2END=ON. After the test build, the environment variable Grpc__EndPoint must be set to the ArmoniK control plane address in the test environment. To get the control plane address and port, we can use this Kubectl commands:

export CPIP=$(kubectl get svc control-plane -n armonik -o custom-columns="IP:.spec.clusterIP" --no-headers=true)
export CPPort=$(kubectl get svc control-plane -n armonik -o custom-columns="PORT:.spec.ports[*].port" --no-headers=true)
export Grpc__EndPoint=http://$CPIP:$CPPort

The worker lib version WorkerLib__Version must also be specified if the default one (0.1.0) is not used. These values can also be specified in the JSON file when used. Then run in your build environnement:

cd /app/install/bin```
./ArmoniK.SDK.Client.Test

It is also possible to use the test image armonik_sdk_client_test generated by the script build-deploy-end2end.sh to run tests. This docker image provides an environment with ArmoniK Client and Client Test built to run tests and submit tasks to ArmoniK.

docker run --rm -t --network host -e Grpc__EndPoint=http://$CPIP:$CPPort -e WorkerLib__Version="$lib_version" armonik_sdk_client_test:"$version"