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