@@ -3,6 +3,7 @@ package v7action_test
33import (
44 "errors"
55 "fmt"
6+ "time"
67
78 . "code.cloudfoundry.org/cli/v9/actor/v7action"
89 "code.cloudfoundry.org/cli/v9/actor/v7action/v7actionfakes"
@@ -23,11 +24,14 @@ var _ = Describe("Application Summary Actions", func() {
2324 var (
2425 actor * Actor
2526 fakeCloudControllerClient * v7actionfakes.FakeCloudControllerClient
27+ fakeConfig * v7actionfakes.FakeConfig
2628 )
2729
2830 BeforeEach (func () {
2931 fakeCloudControllerClient = new (v7actionfakes.FakeCloudControllerClient )
30- actor = NewActor (fakeCloudControllerClient , nil , nil , nil , nil , clock .NewClock ())
32+ fakeConfig = new (v7actionfakes.FakeConfig )
33+ fakeConfig .APIVersionReturns ("3.210.0" )
34+ actor = NewActor (fakeCloudControllerClient , fakeConfig , nil , nil , nil , clock .NewClock ())
3135 })
3236
3337 Describe ("ApplicationSummary" , func () {
@@ -287,6 +291,152 @@ var _ = Describe("Application Summary Actions", func() {
287291 Expect (fakeCloudControllerClient .GetProcessInstancesArgsForCall (0 )).To (Equal ("some-process-guid" ))
288292 })
289293
294+ Context ("the cloud controller supports embedded process instances" , func () {
295+ BeforeEach (func () {
296+ fakeConfig .APIVersionReturns ("3.211.0" )
297+
298+ listedProcesses := []resources.Process {
299+ {
300+ GUID : "some-process-guid" ,
301+ Type : "some-type" ,
302+ Command : * types .NewFilteredString ("[Redacted Value]" ),
303+ MemoryInMB : types.NullUint64 {Value : 32 , IsSet : true },
304+ AppGUID : "some-app-guid" ,
305+ EmbeddedProcessInstances : []resources.EmbeddedProcessInstance {
306+ {Index : 0 , State : "RUNNING" , Since : 300 },
307+ {Index : 1 , State : "CRASHED" , Since : 0 },
308+ },
309+ },
310+ {
311+ GUID : "some-process-web-guid" ,
312+ Type : "web" ,
313+ Command : * types .NewFilteredString ("[Redacted Value]" ),
314+ MemoryInMB : types.NullUint64 {Value : 64 , IsSet : true },
315+ AppGUID : "some-app-guid" ,
316+ EmbeddedProcessInstances : []resources.EmbeddedProcessInstance {
317+ {Index : 0 , State : "RUNNING" , Since : 500 },
318+ {Index : 1 , State : "RUNNING" , Since : 600 },
319+ },
320+ },
321+ }
322+
323+ fakeCloudControllerClient .GetProcessesReturns (
324+ listedProcesses ,
325+ ccv3.Warnings {"get-space-processes-warning" },
326+ nil ,
327+ )
328+ })
329+
330+ It ("uses the embedded process instances" , func () {
331+ Expect (executeErr ).ToNot (HaveOccurred ())
332+ Expect (summaries ).To (Equal ([]ApplicationSummary {
333+ {
334+ Application : resources.Application {
335+ Name : "some-app-name" ,
336+ GUID : "some-app-guid" ,
337+ State : constant .ApplicationStarted ,
338+ },
339+ ProcessSummaries : []ProcessSummary {
340+ {
341+ Process : resources.Process {
342+ GUID : "some-process-web-guid" ,
343+ Type : "web" ,
344+ Command : * types .NewFilteredString ("[Redacted Value]" ),
345+ MemoryInMB : types.NullUint64 {Value : 64 , IsSet : true },
346+ AppGUID : "some-app-guid" ,
347+ EmbeddedProcessInstances : []resources.EmbeddedProcessInstance {
348+ {Index : 0 , State : "RUNNING" , Since : 500 },
349+ {Index : 1 , State : "RUNNING" , Since : 600 },
350+ },
351+ },
352+ InstanceDetails : []ProcessInstance {
353+ {
354+ Index : 0 ,
355+ State : "RUNNING" ,
356+ Uptime : 500 * time .Second ,
357+ },
358+ {
359+ Index : 1 ,
360+ State : "RUNNING" ,
361+ Uptime : 600 * time .Second ,
362+ },
363+ },
364+ },
365+ {
366+ Process : resources.Process {
367+ GUID : "some-process-guid" ,
368+ MemoryInMB : types.NullUint64 {Value : 32 , IsSet : true },
369+ Type : "some-type" ,
370+ Command : * types .NewFilteredString ("[Redacted Value]" ),
371+ AppGUID : "some-app-guid" ,
372+ EmbeddedProcessInstances : []resources.EmbeddedProcessInstance {
373+ {Index : 0 , State : "RUNNING" , Since : 300 },
374+ {Index : 1 , State : "CRASHED" , Since : 0 },
375+ },
376+ },
377+ InstanceDetails : []ProcessInstance {
378+ {
379+ Index : 0 ,
380+ State : "RUNNING" ,
381+ Uptime : 300 * time .Second ,
382+ },
383+ {
384+ Index : 1 ,
385+ State : "CRASHED" ,
386+ Uptime : 0 * time .Second ,
387+ },
388+ },
389+ },
390+ },
391+ Routes : []resources.Route {
392+ {
393+ GUID : "some-route-guid" ,
394+ Destinations : []resources.RouteDestination {
395+ {
396+ App : resources.RouteDestinationApp {
397+ GUID : "some-app-guid" ,
398+ },
399+ },
400+ },
401+ },
402+ {
403+ GUID : "some-other-route-guid" ,
404+ Destinations : []resources.RouteDestination {
405+ {
406+ App : resources.RouteDestinationApp {
407+ GUID : "some-app-guid" ,
408+ },
409+ },
410+ },
411+ },
412+ },
413+ },
414+ }))
415+
416+ Expect (warnings ).To (ConsistOf (
417+ "get-apps-warning" ,
418+ "get-space-processes-warning" ,
419+ "get-routes-warning" ,
420+ ))
421+
422+ Expect (fakeCloudControllerClient .GetApplicationsCallCount ()).To (Equal (1 ))
423+ Expect (fakeCloudControllerClient .GetApplicationsArgsForCall (0 )).To (ConsistOf (
424+ ccv3.Query {Key : ccv3 .OrderBy , Values : []string {"name" }},
425+ ccv3.Query {Key : ccv3 .SpaceGUIDFilter , Values : []string {"some-space-guid" }},
426+ ccv3.Query {Key : ccv3 .LabelSelectorFilter , Values : []string {"some-key=some-value" }},
427+ ccv3.Query {Key : ccv3 .PerPage , Values : []string {ccv3 .MaxPerPage }},
428+ ))
429+
430+ Expect (fakeCloudControllerClient .GetProcessesCallCount ()).To (Equal (1 ))
431+ Expect (fakeCloudControllerClient .GetProcessesArgsForCall (0 )).To (ConsistOf (
432+ ccv3.Query {Key : ccv3 .SpaceGUIDFilter , Values : []string {"some-space-guid" }},
433+ ccv3.Query {Key : ccv3 .Embed , Values : []string {"process_instances" }},
434+ ))
435+
436+ Expect (fakeCloudControllerClient .GetProcessInstancesCallCount ()).To (Equal (0 ))
437+ })
438+ })
439+
290440 When ("there is no label selector" , func () {
291441 BeforeEach (func () {
292442 labelSelector = ""
0 commit comments