Skip to content

Commit

Permalink
Fix panic in TestKibanaEsSample (#1756)
Browse files Browse the repository at this point in the history
* Fix panic in TestKibanaEsSample

* Use the default value
  • Loading branch information
barkbay authored Sep 19, 2019
1 parent 6504362 commit b629b0d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions test/e2e/test/elasticsearch/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,26 @@ import (
func MustNumDataNodes(es v1alpha1.Elasticsearch) int {
var numNodes int
for _, n := range es.Spec.Nodes {
config, err := common.NewCanonicalConfigFrom(n.Config.Data)
if err != nil {
panic(err)
}
nodeCfg, err := settings.CanonicalConfig{
CanonicalConfig: config,
}.Unpack()
if err != nil {
panic(err)
}
if nodeCfg.Node.Data {
if isDataNode(n) {
numNodes += int(n.NodeCount)
}
}
return numNodes
}

func isDataNode(node v1alpha1.NodeSpec) bool {
if node.Config == nil {
return v1alpha1.DefaultCfg.Node.Data // if not specified use the default
}
config, err := common.NewCanonicalConfigFrom(node.Config.Data)
if err != nil {
panic(err)
}
nodeCfg, err := settings.CanonicalConfig{
CanonicalConfig: config,
}.Unpack()
if err != nil {
panic(err)
}
return nodeCfg.Node.Data
}

0 comments on commit b629b0d

Please sign in to comment.