Skip to content

Commit

Permalink
Show org and space quotas (#2299)
Browse files Browse the repository at this point in the history
* org-quota and space-quota now show log volume

* code currently assumes responses with log limits. Consider
  backward compatibility before shipping.

* add log volume to space-quotas and org-quotas commands

* will show "unlimited" for old CC API's which is technically correct

* Fix unit tests in ccv3

Co-authored-by: Rebecca Roberts <robertsre@vmware.com>
Co-authored-by: Matthew Kocher <mkocher@vmware.com>
Co-authored-by: Carson Long <lcarson@vmware.com>
  • Loading branch information
3 people authored Jul 26, 2022
1 parent 7f8423a commit 744f248
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 53 deletions.
39 changes: 27 additions & 12 deletions api/cloudcontroller/ccv3/organization_quota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ var _ = Describe("Organization Quotas", func() {
"total_memory_in_mb": 5120,
"per_process_memory_in_mb": 1024,
"total_instances": 10,
"per_app_tasks": 5
"per_app_tasks": 5,
"log_rate_limit_in_bytes_per_second": 8
},
"services": {
"paid_services_allowed": true,
Expand Down Expand Up @@ -103,7 +104,8 @@ var _ = Describe("Organization Quotas", func() {
"total_memory_in_mb": 10240,
"per_process_memory_in_mb": 1024,
"total_instances": 8,
"per_app_tasks": 5
"per_app_tasks": 5,
"log_rate_limit_in_bytes_per_second": 16
},
"services": {
"paid_services_allowed": false,
Expand Down Expand Up @@ -156,6 +158,7 @@ var _ = Describe("Organization Quotas", func() {
TotalMemory: &types.NullInt{Value: 5120, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 10, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 8, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 10, IsSet: true},
Expand All @@ -175,6 +178,7 @@ var _ = Describe("Organization Quotas", func() {
TotalMemory: &types.NullInt{Value: 10240, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 8, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 16, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 8, IsSet: true},
Expand Down Expand Up @@ -211,7 +215,8 @@ var _ = Describe("Organization Quotas", func() {
"total_memory_in_mb": 10240,
"per_process_memory_in_mb": 1024,
"total_instances": 8,
"per_app_tasks": 5
"per_app_tasks": 5,
"log_rate_limit_in_bytes_per_second": 8
},
"services": {
"paid_services_allowed": false,
Expand Down Expand Up @@ -257,6 +262,7 @@ var _ = Describe("Organization Quotas", func() {
TotalMemory: &types.NullInt{Value: 10240, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 8, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 8, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 8, IsSet: true},
Expand Down Expand Up @@ -337,7 +343,8 @@ var _ = Describe("Organization Quotas", func() {
"total_memory_in_mb": 5120,
"per_process_memory_in_mb": 1024,
"total_instances": 10,
"per_app_tasks": 5
"per_app_tasks": 5,
"log_rate_limit_in_bytes_per_second": 8
},
"services": {
"paid_services_allowed": true,
Expand Down Expand Up @@ -384,6 +391,7 @@ var _ = Describe("Organization Quotas", func() {
TotalMemory: &types.NullInt{Value: 5120, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 10, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 8, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 10, IsSet: true},
Expand Down Expand Up @@ -460,6 +468,7 @@ var _ = Describe("Organization Quotas", func() {
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
Expand Down Expand Up @@ -488,7 +497,8 @@ var _ = Describe("Organization Quotas", func() {
"total_memory_in_mb": 2048,
"per_process_memory_in_mb": 1024,
"total_instances": null,
"per_app_tasks": null
"per_app_tasks": null,
"log_rate_limit_in_bytes_per_second": null
},
"services": {
"paid_services_allowed": true,
Expand All @@ -512,9 +522,10 @@ var _ = Describe("Organization Quotas", func() {
expectedBody := map[string]interface{}{
"name": "elephant-trunk",
"apps": map[string]interface{}{
"total_memory_in_mb": 2048,
"per_process_memory_in_mb": 1024,
"total_instances": nil,
"total_memory_in_mb": 2048,
"per_process_memory_in_mb": 1024,
"total_instances": nil,
"log_rate_limit_in_bytes_per_second": nil,
},
"services": map[string]interface{}{
"paid_services_allowed": true,
Expand Down Expand Up @@ -711,6 +722,7 @@ var _ = Describe("Organization Quotas", func() {
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 8, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
Expand All @@ -735,7 +747,8 @@ var _ = Describe("Organization Quotas", func() {
"total_memory_in_mb": 2048,
"per_process_memory_in_mb": 1024,
"total_instances": null,
"per_app_tasks": null
"per_app_tasks": null,
"log_rate_limit_in_bytes_per_second": 8
},
"services": {
"paid_services_allowed": true,
Expand All @@ -759,9 +772,10 @@ var _ = Describe("Organization Quotas", func() {
expectedBody := map[string]interface{}{
"name": "elephant-trunk",
"apps": map[string]interface{}{
"total_memory_in_mb": 2048,
"per_process_memory_in_mb": 1024,
"total_instances": nil,
"total_memory_in_mb": 2048,
"per_process_memory_in_mb": 1024,
"total_instances": nil,
"log_rate_limit_in_bytes_per_second": 8,
},
"services": map[string]interface{}{
"paid_services_allowed": true,
Expand Down Expand Up @@ -791,6 +805,7 @@ var _ = Describe("Organization Quotas", func() {
TotalMemory: &types.NullInt{IsSet: true, Value: 2048},
InstanceMemory: &types.NullInt{IsSet: true, Value: 1024},
TotalAppInstances: &types.NullInt{IsSet: false, Value: 0},
TotalLogVolume: &types.NullInt{Value: 8, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{IsSet: true, Value: 0},
Expand Down
54 changes: 37 additions & 17 deletions api/cloudcontroller/ccv3/space_quota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var _ = Describe("Space Quotas", func() {

})

Describe("CreateSpaceQuotas", func() {
Describe("CreateSpaceQuota", func() {
JustBeforeEach(func() {
createdSpaceQuota, warnings, executeErr = client.CreateSpaceQuota(inputSpaceQuota)
})
Expand All @@ -144,6 +144,7 @@ var _ = Describe("Space Quotas", func() {
TotalMemory: &types.NullInt{IsSet: true, Value: 2},
InstanceMemory: &types.NullInt{IsSet: true, Value: 3},
TotalAppInstances: &types.NullInt{IsSet: true, Value: 4},
TotalLogVolume: &types.NullInt{IsSet: true, Value: 8},
},
Services: resources.ServiceLimit{
PaidServicePlans: &trueValue,
Expand All @@ -166,7 +167,8 @@ var _ = Describe("Space Quotas", func() {
"total_memory_in_mb": 2,
"per_process_memory_in_mb": 3,
"total_instances": 4,
"per_app_tasks": 900
"per_app_tasks": 900,
"log_rate_limit_in_bytes_per_second": 8
},
"services": {
"paid_services_allowed": true,
Expand Down Expand Up @@ -200,9 +202,10 @@ var _ = Describe("Space Quotas", func() {
expectedBody := map[string]interface{}{
"name": "my-space-quota",
"apps": map[string]interface{}{
"total_memory_in_mb": 2,
"per_process_memory_in_mb": 3,
"total_instances": 4,
"total_memory_in_mb": 2,
"per_process_memory_in_mb": 3,
"total_instances": 4,
"log_rate_limit_in_bytes_per_second": 8,
},
"services": map[string]interface{}{
"paid_services_allowed": true,
Expand Down Expand Up @@ -242,6 +245,7 @@ var _ = Describe("Space Quotas", func() {
TotalMemory: &types.NullInt{IsSet: true, Value: 2},
InstanceMemory: &types.NullInt{IsSet: true, Value: 3},
TotalAppInstances: &types.NullInt{IsSet: true, Value: 4},
TotalLogVolume: &types.NullInt{IsSet: true, Value: 8},
},
Services: resources.ServiceLimit{
PaidServicePlans: &trueValue,
Expand All @@ -266,6 +270,7 @@ var _ = Describe("Space Quotas", func() {
TotalMemory: &types.NullInt{IsSet: true, Value: 2},
InstanceMemory: &types.NullInt{IsSet: true, Value: 3},
TotalAppInstances: &types.NullInt{IsSet: true, Value: 4},
TotalLogVolume: &types.NullInt{IsSet: true, Value: 8},
},
Services: resources.ServiceLimit{
PaidServicePlans: &trueValue,
Expand All @@ -289,7 +294,8 @@ var _ = Describe("Space Quotas", func() {
"total_memory_in_mb": 2,
"per_process_memory_in_mb": 3,
"total_instances": 4,
"per_app_tasks": 5
"per_app_tasks": 5,
"log_rate_limit_in_bytes_per_second": 8
},
"services": {
"paid_services_allowed": true,
Expand Down Expand Up @@ -324,9 +330,10 @@ var _ = Describe("Space Quotas", func() {
expectedBody := map[string]interface{}{
"name": "my-space-quota",
"apps": map[string]interface{}{
"total_memory_in_mb": 2,
"per_process_memory_in_mb": 3,
"total_instances": 4,
"total_memory_in_mb": 2,
"per_process_memory_in_mb": 3,
"total_instances": 4,
"log_rate_limit_in_bytes_per_second": 8,
},
"services": map[string]interface{}{
"paid_services_allowed": true,
Expand Down Expand Up @@ -372,6 +379,7 @@ var _ = Describe("Space Quotas", func() {
TotalMemory: &types.NullInt{IsSet: true, Value: 2},
InstanceMemory: &types.NullInt{IsSet: true, Value: 3},
TotalAppInstances: &types.NullInt{IsSet: true, Value: 4},
TotalLogVolume: &types.NullInt{IsSet: true, Value: 8},
},
Services: resources.ServiceLimit{
PaidServicePlans: &trueValue,
Expand Down Expand Up @@ -522,7 +530,8 @@ var _ = Describe("Space Quotas", func() {
"total_memory_in_mb": 10240,
"per_process_memory_in_mb": 1024,
"total_instances": 8,
"per_app_tasks": 5
"per_app_tasks": 5,
"log_rate_limit_in_bytes_per_second": 8
},
"services": {
"paid_services_allowed": false,
Expand Down Expand Up @@ -566,6 +575,7 @@ var _ = Describe("Space Quotas", func() {
TotalMemory: &types.NullInt{Value: 10240, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 8, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 8, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 8, IsSet: true},
Expand Down Expand Up @@ -663,7 +673,8 @@ var _ = Describe("Space Quotas", func() {
"total_memory_in_mb": 5120,
"per_process_memory_in_mb": 1024,
"total_instances": 10,
"per_app_tasks": 5
"per_app_tasks": 5,
"log_rate_limit_in_bytes_per_second": 8
},
"services": {
"paid_services_allowed": true,
Expand Down Expand Up @@ -703,7 +714,8 @@ var _ = Describe("Space Quotas", func() {
"total_memory_in_mb": 10240,
"per_process_memory_in_mb": 1024,
"total_instances": 8,
"per_app_tasks": 5
"per_app_tasks": 5,
"log_rate_limit_in_bytes_per_second": 16
},
"services": {
"paid_services_allowed": false,
Expand Down Expand Up @@ -756,6 +768,7 @@ var _ = Describe("Space Quotas", func() {
TotalMemory: &types.NullInt{Value: 5120, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 10, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 8, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 10, IsSet: true},
Expand All @@ -776,6 +789,7 @@ var _ = Describe("Space Quotas", func() {
TotalMemory: &types.NullInt{Value: 10240, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 8, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 16, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 8, IsSet: true},
Expand Down Expand Up @@ -812,7 +826,8 @@ var _ = Describe("Space Quotas", func() {
"total_memory_in_mb": 10240,
"per_process_memory_in_mb": 1024,
"total_instances": 8,
"per_app_tasks": 5
"per_app_tasks": 5,
"log_rate_limit_in_bytes_per_second": 8
},
"services": {
"paid_services_allowed": false,
Expand Down Expand Up @@ -858,6 +873,7 @@ var _ = Describe("Space Quotas", func() {
TotalMemory: &types.NullInt{Value: 10240, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 8, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 8, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 8, IsSet: true},
Expand Down Expand Up @@ -1011,6 +1027,7 @@ var _ = Describe("Space Quotas", func() {
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
Expand All @@ -1035,7 +1052,8 @@ var _ = Describe("Space Quotas", func() {
"total_memory_in_mb": 2048,
"per_process_memory_in_mb": 1024,
"total_instances": null,
"per_app_tasks": null
"per_app_tasks": null,
"log_rate_limit_in_bytes_per_second": null
},
"services": {
"paid_services_allowed": true,
Expand All @@ -1056,9 +1074,10 @@ var _ = Describe("Space Quotas", func() {
expectedBody := map[string]interface{}{
"name": "elephant-trunk",
"apps": map[string]interface{}{
"total_memory_in_mb": 2048,
"per_process_memory_in_mb": 1024,
"total_instances": nil,
"total_memory_in_mb": 2048,
"per_process_memory_in_mb": 1024,
"total_instances": nil,
"log_rate_limit_in_bytes_per_second": nil,
},
"services": map[string]interface{}{
"paid_services_allowed": true,
Expand Down Expand Up @@ -1088,6 +1107,7 @@ var _ = Describe("Space Quotas", func() {
TotalMemory: &types.NullInt{IsSet: true, Value: 2048},
InstanceMemory: &types.NullInt{IsSet: true, Value: 1024},
TotalAppInstances: &types.NullInt{IsSet: false, Value: 0},
TotalLogVolume: &types.NullInt{IsSet: false, Value: 0},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{IsSet: true, Value: 0},
Expand Down
2 changes: 2 additions & 0 deletions command/v7/org_quota_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ var _ = Describe("Org Quota Command", func() {
TotalMemory: &types.NullInt{IsSet: true, Value: 2048},
InstanceMemory: &types.NullInt{IsSet: true, Value: 1024},
TotalAppInstances: &types.NullInt{IsSet: true, Value: 2},
TotalLogVolume: &types.NullInt{IsSet: true, Value: 512},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{IsSet: false},
Expand Down Expand Up @@ -138,6 +139,7 @@ var _ = Describe("Org Quota Command", func() {
Expect(testUI.Out).To(Say(`paid service plans:\s+disallowed`))
Expect(testUI.Out).To(Say(`app instances:\s+2`))
Expect(testUI.Out).To(Say(`route ports:\s+unlimited`))
Expect(testUI.Out).To(Say(`log volume per second:\s+512B`))
})
})
})
11 changes: 6 additions & 5 deletions command/v7/org_quotas_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var _ = Describe("org-quotas command", func() {
TotalMemory: &types.NullInt{Value: 1048576, IsSet: true},
InstanceMemory: &types.NullInt{Value: 32, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 3, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 3, IsSet: true},
Expand All @@ -91,8 +92,8 @@ var _ = Describe("org-quotas command", func() {
It("retrieves and displays all quotas", func() {
Expect(executeErr).NotTo(HaveOccurred())
Expect(fakeActor.GetOrganizationQuotasCallCount()).To(Equal(1))
Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports`))
Expect(testUI.Out).To(Say(`org-quota-1\s+1T\s+32M\s+5\s+3\s+allowed\s+3\s+2`))
Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports\s+log volume per second`))
Expect(testUI.Out).To(Say(`org-quota-1\s+1T\s+32M\s+5\s+3\s+allowed\s+3\s+2\s+512B`))
})

When("there are limits that have not been configured", func() {
Expand All @@ -105,6 +106,7 @@ var _ = Describe("org-quotas command", func() {
TotalMemory: &types.NullInt{Value: 0, IsSet: false},
InstanceMemory: &types.NullInt{Value: 0, IsSet: false},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false},
Expand All @@ -123,9 +125,8 @@ var _ = Describe("org-quotas command", func() {

It("should convert default values from the API into readable outputs", func() {
Expect(executeErr).NotTo(HaveOccurred())
Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports`))
Expect(testUI.Out).To(Say(`default\s+unlimited\s+unlimited\s+unlimited\s+unlimited\s+allowed\s+unlimited\s+unlimited`))

Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports\s+log volume per second`))
Expect(testUI.Out).To(Say(`default\s+unlimited\s+unlimited\s+unlimited\s+unlimited\s+allowed\s+unlimited\s+unlimited\s+unlimited`))
})
})
})
Expand Down
Loading

0 comments on commit 744f248

Please sign in to comment.