Test U-SQL Scripts On Premise as well on Hosted Agent

Prerequisites:
  1. Windows SDK for CppSDK
  2. LocalRunHelper.exe with the help of Nuget package (Microsoft.Azure.DataLake.USQL.SDK)
Writing Test Case
You can write the test case in the following two different ways by using LocalRunHelper.exe
  • With the help of creating a Process
  • With the help of Class by adding it as a project reference
Approach 1:

  1. Make sure LocalRunHelper.exe is part of bin\x64\release folder
  2. Make sure the CppSDK folder is also part of bin\x64\release folder
  3. If you build, then make sure the LocalRunHelper.exe (all its dependencies and CPPSDK) to be part of bin\x64\debug or current working folder.
Approach 2:
  1. Add localrunHelper.exe as a project reference
    2. Write Test Case

Unit Testing on Local Machine
  1. Set up Test Framework Settings:
Default Processor Architecture for Test Framework Settings – x64   


            2. Build solution for x64 Platform
a.       Choose Solution platform x64, as CPPSDK supports only 64 bit.

           3. Set the Platform target to x64 under build project properties
                             

Testing on Hosted Agent

1. Ignore the U-SQL Project in Build:

·       As MSBuild Task doesn’t build the Project of type of U-SQL, So we need to skip this project type for building.
·       Go to Configuration Manager and Uncheck the Build Check box for the respective U-SQL Projects.


2. Setting up Test Framework Settings:
              Create a *.runsettings file and specify the TargetPlatform to be x64 and TargetFrameworkVersion to be Framework45.



3.       Ensure the LocalRunHelper.exe and CppSDK are part of the current working directory folder to pick the proper files for the test case execution.

Troubleshooting Tips:
1. In case there is an error and you are unable to identify the route cause for the failure of the testcase/job, run the following command in command prompt which will show you the error.
LocalRunHelper run -Script path_to_usql_script.usql [optional_arguments]
2. If the test cases are not visible in Local/Hosted Agent, verify if the Test Framework settings are set as x64.
3. If the test case is failing in local for a reason like *.dll is missing, then check if the CppSDK path is set properly.
4. DataRoot path need not to be a part of current working directory, However, If you are running the test cases on Hosted agent, (as part of CI/CD) it is recommended that you have this path in current working folder.

References:

Comments