-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(cherry picked from commit a5d86cb)
- Loading branch information
Showing
17 changed files
with
531 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
// +build integration | ||
|
||
package broker | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/elastic/beats/libbeat/tests/compose" | ||
mbtest "github.com/elastic/beats/metricbeat/mb/testing" | ||
// Register input module and metricset | ||
_ "github.com/elastic/beats/metricbeat/module/jolokia" | ||
_ "github.com/elastic/beats/metricbeat/module/jolokia/jmx" | ||
) | ||
|
||
func TestData(t *testing.T) { | ||
service := compose.EnsureUp(t, "kafka", | ||
compose.UpWithTimeout(600*time.Second), | ||
compose.UpWithAdvertisedHostEnvFileForPort(9092), | ||
) | ||
|
||
m := mbtest.NewFetcher(t, getConfig(service.HostForPort(8779))) | ||
m.WriteEvents(t, "") | ||
} | ||
|
||
func TestFetch(t *testing.T) { | ||
service := compose.EnsureUp(t, "kafka", | ||
compose.UpWithTimeout(600*time.Second), | ||
compose.UpWithAdvertisedHostEnvFileForPort(9092), | ||
) | ||
|
||
m := mbtest.NewFetcher(t, getConfig(service.HostForPort(8779))) | ||
events, errs := m.FetchEvents() | ||
if len(errs) > 0 { | ||
t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs) | ||
} | ||
assert.NotEmpty(t, events) | ||
t.Logf("%s/%s event: %+v", m.Module().Name(), m.Name(), events[0]) | ||
} | ||
|
||
func getConfig(host string) map[string]interface{} { | ||
return map[string]interface{}{ | ||
"module": "kafka", | ||
"metricsets": []string{"broker"}, | ||
"hosts": []string{host}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package broker | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/elastic/beats/metricbeat/mb" | ||
// Register input module and metricset | ||
_ "github.com/elastic/beats/metricbeat/module/jolokia" | ||
_ "github.com/elastic/beats/metricbeat/module/jolokia/jmx" | ||
) | ||
|
||
func init() { | ||
// To be moved to some kind of helper | ||
os.Setenv("BEAT_STRICT_PERMS", "false") | ||
mb.Registry.SetSecondarySource(mb.NewLightModulesSource("../../../module")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.