@@ -17,6 +17,8 @@ namespace Microsoft.Azure.Functions.PowerShellWorker.Test
1717{
1818 using System . Collections . ObjectModel ;
1919 using System . Management . Automation ;
20+ using Microsoft . Azure . Functions . PowerShellWorker . Durable ;
21+ using Newtonsoft . Json ;
2022
2123 internal class TestUtils
2224 {
@@ -373,6 +375,52 @@ public void LoggerContextIsSet()
373375 powerShellManagerPool . ReclaimUsedWorker ( worker ) ;
374376 }
375377
378+ [ Theory ]
379+ [ InlineData ( DurableFunctionType . None , false ) ]
380+ [ InlineData ( DurableFunctionType . OrchestrationFunction , false ) ]
381+ [ InlineData ( DurableFunctionType . ActivityFunction , true ) ]
382+ internal void SuppressPipelineTracesForDurableActivityFunctionOnly ( DurableFunctionType durableFunctionType , bool shouldSuppressPipelineTraces )
383+ {
384+ s_testLogger . FullLog . Clear ( ) ;
385+
386+ var path = Path . Join ( s_funcDirectory , "testFunctionWithOutput.ps1" ) ;
387+ var ( functionInfo , testManager ) = PrepareFunction ( path , string . Empty ) ;
388+ functionInfo . DurableFunctionInfo . Type = durableFunctionType ;
389+
390+ try
391+ {
392+ FunctionMetadata . RegisterFunctionMetadata ( testManager . InstanceId , functionInfo . OutputBindings ) ;
393+
394+ var result = testManager . InvokeFunction ( functionInfo , null , null , CreateOrchestratorInputData ( ) , new FunctionInvocationPerformanceStopwatch ( ) ) ;
395+
396+ var relevantLogs = s_testLogger . FullLog . Where ( message => message . StartsWith ( "Information: OUTPUT:" ) ) . ToList ( ) ;
397+ var expected = shouldSuppressPipelineTraces ? new string [ 0 ] : new [ ] { "Information: OUTPUT: Hello" } ;
398+ Assert . Equal ( expected , relevantLogs ) ;
399+ }
400+ finally
401+ {
402+ FunctionMetadata . UnregisterFunctionMetadata ( testManager . InstanceId ) ;
403+ }
404+ }
405+
406+ private static List < ParameterBinding > CreateOrchestratorInputData ( )
407+ {
408+ var orchestrationContext = new OrchestrationContext
409+ {
410+ History = new [ ] { new HistoryEvent { EventType = HistoryEventType . OrchestratorStarted } }
411+ } ;
412+
413+ var testInputData = new List < ParameterBinding >
414+ {
415+ new ParameterBinding
416+ {
417+ Name = TestInputBindingName ,
418+ Data = new TypedData { String = JsonConvert . SerializeObject ( orchestrationContext ) }
419+ }
420+ } ;
421+ return testInputData ;
422+ }
423+
376424 private static Hashtable InvokeFunction ( PowerShellManager powerShellManager , AzFunctionInfo functionInfo , Hashtable triggerMetadata = null )
377425 {
378426 return powerShellManager . InvokeFunction ( functionInfo , triggerMetadata , null , s_testInputData , new FunctionInvocationPerformanceStopwatch ( ) ) ;
0 commit comments