diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-09-05 14:36:15 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-09-05 14:55:33 -0400 |
commit | cd7b0b3d40a5a340d5b47819f94a21c9faf23120 (patch) | |
tree | 67dc3b8f53b0921aade0ba5603d5f1c9cff85eb5 /testsuite | |
parent | 84e8fc36c4d8524c8094daf31955dce8c0a624ea (diff) | |
download | bcfg2-cd7b0b3d40a5a340d5b47819f94a21c9faf23120.tar.gz bcfg2-cd7b0b3d40a5a340d5b47819f94a21c9faf23120.tar.bz2 bcfg2-cd7b0b3d40a5a340d5b47819f94a21c9faf23120.zip |
added server-side client metadata object caching
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py | 3 | ||||
-rw-r--r-- | testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py | 10 |
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() |