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