Skip to content

Commit

Permalink
Add tests and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelweingartner committed Jan 20, 2023
1 parent 4b883f9 commit 80f49d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/source/rest.j2
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ not retroactively calculated as backfill to accommodate the new |timespan|:

{{ scenarios['update-archive-policy']['doc'] }}

The attribute back window of the update request is optional and can be used to
change the `back_window` of an |archive policies|. If we reduce the back
window, data is going to be deleted in the back end when the metrics daemon
Janitor runs. On the other hand, if the value is increased, more raw data
will be stored to enable reprocessing in case of data backfill.

.. note::

|Granularities| cannot be changed to a different rate. Also, |granularities|
Expand Down
18 changes: 18 additions & 0 deletions gnocchi/tests/test_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ def test_get_archive_policy(self):
u'timespan': numpy.timedelta64(2592000, 's')}],
'name': u'low'}, dict(ap))

def test_update_archive_policy_back_window(self):
apname = str(uuid.uuid4())
self.index.create_archive_policy(archive_policy.ArchivePolicy(
apname, 0, [(12, 300)]))
ap = self.index.update_archive_policy(
apname, [archive_policy.ArchivePolicyItem(
granularity=300, points=12)], back_window=10)
self.assertEqual({
'back_window': 10,
'aggregation_methods':
set(self.conf.archive_policy.default_aggregation_methods),
'definition': [
{u'granularity': numpy.timedelta64(300, 's'),
u'points': 12,
u'timespan': numpy.timedelta64(3600, 's')},
],
'name': apname}, dict(ap))

def test_update_archive_policy(self):
self.assertRaises(indexer.UnsupportedArchivePolicyChange,
self.index.update_archive_policy, "low",
Expand Down

0 comments on commit 80f49d1

Please sign in to comment.