%3CLINGO-SUB%20id%3D%22lingo-sub-1690089%22%20slang%3D%22en-US%22%3EAzure%20Stream%20Analytics%20adds%20support%20for%20unit%20testing%20in%20a%20CI%2FCD%20pipeline%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1690089%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20enriching%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fazure-streamanalytics-cicd%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECI%2FCD%20tools%3C%2FA%3E%20to%20add%20the%20support%20for%20query%20unit%20testing%20for%20Azure%20Stream%20Analytics!%20Now%20you%20can%20add%20and%20run%20unit%20tests%20for%20your%20Stream%20Analytics%20jobs%20on%20any%20arbitrary%20machine%20or%20in%20a%20CI%2FCD%20pipeline.%3C%2FP%3E%0A%3CP%3EThe%20unit%20test%20cases%20run%20on%20a%20fully%20functioned%20Stream%20Analytics%20single%20node%20r%20locally.%20It%E2%80%99s%20very%20easy%20to%20use%20the%20query%20unit%20testing%20feature%20with%20the%20Stream%20Analytics%20CI%2FCD%20tools.%20This%20article%20will%20walk%20through%20the%20main%20steps.%20Please%20refer%20our%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fasaunittest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edocumentation%3C%2FA%3E%26nbsp%3Bfor%20more%20details%20and%20for%20the%20commands%20to%20be%20used%20for%20adding%20and%20running%20a%20test%20case.%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-531942676%22%20id%3D%22toc-hId-552296648%22%3E%3CSPAN%3EPrerequisites%20%3C%2FSPAN%3E%3C%2FH1%3E%0A%3CUL%3E%0A%3CLI%3EYou%20need%20to%20have%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fasavscodequickstart%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EVisual%20Studio%20Code%3C%2FA%3E%20(recommended)%20or%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fasavsquickstart%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EVisual%20Studio%20Stream%20Analytics%20project%3C%2FA%3E%20available%20(by%20creating%20new%20project%20or%20exporting%20from%20Azure).%3C%2FLI%3E%0A%3CLI%3EInstall%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fazure-streamanalytics-cicd%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EStream%20Analytics%20CI%2FCD%20tools%3C%2FA%3E%20.(version%202.0.0%20or%20above)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1275511787%22%20id%3D%22toc-hId--1255157815%22%3E%3CSPAN%3EAdd%20a%20test%20case%3C%2FSPAN%3E%3C%2FH1%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20any%20command%20terminal%2C%20run%20the%20command%20'addtestcase'%20to%20add%20a%20test%20case%20template%20for%20your%20project.%20If%20the%20template%20already%20exists%2C%20it%20will%20add%20a%20new%20test%20case%20in%20the%20file.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Eazure-streamanalytics-cicd%20addtestcase%20-project%20%3CPROJECTFULLPATH%3E%20%5B-testConfigPath%5D%20%3CTESTCONFIGFILEFULLPATH%3E%3C%2FTESTCONFIGFILEFULLPATH%3E%3C%2FPROJECTFULLPATH%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%20specify%20the%20test%20case%20inputs%20and%20expected%20outputs%20in%20the%20generated%20testconfig.json%20file.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22unittesting-blog1.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F220111i19A47C231939BE6C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22unittesting-blog1.png%22%20alt%3D%22unittesting-blog1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorsujie_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CH1%20id%3D%22toc-hId-1212001046%22%20id%3D%22toc-hId-1232355018%22%3E%3CSPAN%3ERun%20unit%20tests%3C%2FSPAN%3E%3C%2FH1%3E%0A%3CP%3EUse%20the%20following%20command%20to%20run%20one%20or%20multiple%20test%20cases%20for%20your%20project.%20A%20test%20report%20is%20output%20to%20the%20console.%20Testing%20outputs%2C%20intermediate%20results%20for%20each%20case%20along%20with%20a%20test%20summary%20file%20is%20generated%20in%20the%20output%20folder%20specified%20by%20%E2%80%98-outputPath%E2%80%99%20parameter.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Eazure-streamanalytics-cicd%20test%20-project%20%3CPROJECTFULLPATH%3E%20%5B-testConfigPath%20%3CTESTCONFIGFILEFULLPATH%3E%5D%20%5B-outputPath%20%3COUTPUTPATH%3E%5D%20%5B-customCodeZipFilePath%20%3CZIPFILEPATH%3E%5D%3C%2FZIPFILEPATH%3E%3C%2FOUTPUTPATH%3E%3C%2FTESTCONFIGFILEFULLPATH%3E%3C%2FPROJECTFULLPATH%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22unittesting-blog2.png%22%20style%3D%22width%3A%20902px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F220112iDF826CBF0FE75DBD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22unittesting-blog2.png%22%20alt%3D%22unittesting-blog2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--595453417%22%20id%3D%22toc-hId--575099445%22%3E%3CSPAN%3ELimitations%3C%2FSPAN%3E%3C%2FH1%3E%0A%3CUL%3E%0A%3CLI%3EThe%20feature%20only%20takes%20local%20static%20data%20file%20as%20inputs%20and%20outputs%20to%20a%20local%20folder.%3C%2FLI%3E%0A%3CLI%3EThe%20feature%20only%20supports%20Windows%20if%20your%20query%20contains%20JavaScript%20User-Defined%20Functions%20(UDF)%20or%20User-Defined%20Aggregates%20(UDA).%3C%2FLI%3E%0A%3CLI%3ETime%20policies%20(late%20arrival%20tolerance%2C%20event%20ordering%20policies%2C%20etc)%20don%E2%80%99t%20apply%20in%20unit%20testing.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-1892059416%22%20id%3D%22toc-hId-1912413388%22%3E%3CSPAN%3ESetting%20up%20a%20CI%2FCD%20pipeline%3C%2FSPAN%3E%3C%2FH1%3E%0A%3CP%3ECheck%20out%20the%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fasacicdoverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Estep%20by%20step%20guide%3C%2FA%3E%20on%20how%20to%20use%20the%20tools%20in%20general%20with%20any%20CI%2FCD%20systems.%20You%20can%20also%20learn%20more%20about%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fasacicdpipeline%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Especific%20instructions%20for%20build%2C%20test%20and%20deployment%20with%20Azure%20Pipelines%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-84604953%22%20id%3D%22toc-hId-104958925%22%3E%3CSPAN%3EFeedback%20and%20engagement%3C%2FSPAN%3E%3C%2FH1%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EEngage%20with%20us%20and%20get%20early%20glimpses%20of%20new%20features%20by%20following%20us%20on%20Twitter%20at%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2FAzureStreaming%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%40AzureStreaming%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Azure%20Stream%20Analytics%20team%20is%20highly%20committed%20to%20listening%20to%20your%20feedback%20and%20letting%20the%20user's%20voice%20influence%20our%20future%20investments.%20We%20welcome%20you%20to%20join%20the%20conversation%20and%20make%20your%20voice%20heard%20via%20our%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ffeedback.azure.com%2Fforums%2F270577-stream-analytics%2Ffilters%2Ftop%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EUserVoice%20page%3C%2FA%3E.%20For%20tooling%20specific%20feedback%20you%20can%20also%20contact%20%3CA%20href%3D%22mailto%3Aasatoolfeedback%40microsoft.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EStream%20Analytics%20tools%20feedback%3C%2FA%3E%20email%20group.%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1690089%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20enriching%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fazure-streamanalytics-cicd%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3ECI%2FCD%20tools%3C%2FA%3E%20to%20add%20the%20support%20for%20query%20unit%20testing%20for%20Azure%20Stream%20Analytics!%20Now%20you%20can%20add%20and%20run%20unit%20tests%20for%20your%20Stream%20Analytics%20jobs%20on%20any%20arbitrary%20machine%20or%20in%20a%20CI%2FCD%20pipeline.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1690089%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Stream%20Analytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

