You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@airavata.apache.org by Abhinav Sinha <ab...@gmail.com> on 2022/10/13 17:57:15 UTC

Test framework for Airavata MFT - example API call implementation

Hi, I’m working on a test framework for Airavata MFT using Mockito. I was looking for an implementation of a sample API call to test the Transfer API.

I’m using the Sample API call implementation in the airavata-mft README – but I’m unable to run it as Java fails to find this class ‘MFTApiServiceGrpc’. Do you have another sample API call implementation that I could use instead.

Here’s the code in README:

import org.apache.airavata.mft.api.client.MFTApiClient;
import org.apache.airavata.mft.api.service.*;

public class SampleClient {
    public static void main(String args[]) throws InterruptedException {

        MFTApiServiceGrpc.MFTApiServiceBlockingStub client = MFTApiClient.buildClient("localhost", 7004);

        String sourceId = "remote-ssh-resource2";
        String sourceToken = "local-ssh-cred";
        String destId = "remote-ssh-resource";
        String destToken = "local-ssh-cred";

        TransferApiRequest request = TransferApiRequest.newBuilder()
                .setSourceId(sourceId)
                .setSourceToken(sourceToken)
                .setSourceType("SCP")
                .setDestinationId(destId)
                .setDestinationToken(destToken)
                .setDestinationType("SCP")
                .setAffinityTransfer(false).build();

        // Submitting the transfer to MFT
        TransferApiResponse transferApiResponse = client.submitTransfer(request);
        while(true) {
            // Monitoring transfer status
            try {
                TransferStateApiResponse transferState = client.getTransferState(TransferStateApiRequest.newBuilder().setTransferId(transferApiResponse.getTransferId()).build());
                System.out.println("Latest Transfer State " + transferState.getState());
                if ("COMPLETED".equals(transferState.getState()) || "FAILED".equals(transferState.getState()) {
                    break;
                }

            } catch (Exception e) {
                System.out.println("Errored " + e.getMessage());
            }
            Thread.sleep(1000);
        }
    }
}

Thanks,
Abhinav