]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Support for storing more than one samples
authorFranciszek Gorski <fagorski9@gmail.com>
Thu, 6 Jun 2019 17:28:30 +0000 (19:28 +0200)
committerRazvan Becheriu <razvan@isc.org>
Mon, 15 Jul 2019 12:19:52 +0000 (15:19 +0300)
src/lib/stats/observation.cc
src/lib/stats/tests/observation_unittest.cc

index c82c1db47b413cf1c63b045781c088b4d69ba7d4..3e7417386a9efab49ab8a7c585d3b5ac9574fc55 100644 (file)
@@ -188,7 +188,7 @@ void Observation::setValueInternal(SampleType value, StorageType& storage,
                 storage.front().second - storage.back().second;
             // removing samples until the range_of_storage
             // stops exceeding the duration limit
-            while (range_of_storage > max_sample_age_.second) {
+            while (range_of_storage >= max_sample_age.second) {
                 storage.pop_back();
                 range_of_storage =
                     storage.front().second - storage.back().second;
@@ -317,8 +317,7 @@ std::string Observation::typeToText(Type type) {
         tmp << "integer";
         break;
     case STAT_FLOAT:
-        tmp << "float";
-        break;
+        tmp << "float";        break;
     case STAT_DURATION:
         tmp << "duration";
         break;
@@ -335,7 +334,6 @@ std::string Observation::typeToText(Type type) {
 
 isc::data::ConstElementPtr
 Observation::getJSON() const {
-
     ElementPtr entry = isc::data::Element::createList(); // multiple observations
     ElementPtr value;
     ElementPtr timestamp;
index 1681dcdc3412300cdcc4eb34b1707026d45fdc47..82f362e906bda89277d87f6f87b39d65320bbca6 100644 (file)
@@ -497,6 +497,10 @@ TEST_F(ObservationTest, durationToJSON) {
     std::string first_sample = ", \"01:02:03.000004\", \"" +
         isc::util::ptimeToText(c.getDuration().second) + "\" ] ]";
 
+    // String which contains first added sample
+    std::string first_sample = ", \"01:02:03.000004\", \""
+        + isc::util::ptimeToText(c.getDuration().second) + "\" ] ]";
+
     // 1 hour 2 minutes 3 seconds and 4 milliseconds
     c.setValue(time_duration(1, 2, 3, 4));