~ubuntu-branches/ubuntu/vivid/ceilometer/vivid

« back to all changes in this revision

Viewing changes to ceilometer/tests/test_bin.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-03-06 14:44:28 UTC
  • mto: (28.1.1 utopic-proposed) (1.2.1)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: package-import@ubuntu.com-20140306144428-rvphsh4igwyulzf0
Tags: upstream-2014.1~b3
ImportĀ upstreamĀ versionĀ 2014.1~b3

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
class BinTestCase(base.BaseTestCase):
34
34
    def setUp(self):
35
35
        super(BinTestCase, self).setUp()
36
 
        content = "[database]\n"\
37
 
                  "connection=log://localhost\n"
 
36
        content = ("[database]\n"
 
37
                   "connection=log://localhost\n")
38
38
        self.tempfile = fileutils.write_to_tempfile(content=content,
39
39
                                                    prefix='ceilometer',
40
40
                                                    suffix='.conf')
48
48
                                 "--config-file=%s" % self.tempfile])
49
49
        self.assertEqual(subp.wait(), 0)
50
50
 
51
 
    def test_run_expirer(self):
52
 
        subp = subprocess.Popen(['ceilometer-expirer',
53
 
                                 "--config-file=%s" % self.tempfile])
54
 
        self.assertEqual(subp.wait(), 0)
55
 
 
56
 
 
57
 
class BinSendCounterTestCase(base.BaseTestCase):
 
51
    def test_run_expirer_ttl_disabled(self):
 
52
        subp = subprocess.Popen(['ceilometer-expirer',
 
53
                                 '-d',
 
54
                                 "--config-file=%s" % self.tempfile],
 
55
                                stderr=subprocess.PIPE)
 
56
        __, err = subp.communicate()
 
57
        self.assertEqual(subp.poll(), 0)
 
58
        self.assertIn("Nothing to clean", err)
 
59
 
 
60
    def test_run_expirer_ttl_enabled(self):
 
61
        content = ("[database]\n"
 
62
                   "time_to_live=1\n"
 
63
                   "connection=log://localhost\n")
 
64
        self.tempfile = fileutils.write_to_tempfile(content=content,
 
65
                                                    prefix='ceilometer',
 
66
                                                    suffix='.conf')
 
67
        subp = subprocess.Popen(['ceilometer-expirer',
 
68
                                 '-d',
 
69
                                 "--config-file=%s" % self.tempfile],
 
70
                                stderr=subprocess.PIPE)
 
71
        __, err = subp.communicate()
 
72
        self.assertEqual(subp.poll(), 0)
 
73
        self.assertIn("Dropping data with TTL 1", err)
 
74
 
 
75
 
 
76
class BinSendSampleTestCase(base.BaseTestCase):
58
77
    def setUp(self):
59
 
        super(BinSendCounterTestCase, self).setUp()
 
78
        super(BinSendSampleTestCase, self).setUp()
60
79
        pipeline_cfg_file = self.path_get('etc/ceilometer/pipeline.yaml')
61
80
        content = "[DEFAULT]\n"\
62
81
                  "rpc_backend=ceilometer.openstack.common.rpc.impl_fake\n"\
67
86
                                                    suffix='.conf')
68
87
 
69
88
    def tearDown(self):
70
 
        super(BinSendCounterTestCase, self).tearDown()
 
89
        super(BinSendSampleTestCase, self).tearDown()
71
90
        os.remove(self.tempfile)
72
91
 
73
92
    def test_send_counter_run(self):
74
 
        subp = subprocess.Popen([self.path_get('bin/ceilometer-send-counter'),
 
93
        subp = subprocess.Popen(['ceilometer-send-sample',
75
94
                                 "--config-file=%s" % self.tempfile,
76
 
                                 "--counter-resource=someuuid",
77
 
                                 "--counter-name=mycounter"])
 
95
                                 "--sample-resource=someuuid",
 
96
                                 "--sample-name=mycounter"])
78
97
        self.assertEqual(subp.wait(), 0)
79
98
 
80
99