Skip to content

Commit

Permalink
consistent test style
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-schroeder committed Oct 19, 2016
1 parent 0468948 commit 2d7d131
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 33 deletions.
37 changes: 4 additions & 33 deletions check/cluster_health_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,8 @@ func Test_checkClusterHealth_WhenSomeBrokerMissingInZK_ReportsRed(t *testing.T)
func Test_checkClusterHealth_WhenSomePartitionMissingInZK_ReportsRed(t *testing.T) {
check := newTestCheck()

zkTopics := []ZkTopic{
{
Name: "some-topic",
Partitions: map[int32][]int32{
3: {2, 1},
},
},
}

clusterStatus := check.checkClusterHealth(
healthyMetadata("some-topic"), zkTopics, healthyZkBrokers())
healthyMetadata("some-topic"), partitionMissingZkTopics(), healthyZkBrokers())

if clusterStatus.Status != red {
t.Errorf("CheckHealth reported cluster status as %v, expected %s", clusterStatus.Status, red)
Expand All @@ -66,17 +57,8 @@ func Test_checkClusterHealth_WhenSomePartitionMissingInZK_ReportsRed(t *testing.
func Test_checkClusterHealth_WhenSomeReplicaMissingInZK_ReportsRed(t *testing.T) {
check := newTestCheck()

zkTopics := []ZkTopic{
{
Name: "some-topic",
Partitions: map[int32][]int32{
2: {1},
},
},
}

clusterStatus := check.checkClusterHealth(
healthyMetadata("some-topic"), zkTopics, healthyZkBrokers())
healthyMetadata("some-topic"), replicaMissingZkTopics(), healthyZkBrokers())

if clusterStatus.Status != red {
t.Errorf("CheckHealth reported cluster status as %v, expected %s", clusterStatus.Status, red)
Expand All @@ -86,10 +68,8 @@ func Test_checkClusterHealth_WhenSomeReplicaMissingInZK_ReportsRed(t *testing.T)
func Test_checkClusterHealth_WhenSomeTopicMissingInZK_ReportsRed(t *testing.T) {
check := newTestCheck()

zkTopics := []ZkTopic{}

clusterStatus := check.checkClusterHealth(
healthyMetadata("some-topic"), zkTopics, healthyZkBrokers())
healthyMetadata("some-topic"), []ZkTopic{}, healthyZkBrokers())

if clusterStatus.Status != red {
t.Errorf("CheckHealth reported cluster status as %v, expected %s", clusterStatus.Status, red)
Expand All @@ -99,17 +79,8 @@ func Test_checkClusterHealth_WhenSomeTopicMissingInZK_ReportsRed(t *testing.T) {
func Test_checkClusterHealth_WhenSomeTopicMissingInMetadata_ReportsRed(t *testing.T) {
check := newTestCheck()

zkTopics := []ZkTopic{
{
Name: "some-topic",
Partitions: map[int32][]int32{
3: {2, 1},
},
},
}

clusterStatus := check.checkClusterHealth(
healthyMetadata(), zkTopics, healthyZkBrokers())
healthyMetadata( /* no topic */ ), healthyZkTopics(), healthyZkBrokers())

if clusterStatus.Status != red {
t.Errorf("CheckHealth reported cluster status as %v, expected %s", clusterStatus.Status, red)
Expand Down
20 changes: 20 additions & 0 deletions check/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,26 @@ func healthyZkTopics() []ZkTopic {
}
}

func replicaMissingZkTopics() []ZkTopic {
return []ZkTopic{
{
Name: "some-topic",
Partitions: map[int32][]int32{
2: {1},
},
},
}
}

func partitionMissingZkTopics() []ZkTopic {
return []ZkTopic{
{
Name: "some-topic",
Partitions: map[int32][]int32{},
},
}
}

func healthyZkBrokers() []int32 {
return []int32{1, 2}
}
Expand Down

0 comments on commit 2d7d131

Please sign in to comment.