Skip to content

Commit f651465

Browse files
author
lijianguo
committed
chore(ps):drycc ps:list show autoscale num
1 parent 71bb1be commit f651465

4 files changed

Lines changed: 42 additions & 42 deletions

File tree

api/ps.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type Pods struct {
1515
Name string `json:"name,omitempty"`
1616
State string `json:"state,omitempty"`
1717
Started time.Time `json:"started,omitempty"`
18-
Replicas int `json:"replicas,omitempty"`
18+
Replicas string `json:"replicas,omitempty"`
1919
}
2020

2121
// PodsList defines a collection of app pods.
@@ -29,7 +29,7 @@ func (p PodsList) Less(i, j int) bool { return p[i].Name < p[j].Name }
2929
type PodType struct {
3030
Type string
3131
PodsList PodsList
32-
Replicas int
32+
Replicas string
3333
Status string
3434
}
3535

api/ps_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99

1010
func TestPodsListSorted(t *testing.T) {
1111
pods := PodsList{
12-
{"", "web", "web.fsdfgh4", "up", time.Time{}, 4},
13-
{"", "web", "web.asdfgh1", "up", time.Time{}, 4},
14-
{"", "web", "web.csdfgh3", "up", time.Time{}, 4},
15-
{"", "web", "web.bsdfgh2", "up", time.Time{}, 4},
12+
{"", "web", "web.fsdfgh4", "up", time.Time{}, "4"},
13+
{"", "web", "web.asdfgh1", "up", time.Time{}, "4"},
14+
{"", "web", "web.csdfgh3", "up", time.Time{}, "4"},
15+
{"", "web", "web.bsdfgh2", "up", time.Time{}, "4"},
1616
}
1717

1818
sort.Sort(pods)
@@ -28,9 +28,9 @@ func TestPodsListSorted(t *testing.T) {
2828

2929
func TestPodTypesSorted(t *testing.T) {
3030
podTypes := PodTypes{
31-
{"worker", PodsList{}, 4, "started"},
32-
{"web", PodsList{}, 4, "started"},
33-
{"clock", PodsList{}, 4, "started"},
31+
{"worker", PodsList{}, "4", "started"},
32+
{"web", PodsList{}, "4", "started"},
33+
{"clock", PodsList{}, "4", "started"},
3434
}
3535

3636
sort.Sort(podTypes)

ps/ps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func ByType(processes api.PodsList) api.PodTypes {
129129
if !exists {
130130
p := api.PodsList{process}
131131
status := "started"
132-
if process.State == "stopped" && process.Replicas != 0 {
132+
if process.State == "stopped" && process.Replicas != "0" {
133133
status = "stopped"
134134
}
135135
if process.Name == "" {

ps/ps_test.go

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const processesFixture string = `
2525
"name": "example-go-v2-web-45678",
2626
"state": "up",
2727
"started": "2016-02-13T00:47:52",
28-
"replicas": 1
28+
"replicas": "1"
2929
}
3030
]
3131
}`
@@ -37,7 +37,7 @@ const restartAllFixture string = `[
3737
"name": "example-go-v2-web-45678",
3838
"state": "up",
3939
"started": "2016-02-13T00:47:52",
40-
"replicas": 1
40+
"replicas": "1"
4141
}
4242
]
4343
`
@@ -49,7 +49,7 @@ const restartWorkerFixture string = `[
4949
"name": "example-go-v2-worker-45678",
5050
"state": "up",
5151
"started": "2016-02-13T00:47:52",
52-
"replicas": 1
52+
"replicas": "1"
5353
}
5454
]
5555
`
@@ -61,7 +61,7 @@ const restartWebTwoFixture string = `[
6161
"name": "example-go-v2-web-45678",
6262
"state": "up",
6363
"started": "2016-02-13T00:47:52",
64-
"replicas": 1
64+
"replicas": "1"
6565
}
6666
]
6767
`
@@ -182,7 +182,7 @@ func TestProcessesList(t *testing.T) {
182182
Name: "example-go-v2-web-45678",
183183
State: "up",
184184
Started: started,
185-
Replicas: 1,
185+
Replicas: "1",
186186
},
187187
}
188188

@@ -228,7 +228,7 @@ func TestAppsRestart(t *testing.T) {
228228
Name: "example-go-v2-web-45678",
229229
State: "up",
230230
Started: started,
231-
Replicas: 1,
231+
Replicas: "1",
232232
},
233233
},
234234
},
@@ -242,7 +242,7 @@ func TestAppsRestart(t *testing.T) {
242242
Name: "example-go-v2-worker-45678",
243243
State: "up",
244244
Started: started,
245-
Replicas: 1,
245+
Replicas: "1",
246246
},
247247
},
248248
},
@@ -256,7 +256,7 @@ func TestAppsRestart(t *testing.T) {
256256
Name: "example-go-v2-worker-45678",
257257
State: "up",
258258
Started: started,
259-
Replicas: 1,
259+
Replicas: "1",
260260
},
261261
},
262262
},
@@ -270,7 +270,7 @@ func TestAppsRestart(t *testing.T) {
270270
Name: "example-go-v2-web-45678",
271271
State: "up",
272272
Started: started,
273-
Replicas: 1,
273+
Replicas: "1",
274274
},
275275
},
276276
},
@@ -359,52 +359,52 @@ func TestByType(t *testing.T) {
359359
{
360360
Type: "abc",
361361
PodsList: api.PodsList{
362-
{Type: "abc", Name: "1", Started: started, Replicas: 3, State: "up"},
363-
{Type: "abc", Name: "2", Started: started, Replicas: 3, State: "up"},
364-
{Type: "abc", Name: "3", Started: started, Replicas: 3, State: "up"},
362+
{Type: "abc", Name: "1", Started: started, Replicas: "3", State: "up"},
363+
{Type: "abc", Name: "2", Started: started, Replicas: "3", State: "up"},
364+
{Type: "abc", Name: "3", Started: started, Replicas: "3", State: "up"},
365365
},
366-
Replicas: 3,
366+
Replicas: "3",
367367
Status: "started",
368368
},
369369
{
370370
Type: "job",
371371
PodsList: api.PodsList{},
372-
Replicas: 3,
372+
Replicas: "3",
373373
Status: "stopped",
374374
},
375375
{
376376
Type: "web",
377377
PodsList: api.PodsList{
378-
{Type: "web", Name: "test1", Started: started, Replicas: 3, State: "up"},
379-
{Type: "web", Name: "test2", Started: started, Replicas: 3, State: "up"},
380-
{Type: "web", Name: "test3", Started: started, Replicas: 3, State: "up"},
378+
{Type: "web", Name: "test1", Started: started, Replicas: "3", State: "up"},
379+
{Type: "web", Name: "test2", Started: started, Replicas: "3", State: "up"},
380+
{Type: "web", Name: "test3", Started: started, Replicas: "3", State: "up"},
381381
},
382-
Replicas: 3,
382+
Replicas: "3",
383383
Status: "started",
384384
},
385385
{
386386
Type: "worker",
387387
PodsList: api.PodsList{
388-
{Type: "worker", Name: "a", Started: started, Replicas: 3, State: "up"},
389-
{Type: "worker", Name: "b", Started: started, Replicas: 3, State: "up"},
390-
{Type: "worker", Name: "c", Started: started, Replicas: 3, State: "up"},
388+
{Type: "worker", Name: "a", Started: started, Replicas: "3", State: "up"},
389+
{Type: "worker", Name: "b", Started: started, Replicas: "3", State: "up"},
390+
{Type: "worker", Name: "c", Started: started, Replicas: "3", State: "up"},
391391
},
392-
Replicas: 3,
392+
Replicas: "3",
393393
Status: "started",
394394
},
395395
}
396396

