Пример #1
0
 def test_non_bool_raises(self):
   m = metrics.BooleanMetric('test')
   with self.assertRaises(errors.MonitoringInvalidValueTypeError):
     m.set(object())
   with self.assertRaises(errors.MonitoringInvalidValueTypeError):
     m.set('True')
   with self.assertRaises(errors.MonitoringInvalidValueTypeError):
     m.set(123)
Пример #2
0
 def test_toggle(self):
   m = metrics.BooleanMetric('test')
   m.set(True)
   self.assertEquals(m.get(), True)
   self.assertEquals(self.fake_send.call_count, 1)
   m.toggle()
   self.assertEquals(m.get(), False)
   self.assertEquals(self.fake_send.call_count, 2)
Пример #3
0
 def test_populate_value(self):
   pb = metrics_pb2.MetricsData()
   m = metrics.BooleanMetric('test')
   m._populate_value(pb, True)
   self.assertEquals(pb.boolean_value, True)
Пример #4
0
 def test_set(self):
   m = metrics.BooleanMetric('test')
   m.set(False)
   self.assertEquals(m.get(), False)
   self.assertEquals(self.fake_send.call_count, 1)
Пример #5
0
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Metrics common to all tasks and devices."""

from infra_libs.ts_mon import metrics

# TODO(dsansome): Add more metrics for git revision, cipd package version,
# uptime, etc.
up = metrics.BooleanMetric('presence/up')


def init():
    up.set(True)