We are enriching the CI/CD tools to add the support for query unit testing for Azure Stream Analytics! Now you can add and run unit tests for your Stream Analytics jobs on any arbitrary machine or in a CI/CD pipeline.

The unit test cases run on a fully functioned Stream Analytics single node runtime locally. It’s very easy to use the query unit testing feature with the Stream Analytics CI/CD tools. This article will walk through the main steps. Please refer our documentation for more details and for the commands to be used for adding and running a test case.

 

Prerequisites

 

Add a test case

 

In any command terminal, run the command 'addtestcase' to add a test case template for your project. If the template already exists, it will add a new test case in the file.

 

azure-streamanalytics-cicd addtestcase -project <projectFullPath> [-testConfigPath] <testConfigFileFullPath>

 

Then specify the test case inputs and expected outputs in the generated testconfig.json file.

 

unittesting-blog1.png

 

Run unit tests

Use the following command to run one or multiple test cases for your project. A test report is output to the console. Testing outputs, intermediate results for each case along with a test summary file is generated in the output folder specified by ‘-outputPath’ parameter.

 

azure-streamanalytics-cicd test -project <projectFullPath> [-testConfigPath <testConfigFileFullPath>] [-outputPath <outputPath>] [-customCodeZipFilePath <zipFilePath>]

 

 

unittesting-blog2.png

 

Limitations

  • The feature only takes local static data file as inputs and outputs to a local folder.
  • The feature only supports Windows if your query contains JavaScript User-Defined Functions (UDF) or User-Defined Aggregates (UDA).
  • Time policies (late arrival tolerance, event ordering policies, etc) don’t apply in unit testing.

 

Setting up a CI/CD pipeline

Check out the step by step guide on how to use the tools in general with any CI/CD systems. You can also learn more about specific instructions for build, test and deployment with Azure Pipelines.

 

Feedback and engagement

 

Engage with us and get early glimpses of new features by following us on Twitter at @AzureStreaming.

 

The Azure Stream Analytics team is highly committed to listening to your feedback and letting the user's voice influence our future investments. We welcome you to join the conversation and make your voice heard via our UserVoice page. For tooling specific feedback you can also contact Stream Analytics tools feedback.