Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #15 from geauxvirtual/tb/support_current_pulse_head
Browse files Browse the repository at this point in the history
Update Pulse dependencies
  • Loading branch information
geauxvirtual committed Sep 15, 2015
2 parents b048ebc + c7f37b9 commit 0afefb9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions influx/influx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const (
name = "influx"
version = 3
version = 4
pluginType = plugin.PublisherPluginType
)

Expand All @@ -35,7 +35,8 @@ func NewInfluxPublisher() *influxPublisher {
type influxPublisher struct {
}

func (f *influxPublisher) GetConfigPolicyNode() cpolicy.ConfigPolicyNode {
func (f *influxPublisher) GetConfigPolicy() cpolicy.ConfigPolicy {
cp := cpolicy.New()
config := cpolicy.NewPolicyNode()

r1, err := cpolicy.NewStringRule("host", true)
Expand Down Expand Up @@ -63,7 +64,8 @@ func (f *influxPublisher) GetConfigPolicyNode() cpolicy.ConfigPolicyNode {
r5.Description = "Influxdb password"
config.Add(r4)

return *config
cp.Add([]string{""}, config)
return *cp
}

// Publish publishes metric data to influxdb
Expand Down
4 changes: 2 additions & 2 deletions influx/influx_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func TestInfluxPublish(t *testing.T) {
config["database"] = ctypes.ConfigValueStr{Value: "test"}

ip := NewInfluxPublisher()
policy := ip.GetConfigPolicyNode()
cfg, _ := policy.Process(config)
cp := ip.GetConfigPolicy()
cfg, _ := cp.Get([]string{""}).Process(config)

Convey("Publish integer metric", func() {
metrics := []plugin.PluginMetricType{
Expand Down
34 changes: 28 additions & 6 deletions influx/influx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/intelsdi-x/pulse/control/plugin"
"github.com/intelsdi-x/pulse/control/plugin/cpolicy"
"github.com/intelsdi-x/pulse/core/ctypes"
. "github.com/smartystreets/goconvey/convey"
)

Expand All @@ -27,13 +28,34 @@ func TestInfluxDBPlugin(t *testing.T) {
Convey("So ip should be of influxPublisher type", func() {
So(ip, ShouldHaveSameTypeAs, &influxPublisher{})
})
Convey("ip.GetConfigPolicyNode() should return a config policy node", func() {
config := ip.GetConfigPolicyNode()
Convey("So config should not be nil", func() {
So(config, ShouldNotBeNil)
Convey("ip.GetConfigPolicy() should return a config policy", func() {
configPolicy := ip.GetConfigPolicy()
Convey("So config policy should not be nil", func() {
So(configPolicy, ShouldNotBeNil)
})
Convey("So config should be a cpolicy.ConfigPolicyNode", func() {
So(config, ShouldHaveSameTypeAs, cpolicy.ConfigPolicyNode{})
Convey("So config policy should be a cpolicy.ConfigPolicy", func() {
So(configPolicy, ShouldHaveSameTypeAs, cpolicy.ConfigPolicy{})
})
testConfig := make(map[string]ctypes.ConfigValue)
testConfig["host"] = ctypes.ConfigValueStr{Value: "localhost"}
testConfig["port"] = ctypes.ConfigValueInt{Value: 8086}
testConfig["user"] = ctypes.ConfigValueStr{Value: "root"}
testConfig["password"] = ctypes.ConfigValueStr{Value: "root"}
testConfig["database"] = ctypes.ConfigValueStr{Value: "test"}
cfg, errs := configPolicy.Get([]string{""}).Process(testConfig)
Convey("So config policy should process testConfig and return a config", func() {
So(cfg, ShouldNotBeNil)
})
Convey("So testConfig processing should return no errors", func() {
So(errs.HasErrors(), ShouldBeFalse)
})
testConfig["port"] = ctypes.ConfigValueStr{Value: "8086"}
cfg, errs = configPolicy.Get([]string{""}).Process(testConfig)
Convey("So config policy should not return a config after processing invalid testConfig", func() {
So(cfg, ShouldBeNil)
})
Convey("So testConfig processing should return errors", func() {
So(errs.HasErrors(), ShouldBeTrue)
})
})
})
Expand Down

0 comments on commit 0afefb9

Please sign in to comment.