@@ -12,22 +12,32 @@ import (
1212 "code.cloudfoundry.org/cli/v8/resources"
1313 "code.cloudfoundry.org/cli/v8/types"
1414 "code.cloudfoundry.org/clock"
15+ "github.com/onsi/gomega/format"
1516
1617 "code.cloudfoundry.org/cli/v8/actor/actionerror"
1718
1819 . "github.com/onsi/ginkgo/v2"
1920 . "github.com/onsi/gomega"
2021)
2122
23+ var _ = BeforeSuite (func () {
24+ // Controls how long Gomega prints values in failure messages.
25+ // 0 means "no limit" (prints full values).
26+ format .MaxLength = 0 // or e.g. 20000
27+ })
28+
2229var _ = Describe ("Application Summary Actions" , func () {
2330 var (
2431 actor * Actor
2532 fakeCloudControllerClient * v7actionfakes.FakeCloudControllerClient
33+ fakeConfig * v7actionfakes.FakeConfig
2634 )
2735
2836 BeforeEach (func () {
2937 fakeCloudControllerClient = new (v7actionfakes.FakeCloudControllerClient )
30- actor = NewActor (fakeCloudControllerClient , nil , nil , nil , nil , clock .NewClock ())
38+ fakeConfig = new (v7actionfakes.FakeConfig )
39+ fakeConfig .APIVersionReturns ("3.210.0" )
40+ actor = NewActor (fakeCloudControllerClient , fakeConfig , nil , nil , nil , clock .NewClock ())
3141 })
3242
3343 Describe ("ApplicationSummary" , func () {
@@ -287,6 +297,155 @@ var _ = Describe("Application Summary Actions", func() {
287297 Expect (fakeCloudControllerClient .GetProcessInstancesArgsForCall (0 )).To (Equal ("some-process-guid" ))
288298 })
289299
300+ Context ("the cloud controller supports embedded process instances" , func () {
301+ BeforeEach (func () {
302+ fakeConfig .APIVersionReturns ("3.211.0" )
303+
304+ listedProcesses := []resources.Process {
305+ {
306+ GUID : "some-process-guid" ,
307+ Type : "some-type" ,
308+ Command : * types .NewFilteredString ("[Redacted Value]" ),
309+ MemoryInMB : types.NullUint64 {Value : 32 , IsSet : true },
310+ AppGUID : "some-app-guid" ,
311+ EmbeddedProcessInstances : & []resources.EmbeddedProcessInstance {
312+ {Index : 0 , State : "RUNNING" , Since : 300 },
313+ {Index : 1 , State : "CRASHED" , Since : 0 },
314+ },
315+ },
316+ {
317+ GUID : "some-process-web-guid" ,
318+ Type : "web" ,
319+ Command : * types .NewFilteredString ("[Redacted Value]" ),
320+ MemoryInMB : types.NullUint64 {Value : 64 , IsSet : true },
321+ AppGUID : "some-app-guid" ,
322+ EmbeddedProcessInstances : & []resources.EmbeddedProcessInstance {
323+ {Index : 0 , State : "RUNNING" , Since : 500 },
324+ {Index : 1 , State : "RUNNING" , Since : 600 },
325+ },
326+ },
327+ }
328+
329+ fakeCloudControllerClient .GetProcessesReturns (
330+ listedProcesses ,
331+ ccv3.Warnings {"get-space-processes-warning" },
332+ nil ,
333+ )
334+ })
335+
336+ It ("uses the embedded process instances" , func () {
337+ Expect (executeErr ).ToNot (HaveOccurred ())
338+ fmt .Println ("================================" )
339+ fmt .Printf ("%#v\n " , summaries )
340+ fmt .Println ("================================" )
341+ Expect (summaries ).To (Equal ([]ApplicationSummary {
342+ {
343+ Application : resources.Application {
344+ Name : "some-app-name" ,
345+ GUID : "some-app-guid" ,
346+ State : constant .ApplicationStarted ,
347+ },
348+ ProcessSummaries : []ProcessSummary {
349+ {
350+ Process : resources.Process {
351+ GUID : "some-process-web-guid" ,
352+ Type : "web" ,
353+ Command : * types .NewFilteredString ("[Redacted Value]" ),
354+ MemoryInMB : types.NullUint64 {Value : 64 , IsSet : true },
355+ AppGUID : "some-app-guid" ,
356+ EmbeddedProcessInstances : & []resources.EmbeddedProcessInstance {
357+ {Index : 0 , State : "RUNNING" , Since : 500 },
358+ {Index : 1 , State : "RUNNING" , Since : 600 },
359+ },
360+ },
361+ InstanceDetails : []ProcessInstance {
362+ {
363+ Index : 0 ,
364+ State : "RUNNING" ,
365+ Uptime : 500 ,
366+ },
367+ {
368+ Index : 1 ,
369+ State : "RUNNING" ,
370+ Uptime : 600 ,
371+ },
372+ },
373+ },
374+ {
375+ Process : resources.Process {
376+ GUID : "some-process-guid" ,
377+ MemoryInMB : types.NullUint64 {Value : 32 , IsSet : true },
378+ Type : "some-type" ,
379+ Command : * types .NewFilteredString ("[Redacted Value]" ),
380+ AppGUID : "some-app-guid" ,
381+ EmbeddedProcessInstances : & []resources.EmbeddedProcessInstance {
382+ {Index : 0 , State : "RUNNING" , Since : 300 },
383+ {Index : 1 , State : "CRASHED" , Since : 0 },
384+ },
385+ },
386+ InstanceDetails : []ProcessInstance {
387+ {
388+ Index : 0 ,
389+ State : "RUNNING" ,
390+ Uptime : 300 ,
391+ },
392+ {
393+ Index : 1 ,
394+ State : "CRASHED" ,
395+ Uptime : 0 ,
396+ },
397+ },
398+ },
399+ },
400+ Routes : []resources.Route {
401+ {
402+ GUID : "some-route-guid" ,
403+ Destinations : []resources.RouteDestination {
404+ {
405+ App : resources.RouteDestinationApp {
406+ GUID : "some-app-guid" ,
407+ },
408+ },
409+ },
410+ },
411+ {
412+ GUID : "some-other-route-guid" ,
413+ Destinations : []resources.RouteDestination {
414+ {
415+ App : resources.RouteDestinationApp {
416+ GUID : "some-app-guid" ,
417+ },
418+ },
419+ },
420+ },
421+ },
422+ },
423+ }))
424+
425+ Expect (warnings ).To (ConsistOf (
426+ "get-apps-warning" ,
427+ "get-space-processes-warning" ,
428+ "get-routes-warning" ,
429+ ))
430+
431+ Expect (fakeCloudControllerClient .GetApplicationsCallCount ()).To (Equal (1 ))
432+ Expect (fakeCloudControllerClient .GetApplicationsArgsForCall (0 )).To (ConsistOf (
433+ ccv3.Query {Key : ccv3 .OrderBy , Values : []string {"name" }},
434+ ccv3.Query {Key : ccv3 .SpaceGUIDFilter , Values : []string {"some-space-guid" }},
435+ ccv3.Query {Key : ccv3 .LabelSelectorFilter , Values : []string {"some-key=some-value" }},
436+ ccv3.Query {Key : ccv3 .PerPage , Values : []string {ccv3 .MaxPerPage }},
437+ ))
438+
439+ Expect (fakeCloudControllerClient .GetProcessesCallCount ()).To (Equal (1 ))
440+ Expect (fakeCloudControllerClient .GetProcessesArgsForCall (0 )).To (ConsistOf (
441+ ccv3.Query {Key : ccv3 .SpaceGUIDFilter , Values : []string {"some-space-guid" }},
442+ ccv3.Query {Key : ccv3 .Embed , Values : []string {"process_instances" }},
443+ ))
444+
445+ Expect (fakeCloudControllerClient .GetProcessInstancesCallCount ()).To (Equal (0 ))
446+ })
447+ })
448+
290449 When ("there is no label selector" , func () {
291450 BeforeEach (func () {
292451 labelSelector = ""
0 commit comments