Example #1
0
			interval, str := computeHistogramInterval(&tr, 60)
			Expect(str).To(Equal("60.000s"))
			Expect(interval).To(BeNumerically("~", 60.0))
		})
	})

	Context("computeRealSecondsInInterval on a two minutes time window, 1 minute interval", func() {
		var tr datetime.Timerange
		BeforeEach(func() {
			tr.From = datetime.MustParseJsTime("2015-01-02T15:03:10.000Z")
			tr.To = datetime.MustParseJsTime("2015-01-02T15:04:30.000Z")
		})

		It("should get smaller than 1 minute interval at the start", func() {
			secs := computeRealSecondsInInterval(60,
				datetime.MustParseTime("2015-01-02T15:03:00.000Z"), &tr)
			Expect(secs).To(BeNumerically("~", 50.0))
		})

		It("should get smaller than 1 minute interval at the end", func() {
			secs := computeRealSecondsInInterval(60,
				datetime.MustParseTime("2015-01-02T15:04:00.000Z"), &tr)
			Expect(secs).To(BeNumerically("~", 30.0))
		})

		It("should get exactly 1 minute in the middle", func() {
			secs := computeRealSecondsInInterval(60,
				datetime.MustParseTime("2015-01-02T15:03:20.000Z"), &tr)
			Expect(secs).To(BeNumerically("~", 60.0))
		})
	})
Example #2
0
	"bonitosrv/elasticsearch"
	"encoding/json"
	"testing"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("volumeLine visualization", func() {

	var viz volumeLine
	var interval Interval
	BeforeEach(func() {
		viz = volumeLine{}
		interval = Interval{
			From:          datetime.MustParseTime("2015-01-02T15:04:00.000Z"),
			To:            datetime.MustParseTime("2015-01-02T15:05:00.000Z"),
			BucketTsSize:  "30s",
			BucketSeconds: 30,
			Seconds:       60,
		}
	})

	Context("buildEsAggs", func() {
		It("should create a date_histogram aggregation", func() {
			var config = ConfigRaw{
				Name:  "volumehist",
				Type:  "volume-line",
				Index: 1,
				Config: json.RawMessage(`{
					"ts_field": "timestamp",