File tree Expand file tree Collapse file tree 5 files changed +52
-3
lines changed
Compute/Commands.Compute.Test/ScenarioTests
Profile/Commands.Profile.Test
Resources/Commands.ResourceManager/Cmdlets/Implementation Expand file tree Collapse file tree 5 files changed +52
-3
lines changed Original file line number Diff line number Diff line change @@ -137,13 +137,50 @@ protected string PSVersion
137137
138138 protected abstract string DataCollectionWarning { get ; }
139139
140+ private SessionState _sessionState ;
141+
142+ public new SessionState SessionState
143+ {
144+ get
145+ {
146+ return _sessionState ;
147+ }
148+ set
149+ {
150+ _sessionState = value ;
151+ }
152+ }
153+
154+ private RuntimeDefinedParameterDictionary _asJobDynamicParameters ;
155+
156+ public RuntimeDefinedParameterDictionary AsJobDynamicParameters
157+ {
158+ get
159+ {
160+ if ( _asJobDynamicParameters == null )
161+ {
162+ _asJobDynamicParameters = new RuntimeDefinedParameterDictionary ( ) ;
163+ }
164+ return _asJobDynamicParameters ;
165+ }
166+ set
167+ {
168+ _asJobDynamicParameters = value ;
169+ }
170+ }
171+
140172 /// <summary>
141173 /// Initializes AzurePSCmdlet properties.
142174 /// </summary>
143175 public AzurePSCmdlet ( )
144176 {
145177 DebugMessages = new ConcurrentQueue < string > ( ) ;
178+ }
146179
180+ // Register Dynamic Parameters for use in long running jobs
181+ public void RegisterDynamicParameters ( RuntimeDefinedParameterDictionary parameters )
182+ {
183+ this . AsJobDynamicParameters = parameters ;
147184 }
148185
149186
@@ -252,6 +289,7 @@ protected virtual void TearDownHttpClientPipeline()
252289 /// </summary>
253290 protected override void BeginProcessing ( )
254291 {
292+ SessionState = base . SessionState ;
255293 var profile = _dataCollectionProfile ;
256294 //TODO: Inject from CI server
257295 lock ( lockObject )
Original file line number Diff line number Diff line change @@ -107,7 +107,9 @@ function Test-VirtualMachineSetRunCommand
107107
108108 $path = ' ScenarioTests\test.ps1' ;
109109
110- $result = Invoke-AzureRmVMRunCommand - ResourceGroupName $rgname - Name $vmname - CommandId $commandId - ScriptPath $path - Parameter $param ;
110+ $job = Invoke-AzureRmVMRunCommand - ResourceGroupName $rgname - Name $vmname - CommandId $commandId - ScriptPath $path - Parameter $param - AsJob;
111+ $result = $job | Wait-Job
112+
111113 Assert-AreEqual " Succeeded" $result.Status
112114
113115 # Remove All VMs
Original file line number Diff line number Diff line change @@ -183,6 +183,7 @@ public void JobCopiesCmdletParameterSet()
183183 Mock < ICommandRuntime > mock = new Mock < ICommandRuntime > ( ) ;
184184 var cmdlet = new AzureParameterSetCmdlet ( ) ;
185185 cmdlet . SetParameterSet ( "ParameterSetIsSet" ) ;
186+ cmdlet . AsJobDynamicParameters = new RuntimeDefinedParameterDictionary ( ) ;
186187 cmdlet . CommandRuntime = mock . Object ;
187188 var job = cmdlet . ExecuteAsJob ( "Test parameter set job" ) as AzureLongRunningJob < AzureParameterSetCmdlet > ;
188189 WaitForCompletion ( job , j =>
@@ -389,6 +390,10 @@ public override void ExecuteCmdlet()
389390 {
390391 throw new InvalidOperationException ( "Parameter set must be set" ) ;
391392 }
393+ if ( this . AsJobDynamicParameters == null )
394+ {
395+ throw new InvalidOperationException ( "Dynamic parameters must be set" ) ;
396+ }
392397 }
393398
394399 protected override void InitializeQosEvent ( )
Original file line number Diff line number Diff line change @@ -135,6 +135,8 @@ public object GetDynamicParameters()
135135 }
136136 }
137137
138+ RegisterDynamicParameters ( dynamicParameters ) ;
139+
138140 return dynamicParameters ;
139141 }
140142
@@ -172,7 +174,7 @@ protected Hashtable GetTemplateParameterObject(Hashtable templateParameterObject
172174 }
173175
174176 // Load dynamic parameters
175- IEnumerable < RuntimeDefinedParameter > parameters = PowerShellUtilities . GetUsedDynamicParameters ( dynamicParameters , MyInvocation ) ;
177+ IEnumerable < RuntimeDefinedParameter > parameters = PowerShellUtilities . GetUsedDynamicParameters ( this . AsJobDynamicParameters , MyInvocation ) ;
176178 if ( parameters . Any ( ) )
177179 {
178180 parameters . ForEach ( dp => prameterObject [ ( ( ParameterAttribute ) dp . Attributes [ 0 ] ) . HelpMessage ] = new Hashtable { { "value" , dp . Value } } ) ;
Original file line number Diff line number Diff line change @@ -248,6 +248,8 @@ object IDynamicParameters.GetDynamicParameters()
248248 }
249249 }
250250
251+ RegisterDynamicParameters ( dynamicParameters ) ;
252+
251253 return this . dynamicParameters ;
252254 }
253255
@@ -269,7 +271,7 @@ private JObject GetParameters()
269271 }
270272
271273 // Load dynamic parameters
272- var parameters = PowerShellUtilities . GetUsedDynamicParameters ( dynamicParameters , MyInvocation ) ;
274+ var parameters = PowerShellUtilities . GetUsedDynamicParameters ( AsJobDynamicParameters , MyInvocation ) ;
273275 if ( parameters . Count ( ) > 0 )
274276 {
275277 return MyInvocation . BoundParameters . ToJObjectWithValue ( parameters . Select ( p => p . Name ) ) ;
You can’t perform that action at this time.
0 commit comments