summaryrefslogtreecommitdiffstats
path: root/testsuite/Testsrc
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/Testsrc')
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py3
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py10
2 files changed, 12 insertions, 1 deletions
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py
index 2ff0af78e..9646ee66d 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py
@@ -7,7 +7,7 @@ import lxml.etree
import Bcfg2.Server
import Bcfg2.Server.Plugin
from Bcfg2.Server.Plugins.Metadata import *
-from mock import Mock, patch
+from mock import Mock, MagicMock, patch
# add all parent testsuite directories to sys.path to allow (most)
# relative imports in python 2.4
@@ -90,6 +90,7 @@ def get_groups_test_tree():
def get_metadata_object(core=None, watch_clients=False, use_db=False):
if core is None:
core = Mock()
+ core.metadata_cache = MagicMock()
core.setup.cfp.getboolean = Mock(return_value=use_db)
return Metadata(core, datastore, watch_clients=watch_clients)
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py
index 0a971c245..7673c73d2 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py
@@ -477,6 +477,7 @@ text
datalist = ["a", "b", "c"]
probes = self.get_probes_object()
+ probes.core.metadata_cache_mode = 'off'
client = Mock()
client.hostname = "foo.example.com"
probes.ReceiveData(client, datalist)
@@ -485,6 +486,15 @@ text
[call(client, "a"), call(client, "b"),
call(client, "c")])
mock_write_data.assert_called_with(client)
+ self.assertFalse(probes.core.metadata_cache.expire.called)
+
+ # change the datalist, ensure that the cache is cleared
+ probes.probedata[client.hostname] = ClientProbeDataSet(a=1, b=2, c=3)
+ probes.core.metadata_cache_mode = 'aggressive'
+ probes.ReceiveData(client, ['a', 'b', 'd'])
+
+ mock_write_data.assert_called_with(client)
+ probes.core.metadata_cache.expire.assert_called_with(client.hostname)
def test_ReceiveDataItem(self):
probes = self.get_probes_object()