397397
input := api.PodsList{
398-
{Type: "worker", Name: "c", Started: started, Replicas: 3, State: "up"},
399-
{Type: "abc", Name: "2", Started: started, Replicas: 3, State: "up"},
400-
{Type: "worker", Name: "b", Started: started, Replicas: 3, State: "up"},
401-
{Type: "web", Name: "test1", Started: started, Replicas: 3, State: "up"},
402-
{Type: "web", Name: "test3", Started: started, Replicas: 3, State: "up"},
403-
{Type: "abc", Name: "1", Started: started, Replicas: 3, State: "up"},
404-
{Type: "worker", Name: "a", Started: started, Replicas: 3, State: "up"},
405-
{Type: "abc", Name: "3", Started: started, Replicas: 3, State: "up"},
406-
{Type: "web", Name: "test2", Started: started, Replicas: 3, State: "up"},
407-
{Type: "job", Replicas: 3, State: "stopped"},
398+
{Type: "worker", Name: "c", Started: started, Replicas: "3", State: "up"},
399+
{Type: "abc", Name: "2", Started: started, Replicas: "3", State: "up"},
400+
{Type: "worker", Name: "b", Started: started, Replicas: "3", State: "up"},
401+
{Type: "web", Name: "test1", Started: started, Replicas: "3", State: "up"},
402+
{Type: "web", Name: "test3", Started: started, Replicas: "3", State: "up"},
403+
{Type: "abc", Name: "1", Started: started, Replicas: "3", State: "up"},
404+
{Type: "worker", Name: "a", Started: started, Replicas: "3", State: "up"},
405+
{Type: "abc", Name: "3", Started: started, Replicas: "3", State: "up"},
406+
{Type: "web", Name: "test2", Started: started, Replicas: "3", State: "up"},
407+
{Type: "job", Replicas: "3", State: "stopped"},
408408
}
409409

410410
actual := ByType(input)

0 commit comments

Comments
 (0)