Esempio n. 1
0
        public virtual void TestGet()
        {
            MetricsCache cache = new MetricsCache();

            NUnit.Framework.Assert.IsNull("empty", cache.Get("r", Arrays.AsList(MakeTag("t",
                                                                                        "t"))));
            MetricsRecord mr = MakeRecord("r", Arrays.AsList(MakeTag("t", "t")), Arrays.AsList
                                              (MakeMetric("m", 1)));

            cache.Update(mr);
            MetricsCache.Record cr = cache.Get("r", mr.Tags());
            Log.Debug("tags=" + mr.Tags() + " cr=" + cr);
            NUnit.Framework.Assert.IsNotNull("Got record", cr);
            Assert.Equal("contains 1 metric", 1, cr.Metrics().Count);
            CheckMetricValue("new metric value", cr, "m", 1);
        }
Esempio n. 2
0
        public virtual void TestOverflow()
        {
            MetricsCache cache = new MetricsCache();

            MetricsCache.Record      cr;
            ICollection <MetricsTag> t0 = Arrays.AsList(MakeTag("t0", "0"));

            for (int i = 0; i < MetricsCache.MaxRecsPerNameDefault + 1; ++i)
            {
                cr = cache.Update(MakeRecord("r", Arrays.AsList(MakeTag("t" + i, string.Empty + i
                                                                        )), Arrays.AsList(MakeMetric("m", i))));
                CheckMetricValue("new metric value", cr, "m", i);
                if (i < MetricsCache.MaxRecsPerNameDefault)
                {
                    NUnit.Framework.Assert.IsNotNull("t0 is still there", cache.Get("r", t0));
                }
            }
            NUnit.Framework.Assert.IsNull("t0 is gone", cache.Get("r", t0));
        }