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

Commit

Permalink
Changed published timestamp into metric's collection timestamp
Browse files Browse the repository at this point in the history
+ incrementing the version of plugin
+ updating file-publisher version required by some tests
  • Loading branch information
IzabellaRaulin committed Nov 6, 2015
1 parent d7ae0b3 commit 8a6cc67
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions control/control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -940,15 +940,15 @@ func TestPublishMetrics(t *testing.T) {
<-lpe.done
So(err, ShouldBeNil)
So(len(c.pluginManager.all()), ShouldEqual, 1)
lp, err2 := c.pluginManager.get("publisher:file:2")
lp, err2 := c.pluginManager.get("publisher:file:3")
So(err2, ShouldBeNil)
So(lp.Name(), ShouldResemble, "file")
So(lp.ConfigPolicy, ShouldNotBeNil)

Convey("Subscribe to file publisher with good config", func() {
n := cdata.NewNode()
config.Plugins.Publisher.Plugins[lp.Name()] = newPluginConfigItem(optAddPluginConfigItem("file", ctypes.ConfigValueStr{Value: "/tmp/pulse-TestPublishMetrics.out"}))
pool, errp := c.pluginRunner.AvailablePlugins().getOrCreatePool("publisher:file:2")
pool, errp := c.pluginRunner.AvailablePlugins().getOrCreatePool("publisher:file:3")
So(errp, ShouldBeNil)
pool.subscribe("1", unboundSubscriptionType)
err := c.pluginRunner.runPlugin(lp.Path)
Expand All @@ -963,7 +963,7 @@ func TestPublishMetrics(t *testing.T) {
enc := gob.NewEncoder(&buf)
enc.Encode(metrics)
contentType := plugin.PulseGOBContentType
errs := c.PublishMetrics(contentType, buf.Bytes(), "file", 2, n.Table())
errs := c.PublishMetrics(contentType, buf.Bytes(), "file", 3, n.Table())
So(errs, ShouldBeNil)
ap := c.AvailablePlugins()
So(ap, ShouldNotBeEmpty)
Expand Down
6 changes: 3 additions & 3 deletions mgmt/rest/client/client_func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func TestPulseClient(t *testing.T) {
So(p3.Err, ShouldBeNil)
So(p3.LoadedPlugins, ShouldNotBeEmpty)
So(p3.LoadedPlugins[0].Name, ShouldEqual, "file")
So(p3.LoadedPlugins[0].Version, ShouldEqual, 2)
So(p3.LoadedPlugins[0].Version, ShouldEqual, 3)
So(p3.LoadedPlugins[0].LoadedTime().Unix(), ShouldBeLessThanOrEqualTo, time.Now().Unix())
})
Convey("there should be three loaded plugins", func() {
Expand Down Expand Up @@ -451,10 +451,10 @@ func TestPulseClient(t *testing.T) {
So(p2.Version, ShouldEqual, 2)
So(p2.Type, ShouldEqual, "collector")

p3 := c.UnloadPlugin("publisher", "file", 2)
p3 := c.UnloadPlugin("publisher", "file", 3)
So(p3.Err, ShouldBeNil)
So(p3.Name, ShouldEqual, "file")
So(p3.Version, ShouldEqual, 2)
So(p3.Version, ShouldEqual, 3)
So(p3.Type, ShouldEqual, "publisher")
})
Convey("unload when only one plugin loaded", func() {
Expand Down
8 changes: 2 additions & 6 deletions plugin/publisher/pulse-publisher-file/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ import (
"encoding/gob"
"errors"
"fmt"
"time"
// "fmt"
"os"
// "strings"
// "time"

log "github.com/Sirupsen/logrus"

Expand All @@ -40,7 +36,7 @@ import (

const (
name = "file"
version = 2
version = 3
pluginType = plugin.PublisherPluginType
)

Expand Down Expand Up @@ -81,7 +77,7 @@ func (f *filePublisher) Publish(contentType string, content []byte, config map[s
if source == "" {
source = "unknown"
}
w.WriteString(fmt.Sprintf("%v|%v|%v|%v\n", time.Now().Local(), m.Namespace(), m.Data(), source))
w.WriteString(fmt.Sprintf("%v|%v|%v|%v\n", m.Timestamp(), m.Namespace(), m.Data(), source))
}
w.Flush()

Expand Down
2 changes: 1 addition & 1 deletion scheduler/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestCollectPublishWorkflow(t *testing.T) {
w.CollectNode.AddMetric("/intel/dummy/foo", 2)
w.CollectNode.AddConfigItem("/intel/dummy/foo", "password", "secret")

pu := wmap.NewPublishNode("file", 2)
pu := wmap.NewPublishNode("file", 3)
pu.AddConfigItem("file", "/tmp/pulse-TestCollectPublishWorkflow.out")

pr := wmap.NewProcessNode("passthru", 1)
Expand Down

0 comments on commit 8a6cc67

Please sign in to comment.