OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import operator | |
6 import random | 5 import random |
7 import unittest | 6 import unittest |
8 | 7 |
9 import gae_ts_mon | 8 import gae_ts_mon |
10 import mock | 9 import mock |
11 | 10 |
12 from google.appengine.ext import testbed | 11 from google.appengine.ext import testbed |
13 from google.appengine.api.memcache import memcache_service_pb | 12 from google.appengine.api.memcache import memcache_service_pb |
14 | 13 |
15 from infra_libs.ts_mon import memcache_metric_store | 14 from infra_libs.ts_mon import memcache_metric_store |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 with self.assertRaises(errors.MonitoringDecreasingValueError): | 157 with self.assertRaises(errors.MonitoringDecreasingValueError): |
159 self.store.modify_multi([ | 158 self.store.modify_multi([ |
160 metric_store.Modification( | 159 metric_store.Modification( |
161 self.gauge_metric.name, (), 'set', (41, True))]) | 160 self.gauge_metric.name, (), 'set', (41, True))]) |
162 | 161 |
163 def test_modify_multi_incr(self): | 162 def test_modify_multi_incr(self): |
164 self.gauge_metric.set(42) | 163 self.gauge_metric.set(42) |
165 | 164 |
166 self.store.modify_multi([ | 165 self.store.modify_multi([ |
167 metric_store.Modification( | 166 metric_store.Modification( |
168 self.gauge_metric.name, (), 'incr', (4, operator.add))]) | 167 self.gauge_metric.name, (), 'incr', (4, None))]) |
169 | 168 |
170 self.assertEqual(46, self.gauge_metric.get()) | 169 self.assertEqual(46, self.gauge_metric.get()) |
171 | 170 |
172 def test_modify_multi_incr_negative(self): | 171 def test_modify_multi_incr_negative(self): |
173 with self.assertRaises(errors.MonitoringDecreasingValueError): | 172 with self.assertRaises(errors.MonitoringDecreasingValueError): |
174 self.store.modify_multi([ | 173 self.store.modify_multi([ |
175 metric_store.Modification( | 174 metric_store.Modification( |
176 self.gauge_metric.name, (), 'incr', (-1, operator.add))]) | 175 self.gauge_metric.name, (), 'incr', (-1, None))]) |
177 | 176 |
178 def test_modify_multi_bad_type(self): | 177 def test_modify_multi_bad_type(self): |
179 with self.assertRaises(errors.UnknownModificationTypeError): | 178 with self.assertRaises(errors.UnknownModificationTypeError): |
180 self.store.modify_multi([ | 179 self.store.modify_multi([ |
181 metric_store.Modification( | 180 metric_store.Modification( |
182 self.gauge_metric.name, (), 'bad', (-1, operator.add))]) | 181 self.gauge_metric.name, (), 'bad', (-1, None))]) |
183 | 182 |
184 def test_modify_multi_with_fields(self): | 183 def test_modify_multi_with_fields(self): |
185 self.store.modify_multi([ | 184 self.store.modify_multi([ |
186 metric_store.Modification( | 185 metric_store.Modification( |
187 self.gauge_metric.name, (('f', 1),), 'set', (41, False)), | 186 self.gauge_metric.name, (('f', 1),), 'set', (41, False)), |
188 metric_store.Modification( | 187 metric_store.Modification( |
189 self.gauge_metric.name, (('f', 2),), 'set', (42, False))]) | 188 self.gauge_metric.name, (('f', 2),), 'set', (42, False))]) |
190 | 189 |
191 self.assertEqual(41, self.gauge_metric.get({'f': 1})) | 190 self.assertEqual(41, self.gauge_metric.get({'f': 1})) |
192 self.assertEqual(42, self.gauge_metric.get({'f': 2})) | 191 self.assertEqual(42, self.gauge_metric.get({'f': 2})) |
OLD | NEW |