aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/tests
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-03-23 12:43:25 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-03-24 16:34:46 +0000
commit85e03a64dd0a4ebe71009ec4bdf4192c04a9786e (patch)
treef8c9191d0e542c3d76a30fd6cc101251cce67e40 /lib/bb/tests
parentaf1654498ee5b47368a41dad2d2b7b6abc19ff15 (diff)
downloadbitbake-85e03a64dd0a4ebe71009ec4bdf4192c04a9786e.tar.gz
tinfoil: Simplify remote datastore connections
The current approach to remote datastores used in tinfoil is breaking. For example, adding a devupstream extension to a recipe with a git upstream, making it the preferred version and then running "devtool modify" on it causes get_srcrev() circular dependency issues. The problem is the override handling in the datastore is broken. This gets broken since remotedata:recieve_datastore() sets d.dict but doesn't update d.overridedata (or d.inchistory or d.varhistory). We could play whack-a-mole but the current implementation seems to be flawed to me. It also doesn't cover, or only partially covers some datastore operations and each needs new dedicated command API. Instead, step back and reimplement the way the datastore connector works. With this change, the datastore is either remote or local but the data is not spread on two sides of the connection. All the API is proxied over the connection by a single function for the datastore (and two to support variable history and include history). This code does not support using the datastore as a parameter to any data store functions. We did have one case of that but its just bad code and can be replaced. The result is something which is much simpler and less invasive to the datastore code itself, meaning its behaviour should be much more consistent. The existing tests for the remote data no longer make any sense and are removed. The one bug this code would have is if key/value pairs are returned over the IPC and those values contained a DataSmart object since we don't recurse into return values to find such things. Nothing appears to do that currently so lets worry about it if its ever an issue. This change should simplfy a ton of other issues and avoid a ton of other bugs so is a huge net gain. Tested with bitbake's and OE's selftests. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/tests')
-rw-r--r--lib/bb/tests/data.py139
1 files changed, 0 insertions, 139 deletions
diff --git a/lib/bb/tests/data.py b/lib/bb/tests/data.py
index 3e49984c9..2b137706d 100644
--- a/lib/bb/tests/data.py
+++ b/lib/bb/tests/data.py
@@ -544,142 +544,3 @@ class Serialize(unittest.TestCase):
self.assertEqual(newd.getVarFlag('HELLO', 'other'), 'planet')
-# Remote datastore tests
-# These really only test the interface, since in actual usage we have a
-# tinfoil connector that does everything over RPC, and this doesn't test
-# that.
-
-class TestConnector:
- d = None
- def __init__(self, d):
- self.d = d
- def getVar(self, name):
- return self.d._findVar(name)
- def getKeys(self):
- return set(self.d.keys())
- def getVarHistory(self, name):
- return self.d.varhistory.variable(name)
- def expandPythonRef(self, varname, expr, d):
- localdata = self.d.createCopy()
- for key in d.localkeys():
- localdata.setVar(d.getVar(key))
- varparse = bb.data_smart.VariableParse(varname, localdata)
- return varparse.python_sub(expr)
- def setVar(self, name, value):
- self.d.setVar(name, value)
- def setVarFlag(self, name, flag, value):
- self.d.setVarFlag(name, flag, value)
- def delVar(self, name):
- self.d.delVar(name)
- return False
- def delVarFlag(self, name, flag):
- self.d.delVarFlag(name, flag)
- return False
- def renameVar(self, name, newname):
- self.d.renameVar(name, newname)
- return False
-
-class Remote(unittest.TestCase):
- def test_remote(self):
-
- d1 = bb.data.init()
- d1.enableTracking()
- d2 = bb.data.init()
- d2.enableTracking()
- connector = TestConnector(d1)
-
- d2.setVar('_remote_data', connector)
-
- d1.setVar('HELLO', 'world')
- d1.setVarFlag('OTHER', 'flagname', 'flagvalue')
- self.assertEqual(d2.getVar('HELLO'), 'world')
- self.assertEqual(d2.expand('${HELLO}'), 'world')
- self.assertEqual(d2.expand('${@d.getVar("HELLO")}'), 'world')
- self.assertIn('flagname', d2.getVarFlags('OTHER'))
- self.assertEqual(d2.getVarFlag('OTHER', 'flagname'), 'flagvalue')
- self.assertEqual(d1.varhistory.variable('HELLO'), d2.varhistory.variable('HELLO'))
- # Test setVar on client side affects server
- d2.setVar('HELLO', 'other-world')
- self.assertEqual(d1.getVar('HELLO'), 'other-world')
- # Test setVarFlag on client side affects server
- d2.setVarFlag('HELLO', 'flagname', 'flagvalue')
- self.assertEqual(d1.getVarFlag('HELLO', 'flagname'), 'flagvalue')
- # Test client side data is incorporated in python expansion (which is done on server)
- d2.setVar('FOO', 'bar')
- self.assertEqual(d2.expand('${@d.getVar("FOO")}'), 'bar')
- # Test overrides work
- d1.setVar('FOO_test', 'baz')
- d1.appendVar('OVERRIDES', ':test')
- self.assertEqual(d2.getVar('FOO'), 'baz')
-
-
-# Remote equivalents of local test classes
-# Note that these aren't perfect since we only test in one direction
-
-class RemoteDataExpansions(DataExpansions):
- def setUp(self):
- self.d1 = bb.data.init()
- self.d = bb.data.init()
- self.d1["foo"] = "value_of_foo"
- self.d1["bar"] = "value_of_bar"
- self.d1["value_of_foo"] = "value_of_'value_of_foo'"
- connector = TestConnector(self.d1)
- self.d.setVar('_remote_data', connector)
-
-class TestRemoteNestedExpansions(TestNestedExpansions):
- def setUp(self):
- self.d1 = bb.data.init()
- self.d = bb.data.init()
- self.d1["foo"] = "foo"
- self.d1["bar"] = "bar"
- self.d1["value_of_foobar"] = "187"
- connector = TestConnector(self.d1)
- self.d.setVar('_remote_data', connector)
-
-class TestRemoteConcat(TestConcat):
- def setUp(self):
- self.d1 = bb.data.init()
- self.d = bb.data.init()
- self.d1.setVar("FOO", "foo")
- self.d1.setVar("VAL", "val")
- self.d1.setVar("BAR", "bar")
- connector = TestConnector(self.d1)
- self.d.setVar('_remote_data', connector)
-
-class TestRemoteConcatOverride(TestConcatOverride):
- def setUp(self):
- self.d1 = bb.data.init()
- self.d = bb.data.init()
- self.d1.setVar("FOO", "foo")
- self.d1.setVar("VAL", "val")
- self.d1.setVar("BAR", "bar")
- connector = TestConnector(self.d1)
- self.d.setVar('_remote_data', connector)
-
-class TestRemoteOverrides(TestOverrides):
- def setUp(self):
- self.d1 = bb.data.init()
- self.d = bb.data.init()
- self.d1.setVar("OVERRIDES", "foo:bar:local")
- self.d1.setVar("TEST", "testvalue")
- connector = TestConnector(self.d1)
- self.d.setVar('_remote_data', connector)
-
-class TestRemoteKeyExpansion(TestKeyExpansion):
- def setUp(self):
- self.d1 = bb.data.init()
- self.d = bb.data.init()
- self.d1.setVar("FOO", "foo")
- self.d1.setVar("BAR", "foo")
- connector = TestConnector(self.d1)
- self.d.setVar('_remote_data', connector)
-
-class TestRemoteFlags(TestFlags):
- def setUp(self):
- self.d1 = bb.data.init()
- self.d = bb.data.init()
- self.d1.setVar("foo", "value of foo")
- self.d1.setVarFlag("foo", "flag1", "value of flag1")
- self.d1.setVarFlag("foo", "flag2", "value of flag2")
- connector = TestConnector(self.d1)
- self.d.setVar('_remote_data', connector)