Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit 5625842

Browse files
dmiusNikolayS
authored andcommitted
fix: L003 generation of recommendations fixed
1 parent 455e134 commit 5625842

File tree

3 files changed

+90
-73
lines changed

3 files changed

+90
-73
lines changed

pghrep/src/checkup/l003/l003.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func L003Process(report L003Report) (checkup.ReportResult, error) {
1818
var tables []string
1919

2020
for _, hostData := range report.Results {
21-
for _, tableData := range hostData.Data {
21+
for _, tableData := range hostData.Data.Tables {
2222
if tableData.CapacityUsedPercent <= MAX_RATIO_PERCENT {
2323
continue
2424
}

pghrep/src/checkup/l003/l003_test.go

Lines changed: 82 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ func TestL003Success(t *testing.T) {
1212

1313
var report L003Report
1414
var hostResult L003ReportHostResult = L003ReportHostResult{
15-
Data: map[string]L003Table{
16-
"test_schema.orders": L003Table{
17-
Table: "test_schema.orders",
18-
Pk: "id",
19-
Type: "int4",
20-
CurrentMaxValue: 80000000,
21-
CapacityUsedPercent: 3.725,
15+
Data: L003ReportHostResultData{
16+
Tables: map[string]L003Table{
17+
"test_schema.orders": L003Table{
18+
Table: "test_schema.orders",
19+
Pk: "id",
20+
Type: "int4",
21+
CurrentMaxValue: 80000000,
22+
CapacityUsedPercent: 3.725,
23+
},
2224
},
25+
MinTableSizeBytes: 0,
2326
},
2427
}
2528

@@ -43,14 +46,17 @@ func TestL003P1_1(t *testing.T) {
4346

4447
var report L003Report
4548
var hostResult L003ReportHostResult = L003ReportHostResult{
46-
Data: map[string]L003Table{
47-
"test_schema.orders": L003Table{
48-
Table: "test_schema.orders",
49-
Pk: "id",
50-
Type: "int4",
51-
CurrentMaxValue: 800000000,
52-
CapacityUsedPercent: 37.25,
49+
Data: L003ReportHostResultData{
50+
Tables: map[string]L003Table{
51+
"test_schema.orders": L003Table{
52+
Table: "test_schema.orders",
53+
Pk: "id",
54+
Type: "int4",
55+
CurrentMaxValue: 80000000,
56+
CapacityUsedPercent: 37.25,
57+
},
5358
},
59+
MinTableSizeBytes: 0,
5460
},
5561
}
5662

@@ -74,21 +80,24 @@ func TestL003P1_N(t *testing.T) {
7480

7581
var report L003Report
7682
var hostResult L003ReportHostResult = L003ReportHostResult{
77-
Data: map[string]L003Table{
78-
"test_schema.orders": L003Table{
79-
Table: "test_schema.orders",
80-
Pk: "id",
81-
Type: "int4",
82-
CurrentMaxValue: 800000000,
83-
CapacityUsedPercent: 37.25,
84-
},
85-
"test_schema.orders_A": L003Table{
86-
Table: "test_schema.orders_A",
87-
Pk: "id",
88-
Type: "int4",
89-
CurrentMaxValue: 300000000,
90-
CapacityUsedPercent: 13.97,
83+
Data: L003ReportHostResultData{
84+
Tables: map[string]L003Table{
85+
"test_schema.orders": L003Table{
86+
Table: "test_schema.orders",
87+
Pk: "id",
88+
Type: "int4",
89+
CurrentMaxValue: 80000000,
90+
CapacityUsedPercent: 37.25,
91+
},
92+
"test_schema.orders_A": L003Table{
93+
Table: "test_schema.orders_A",
94+
Pk: "id",
95+
Type: "int4",
96+
CurrentMaxValue: 300000000,
97+
CapacityUsedPercent: 13.97,
98+
},
9199
},
100+
MinTableSizeBytes: 0,
92101
},
93102
}
94103

@@ -112,49 +121,52 @@ func TestL003P1_6(t *testing.T) {
112121

113122
var report L003Report
114123
var hostResult L003ReportHostResult = L003ReportHostResult{
115-
Data: map[string]L003Table{
116-
"test_schema.orders": L003Table{
117-
Table: "test_schema.orders",
118-
Pk: "id",
119-
Type: "int4",
120-
CurrentMaxValue: 800000000,
121-
CapacityUsedPercent: 37.25,
122-
},
123-
"test_schema.orders_A": L003Table{
124-
Table: "test_schema.orders_A",
125-
Pk: "id",
126-
Type: "int4",
127-
CurrentMaxValue: 300000000,
128-
CapacityUsedPercent: 33.97,
129-
},
130-
"test_schema.orders_B": L003Table{
131-
Table: "test_schema.orders_B",
132-
Pk: "id",
133-
Type: "int4",
134-
CurrentMaxValue: 300000000,
135-
CapacityUsedPercent: 27.97,
136-
},
137-
"test_schema.orders_C": L003Table{
138-
Table: "test_schema.orders_C",
139-
Pk: "id",
140-
Type: "int4",
141-
CurrentMaxValue: 300000000,
142-
CapacityUsedPercent: 25.97,
143-
},
144-
"test_schema.orders_D": L003Table{
145-
Table: "test_schema.orders_D",
146-
Pk: "id",
147-
Type: "int4",
148-
CurrentMaxValue: 300000000,
149-
CapacityUsedPercent: 23.97,
150-
},
151-
"test_schema.orders_E": L003Table{
152-
Table: "test_schema.orders_E",
153-
Pk: "id",
154-
Type: "int4",
155-
CurrentMaxValue: 300000000,
156-
CapacityUsedPercent: 13.97,
124+
Data: L003ReportHostResultData{
125+
Tables: map[string]L003Table{
126+
"test_schema.orders": L003Table{
127+
Table: "test_schema.orders",
128+
Pk: "id",
129+
Type: "int4",
130+
CurrentMaxValue: 800000000,
131+
CapacityUsedPercent: 37.25,
132+
},
133+
"test_schema.orders_A": L003Table{
134+
Table: "test_schema.orders_A",
135+
Pk: "id",
136+
Type: "int4",
137+
CurrentMaxValue: 300000000,
138+
CapacityUsedPercent: 33.97,
139+
},
140+
"test_schema.orders_B": L003Table{
141+
Table: "test_schema.orders_B",
142+
Pk: "id",
143+
Type: "int4",
144+
CurrentMaxValue: 300000000,
145+
CapacityUsedPercent: 27.97,
146+
},
147+
"test_schema.orders_C": L003Table{
148+
Table: "test_schema.orders_C",
149+
Pk: "id",
150+
Type: "int4",
151+
CurrentMaxValue: 300000000,
152+
CapacityUsedPercent: 25.97,
153+
},
154+
"test_schema.orders_D": L003Table{
155+
Table: "test_schema.orders_D",
156+
Pk: "id",
157+
Type: "int4",
158+
CurrentMaxValue: 300000000,
159+
CapacityUsedPercent: 23.97,
160+
},
161+
"test_schema.orders_E": L003Table{
162+
Table: "test_schema.orders_E",
163+
Pk: "id",
164+
Type: "int4",
165+
CurrentMaxValue: 300000000,
166+
CapacityUsedPercent: 13.97,
167+
},
157168
},
169+
MinTableSizeBytes: 0,
158170
},
159171
}
160172

pghrep/src/checkup/l003/l003struct.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ type L003Table struct {
1010
CapacityUsedPercent float64 `json:"capacity_used_percent"`
1111
}
1212

13+
type L003ReportHostResultData struct {
14+
Tables map[string]L003Table `json:"tables"`
15+
MinTableSizeBytes int64 `json:"min_table_size_bytes"`
16+
}
17+
1318
type L003ReportHostResult struct {
14-
Data map[string]L003Table `json:"data"`
15-
NodesJson checkup.ReportLastNodes `json:"nodes.json"`
19+
Data L003ReportHostResultData `json:"data"`
20+
NodesJson checkup.ReportLastNodes `json:"nodes.json"`
1621
}
1722

1823
type L003ReportHostsResults map[string]L003ReportHostResult

0 commit comments

Comments
 (0)