예제 #1
0
func metricAPI(st api.Connection) (metricsmanager.MetricsManagerClient, error) {
	client, err := metricsmanager.NewClient(st)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return client, nil
}
예제 #2
0
func (s *metricsManagerSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)
	manager, err := metricsmanager.NewClient(s.APIState)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(manager, gc.NotNil)
	s.manager = manager
}
예제 #3
0
파일: manifold.go 프로젝트: kat-co/juju
// manifoldStart creates a runner for the metrics workers, given a base.APICaller.
func manifoldStart(apiCaller base.APICaller) (worker.Worker, error) {
	client, err := metricsmanager.NewClient(apiCaller)
	if err != nil {
		return nil, errors.Trace(err)
	}
	w, err := newMetricsManager(client, nil)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return w, nil
}
예제 #4
0
파일: cleanup_test.go 프로젝트: zhouqt/juju
// TestCleaner create 2 metrics, one old and one new.
// After a single run of the cleanup worker it expects the
// old one to be deleted
func (s *CleanupSuite) TestCleaner(c *gc.C) {
	unit := s.Factory.MakeUnit(c, nil)
	oldTime := time.Now().Add(-(time.Hour * 25))
	now := time.Now()
	oldMetric := s.Factory.MakeMetric(c, &factory.MetricParams{Unit: unit, Sent: true, Time: &oldTime})
	newMetric := s.Factory.MakeMetric(c, &factory.MetricParams{Unit: unit, Sent: true, Time: &now})

	notify := make(chan struct{})
	client := metricsmanager.NewClient(s.APIState)
	worker := metricworker.NewCleanup(client, notify)
	defer worker.Kill()
	select {
	case <-notify:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("the cleanup function should have fired by now")
	}
	_, err := s.State.MetricBatch(newMetric.UUID())
	c.Assert(err, gc.IsNil)

	_, err = s.State.MetricBatch(oldMetric.UUID())
	c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
예제 #5
0
파일: client_test.go 프로젝트: zhouqt/juju
func (s *metricsManagerSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)
	s.manager = metricsmanager.NewClient(s.APIState)
	c.Assert(s.manager, gc.NotNil)
}