Skip to content

Commit b7bb540

Browse files
authored
fix: DiskState parsing error (#31)
1 parent a1c283b commit b7bb540

File tree

4 files changed

+60
-6
lines changed

4 files changed

+60
-6
lines changed

deploy/cruisecontrol/capacityJBOD.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,45 @@
1212
"NW_OUT": "10000"
1313
},
1414
"doc": "The default capacity for a broker with multiple logDirs each on a separate heterogeneous disk."
15+
},
16+
{
17+
"brokerId": "0",
18+
"capacity": {
19+
"DISK": {
20+
"/var/lib/kafka/data0": "100000",
21+
"/var/lib/kafka/data1": "100000"
22+
},
23+
"CPU": "100",
24+
"NW_IN": "10000",
25+
"NW_OUT": "10000"
26+
},
27+
"doc": "The default capacity for a broker with multiple logDirs each on a separate heterogeneous disk."
28+
},
29+
{
30+
"brokerId": "1",
31+
"capacity": {
32+
"DISK": {
33+
"/var/lib/kafka/data0": "100000",
34+
"/var/lib/kafka/data1": "100000"
35+
},
36+
"CPU": "100",
37+
"NW_IN": "10000",
38+
"NW_OUT": "10000"
39+
},
40+
"doc": "The default capacity for a broker with multiple logDirs each on a separate heterogeneous disk."
41+
},
42+
{
43+
"brokerId": "2",
44+
"capacity": {
45+
"DISK": {
46+
"/var/lib/kafka/data0": "100000",
47+
"/var/lib/kafka/data1": "100000"
48+
},
49+
"CPU": "100",
50+
"NW_IN": "10000",
51+
"NW_OUT": "10000"
52+
},
53+
"doc": "The default capacity for a broker with multiple logDirs each on a separate heterogeneous disk."
1554
}
1655
]
1756
}

integration_test/kafka_cluster_load_test.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ limitations under the License.
1717
package integration_test
1818

1919
import (
20-
"github.com/banzaicloud/go-cruise-control/integration_test/helpers"
21-
"github.com/banzaicloud/go-cruise-control/pkg/api"
2220
. "github.com/onsi/ginkgo/v2"
2321
. "github.com/onsi/gomega"
22+
23+
"github.com/banzaicloud/go-cruise-control/integration_test/helpers"
24+
"github.com/banzaicloud/go-cruise-control/pkg/api"
2425
)
2526

2627
var _ = Describe("Kafka Cluster Load", Label("api:load", "api:state"), func() {
@@ -65,6 +66,11 @@ var _ = Describe("Kafka Cluster Load", Label("api:load", "api:state"), func() {
6566
"rack-2",
6667
},
6768
}
69+
70+
expectedBrokerDisks = []string{
71+
"/var/lib/kafka/data0",
72+
"/var/lib/kafka/data1",
73+
}
6874
)
6975

7076
BeforeEach(func(ctx SpecContext) {
@@ -80,7 +86,10 @@ var _ = Describe("Kafka Cluster Load", Label("api:load", "api:state"), func() {
8086
Context("for the last hour", func() {
8187
It("should result no errors", func(ctx SpecContext) {
8288
By("requesting load information")
83-
req := api.KafkaClusterLoadRequestWithDefaults()
89+
req := &api.KafkaClusterLoadRequest{
90+
AllowCapacityEstimation: true,
91+
PopulateDiskInfo: true,
92+
}
8493
resp, err := cruisecontrol.KafkaClusterLoad(ctx, req)
8594
Expect(err).NotTo(HaveOccurred())
8695
Expect(resp.Failed()).To(BeFalse())
@@ -94,6 +103,11 @@ var _ = Describe("Kafka Cluster Load", Label("api:load", "api:state"), func() {
94103
Expect(ok).To(BeTrue())
95104
Expect(broker.Host).To(Equal(expectedBroker.Host))
96105
Expect(broker.Rack).To(Equal(expectedBroker.Rack))
106+
107+
for _, disk := range expectedBrokerDisks {
108+
_, ok := broker.DiskState[disk]
109+
Expect(ok).To(BeTrue())
110+
}
97111
}
98112

99113
By("getting host load statistics")

makefile.d/50-deploy.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ start: ## Spin up local development environment
1616
up \
1717
--detach \
1818
--remove-orphans \
19-
--timeout $(DOCKER_COMPOSE_TIMEOUT) \
19+
-t $(DOCKER_COMPOSE_TIMEOUT) \
2020
--wait
2121

2222
.PHONY: stop
@@ -28,4 +28,4 @@ stop: ## Stop local development environment
2828
down \
2929
--remove-orphans \
3030
--volumes \
31-
--timeout $(DOCKER_COMPOSE_TIMEOUT)
31+
-t $(DOCKER_COMPOSE_TIMEOUT)

pkg/types/broker_stats.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ type BrokerLoadStats struct {
122122
NetworkOutCapacity float64 `json:"NetworkOutCapacity"`
123123
LeaderNwInRate float64 `json:"LeaderNwInRate"`
124124
DiskPct float64 `json:"DiskPct"`
125-
DiskState []DiskStats `json:"DiskState"`
125+
126+
DiskState map[string]DiskStats `json:"DiskState"`
126127
}
127128

128129
const (

0 commit comments

Comments
 (0)