From 9ce862676a8a03239f09d83b2e9541485c07e61d Mon Sep 17 00:00:00 2001 From: geauxvirtual Date: Wed, 16 Sep 2015 13:36:34 -0700 Subject: [PATCH] Remove InfluxDB plugin. Moved to https://github.com/intelsdi-x/pulse-plugin-publisher-influxdb --- .../Godeps/Godeps.json | 34 ----- .../pulse-publisher-influxdb/Godeps/Readme | 5 - .../pulse-publisher-influxdb/README.md | 2 - .../influx/docker_int_test.sh | 28 ---- .../pulse-publisher-influxdb/influx/influx.go | 144 ------------------ .../influx/influx_integration_test.go | 78 ---------- .../pulse-publisher-influxdb/main.go | 13 -- .../pulse-publisher-influxdb/main_test.go | 47 ------ 8 files changed, 351 deletions(-) delete mode 100644 plugin/publisher/pulse-publisher-influxdb/Godeps/Godeps.json delete mode 100644 plugin/publisher/pulse-publisher-influxdb/Godeps/Readme delete mode 100644 plugin/publisher/pulse-publisher-influxdb/README.md delete mode 100755 plugin/publisher/pulse-publisher-influxdb/influx/docker_int_test.sh delete mode 100644 plugin/publisher/pulse-publisher-influxdb/influx/influx.go delete mode 100644 plugin/publisher/pulse-publisher-influxdb/influx/influx_integration_test.go delete mode 100644 plugin/publisher/pulse-publisher-influxdb/main.go delete mode 100644 plugin/publisher/pulse-publisher-influxdb/main_test.go diff --git a/plugin/publisher/pulse-publisher-influxdb/Godeps/Godeps.json b/plugin/publisher/pulse-publisher-influxdb/Godeps/Godeps.json deleted file mode 100644 index 26f0e93df..000000000 --- a/plugin/publisher/pulse-publisher-influxdb/Godeps/Godeps.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "ImportPath": "github.com/intelsdi-x/pulse/plugin/publisher/pulse-publisher-influxdb", - "GoVersion": "go1.4.2", - "Deps": [ - { - "ImportPath": "github.com/influxdb/influxdb/client", - "Comment": "v0.9.1", - "Rev": "8b3219e74fcc3843a6f4901bdf00e905642b6bd6" - }, - { - "ImportPath": "github.com/influxdb/influxdb/influxql", - "Comment": "v0.9.1", - "Rev": "8b3219e74fcc3843a6f4901bdf00e905642b6bd6" - }, - { - "ImportPath": "github.com/intelsdi-x/gomit", - "Rev": "4f098da2bbb51d787be003e4abfbc25d01837564" - }, - { - "ImportPath": "github.com/jtolds/gls", - "Rev": "f1ac7f4f24f50328e6bc838ca4437d1612a0243c" - }, - { - "ImportPath": "github.com/smartystreets/assertions", - "Comment": "1.5.0-379-g75acd40", - "Rev": "75acd402ca38dc205641a826bb58b9de014926dd" - }, - { - "ImportPath": "github.com/smartystreets/goconvey/convey", - "Comment": "1.5.0-386-geb2e83c", - "Rev": "eb2e83c1df892d2c9ad5a3c85672da30be585dfd" - } - ] -} diff --git a/plugin/publisher/pulse-publisher-influxdb/Godeps/Readme b/plugin/publisher/pulse-publisher-influxdb/Godeps/Readme deleted file mode 100644 index 4cdaa53d5..000000000 --- a/plugin/publisher/pulse-publisher-influxdb/Godeps/Readme +++ /dev/null @@ -1,5 +0,0 @@ -This directory tree is generated automatically by godep. - -Please do not edit. - -See https://github.com/tools/godep for more information. diff --git a/plugin/publisher/pulse-publisher-influxdb/README.md b/plugin/publisher/pulse-publisher-influxdb/README.md deleted file mode 100644 index 7997dc2b8..000000000 --- a/plugin/publisher/pulse-publisher-influxdb/README.md +++ /dev/null @@ -1,2 +0,0 @@ -This plugin currently support influxdb version 0.9.0. - diff --git a/plugin/publisher/pulse-publisher-influxdb/influx/docker_int_test.sh b/plugin/publisher/pulse-publisher-influxdb/influx/docker_int_test.sh deleted file mode 100755 index 61746c0f5..000000000 --- a/plugin/publisher/pulse-publisher-influxdb/influx/docker_int_test.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# This script assumes you have docker machine installed, pass the machine name, and have docker client pointed to it. -# After we add docker support to integration testing this should be removed. This is purely for laptop tesing this plugin before PR. - -#docker-machine start $1 -stop_dm=true -if docker-machine ls | grep "${1}" | grep Running ; then - echo "docker machine is already running" - stop_dm=false -else - echo "starting docker machine" - docker-machine start $1 - stop_dm=true -fi -eval "$(docker-machine env $1)" -#redirecting stdout and err to cleanup output -docker run --name pulse_int_influxdb -d -p 8083:8083 -p 8086:8086 --expose 8090 --expose 8099 tutum/influxdb:staging-0.9.0-rc 2>&1 > /dev/null || docker start pulse_int_influxdb -export PULSE_INFLUXDB_HOST=`docker-machine ip $1` -#redirect stdout and err to cleanup output -curl -G --fail --silent --show-error http://${PULSE_INFLUXDB_HOST}:8086/query --data-urlencode "q=CREATE DATABASE test" > /dev/null -sleep 3 -go test -if $stop_dm ; then - echo "stopping docker machine" - docker-machine stop $1 -fi -#docker-machine stopte $1 diff --git a/plugin/publisher/pulse-publisher-influxdb/influx/influx.go b/plugin/publisher/pulse-publisher-influxdb/influx/influx.go deleted file mode 100644 index dbd81fb94..000000000 --- a/plugin/publisher/pulse-publisher-influxdb/influx/influx.go +++ /dev/null @@ -1,144 +0,0 @@ -package influx - -import ( - "bytes" - "encoding/gob" - "fmt" - "net/url" - "strings" - "time" - - log "github.com/Sirupsen/logrus" - - "github.com/intelsdi-x/pulse/control/plugin" - "github.com/intelsdi-x/pulse/control/plugin/cpolicy" - "github.com/intelsdi-x/pulse/core/ctypes" - - "github.com/influxdb/influxdb/client" -) - -const ( - name = "influx" - version = 1 - pluginType = plugin.PublisherPluginType -) - -// Meta returns a plugin meta data -func Meta() *plugin.PluginMeta { - return plugin.NewPluginMeta(name, version, pluginType, []string{plugin.PulseGOBContentType}, []string{plugin.PulseGOBContentType}) -} - -//NewInfluxPublisher returns an instance of the InfuxDB publisher -func NewInfluxPublisher() *influxPublisher { - return &influxPublisher{} -} - -type influxPublisher struct { -} - -func (f *influxPublisher) GetConfigPolicy() cpolicy.ConfigPolicy { - cp := cpolicy.New() - config := cpolicy.NewPolicyNode() - - r1, err := cpolicy.NewStringRule("host", true) - handleErr(err) - r1.Description = "Influxdb host" - config.Add(r1) - - r2, err := cpolicy.NewIntegerRule("port", true) - handleErr(err) - r2.Description = "Influxdb port" - config.Add(r2) - - r3, err := cpolicy.NewStringRule("database", true) - handleErr(err) - r3.Description = "Influxdb db name" - config.Add(r3) - - r4, err := cpolicy.NewStringRule("user", true) - handleErr(err) - r4.Description = "Influxdb user" - config.Add(r4) - - r5, err := cpolicy.NewStringRule("password", true) - handleErr(err) - r5.Description = "Influxdb password" - config.Add(r4) - - cp.Add([]string{""}, config) - return *cp -} - -// Publish publishes metric data to influxdb -// currently only 0.9 version of influxdb are supported -func (f *influxPublisher) Publish(contentType string, content []byte, config map[string]ctypes.ConfigValue) error { - logger := log.New() - var metrics []plugin.PluginMetricType - - switch contentType { - case plugin.PulseGOBContentType: - dec := gob.NewDecoder(bytes.NewBuffer(content)) - if err := dec.Decode(&metrics); err != nil { - logger.Printf("Error decoding: error=%v content=%v", err, content) - return err - } - default: - logger.Printf("Error unknown content type '%v'", contentType) - return fmt.Errorf("Unknown content type '%s'", contentType) - } - - u, err := url.Parse(fmt.Sprintf("http://%s:%d", config["host"].(ctypes.ConfigValueStr).Value, config["port"].(ctypes.ConfigValueInt).Value)) - if err != nil { - handleErr(err) - } - - conf := client.Config{ - URL: *u, - Username: config["user"].(ctypes.ConfigValueStr).Value, - Password: config["password"].(ctypes.ConfigValueStr).Value, - UserAgent: "pulse-publisher", - } - - con, err := client.NewClient(conf) - if err != nil { - logger.Fatal(err) - } - - dur, ver, err := con.Ping() - if err != nil { - logger.Printf("ERROR publishing %v to %v with %v %v", metrics, config, ver, dur) - handleErr(err) - } - - pts := make([]client.Point, len(metrics)) - for i, m := range metrics { - pts[i] = client.Point{ - Measurement: strings.Join(m.Namespace(), "/"), - Fields: map[string]interface{}{ - "value": m.Data(), - }, - } - } - - bps := client.BatchPoints{ - Time: time.Now(), - Precision: "s", - Points: pts, - Database: config["database"].(ctypes.ConfigValueStr).Value, - RetentionPolicy: "default", - } - - _, err = con.Write(bps) - if err != nil { - logger.Printf("Error: '%s' printing points: %+v", err.Error(), bps) - } - //logger.Printf("writing %+v \n", bps) - - return nil -} - -func handleErr(e error) { - if e != nil { - panic(e) - } -} diff --git a/plugin/publisher/pulse-publisher-influxdb/influx/influx_integration_test.go b/plugin/publisher/pulse-publisher-influxdb/influx/influx_integration_test.go deleted file mode 100644 index 599f9214d..000000000 --- a/plugin/publisher/pulse-publisher-influxdb/influx/influx_integration_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// -// +build integration - -package influx - -import ( - "bytes" - "encoding/gob" - "errors" - "log" - "os" - "testing" - - "github.com/intelsdi-x/pulse/control/plugin" - "github.com/intelsdi-x/pulse/core/ctypes" - - . "github.com/smartystreets/goconvey/convey" -) - -func TestInfluxPublish(t *testing.T) { - config := make(map[string]ctypes.ConfigValue) - - Convey("TestInflux", t, func() { - config["host"] = ctypes.ConfigValueStr{Value: os.Getenv("PULSE_INFLUXDB_HOST")} - config["port"] = ctypes.ConfigValueInt{Value: 8086} - config["user"] = ctypes.ConfigValueStr{Value: "root"} - config["password"] = ctypes.ConfigValueStr{Value: "root"} - config["database"] = ctypes.ConfigValueStr{Value: "test"} - - ip := NewInfluxPublisher() - So(ip, ShouldNotBeNil) - - policy := ip.GetConfigPolicyNode() - So(policy, ShouldNotBeNil) - cfg, errs := policy.Process(config) - So(cfg, ShouldNotBeNil) - So(errs.HasErrors(), ShouldBeFalse) - So(cfg, ShouldNotBeNil) - - Convey("Publish", func() { - var buf bytes.Buffer - metrics := []plugin.PluginMetric{ - *plugin.NewPluginMetric([]string{"foo"}, 99), - } - enc := gob.NewEncoder(&buf) - enc.Encode(metrics) - Convey("int", func() { - err := ip.Publish(plugin.ContentTypes[plugin.PulseGobContentType], buf.Bytes(), *cfg, log.New(os.Stdout, "influx_test", log.LstdFlags)) - So(err, ShouldBeNil) - }) - - Convey("float", func() { - metrics = []plugin.PluginMetric{ - *plugin.NewPluginMetric([]string{"foo"}, 3.141), - } - buf.Reset() - enc = gob.NewEncoder(&buf) - enc.Encode(metrics) - err := ip.Publish(plugin.ContentTypes[plugin.PulseGobContentType], buf.Bytes(), *cfg, log.New(os.Stdout, "influx_test", log.LstdFlags)) - So(err, ShouldBeNil) - }) - - Convey("Unsupported data value error", func() { - metrics = []plugin.PluginMetric{ - *plugin.NewPluginMetric([]string{"foo"}, "bar"), - } - buf.Reset() - enc = gob.NewEncoder(&buf) - enc.Encode(metrics) - err := ip.Publish(plugin.ContentTypes[plugin.PulseGobContentType], buf.Bytes(), *cfg, log.New(os.Stdout, "influx_test", log.LstdFlags)) - So(err, ShouldNotBeNil) - So(err, ShouldResemble, errors.New("Unsupported data type 'string'")) - - }) - }) - - }) -} diff --git a/plugin/publisher/pulse-publisher-influxdb/main.go b/plugin/publisher/pulse-publisher-influxdb/main.go deleted file mode 100644 index 1117b9798..000000000 --- a/plugin/publisher/pulse-publisher-influxdb/main.go +++ /dev/null @@ -1,13 +0,0 @@ -package main - -import ( - "os" - - "github.com/intelsdi-x/pulse/control/plugin" - "github.com/intelsdi-x/pulse/plugin/publisher/pulse-publisher-influxdb/influx" -) - -func main() { - meta := influx.Meta() - plugin.Start(meta, influx.NewInfluxPublisher(), os.Args[1]) -} diff --git a/plugin/publisher/pulse-publisher-influxdb/main_test.go b/plugin/publisher/pulse-publisher-influxdb/main_test.go deleted file mode 100644 index b5ecdd422..000000000 --- a/plugin/publisher/pulse-publisher-influxdb/main_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package main - -import ( - "fmt" - "os" - "path" - "testing" - - "github.com/intelsdi-x/pulse/control" - "github.com/intelsdi-x/pulse/plugin/helper" - . "github.com/smartystreets/goconvey/convey" -) - -var ( - PluginName = "pulse-publisher-influx" - PluginType = "publisher" - PulsePath = os.Getenv("PULSE_PATH") - PluginPath = path.Join(PulsePath, "plugin", PluginName) -) - -func TestFilePublisherLoad(t *testing.T) { - // These tests only work if PULSE_PATH is known. - // It is the responsibility of the testing framework to - // build the plugins first into the build dir. - if PulsePath != "" { - // Helper plugin trigger build if possible for this plugin - helper.BuildPlugin(PluginType, PluginName) - // - //TODO cannot test this locally. We need AMQP and integration tests. - SkipConvey("ensure plugin loads and responds", t, func() { - c := control.New() - c.Start() - _, err := c.Load(PluginPath) - - So(err, ShouldBeNil) - }) - } else { - fmt.Printf("PULSE_PATH not set. Cannot test %s plugin.\n", PluginName) - } -} - -func TestMain(t *testing.T) { - Convey("ensure plugin loads and responds", t, func() { - os.Args = []string{"", "{\"NoDaemon\": true}"} - So(func() { main() }, ShouldNotPanic) - }) -}