summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/data.py
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 22:01:03 +0000
commitd53958766e2c766b95b3947f69b64c409ed433d8 (patch)
tree45e943ca7b1cce938d730cf17cdbb4e472082258 /bitbake/lib/bb/tests/data.py
parent89705a60f3b566743703c3a7597ccc4507293dd9 (diff)
downloadpoky-d53958766e2c766b95b3947f69b64c409ed433d8.tar.gz
bitbake: 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. (Bitbake rev: 85e03a64dd0a4ebe71009ec4bdf4192c04a9786e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/data.py')
-rw-r--r--bitbake/lib/bb/tests/data.py139
1 files changed, 0 insertions, 139 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py
index 3e49984c93..2b137706dd 100644
--- a/bitbake/lib/bb/tests/data.py
+++ b/bitbake/lib/bb/tests/data.py
@@ -544,142 +544,3 @@ class Serialize(unittest.TestCase):
544 self.assertEqual(newd.getVarFlag('HELLO', 'other'), 'planet') 544 self.assertEqual(newd.getVarFlag('HELLO', 'other'), 'planet')
545 545
546 546
547# Remote datastore tests
548# These really only test the interface, since in actual usage we have a
549# tinfoil connector that does everything over RPC, and this doesn't test
550# that.
551
552class TestConnector:
553 d = None
554 def __init__(self, d):
555 self.d = d
556 def getVar(self, name):
557 return self.d._findVar(name)
558 def getKeys(self):
559 return set(self.d.keys())
560 def getVarHistory(self, name):
561 return self.d.varhistory.variable(name)
562 def expandPythonRef(self, varname, expr, d):
563 localdata = self.d.createCopy()
564 for key in d.localkeys():
565 localdata.setVar(d.getVar(key))
566 varparse = bb.data_smart.VariableParse(varname, localdata)
567 return varparse.python_sub(expr)
568 def setVar(self, name, value):
569 self.d.setVar(name, value)
570 def setVarFlag(self, name, flag, value):
571 self.d.setVarFlag(name, flag, value)
572 def delVar(self, name):
573 self.d.delVar(name)
574 return False
575 def delVarFlag(self, name, flag):
576 self.d.delVarFlag(name, flag)
577 return False
578 def renameVar(self, name, newname):
579 self.d.renameVar(name, newname)
580 return False
581
582class Remote(unittest.TestCase):
583 def test_remote(self):
584
585 d1 = bb.data.init()
586 d1.enableTracking()
587 d2 = bb.data.init()
588 d2.enableTracking()
589 connector = TestConnector(d1)
590
591 d2.setVar('_remote_data', connector)
592
593 d1.setVar('HELLO', 'world')
594 d1.setVarFlag('OTHER', 'flagname', 'flagvalue')
595 self.assertEqual(d2.getVar('HELLO'), 'world')
596 self.assertEqual(d2.expand('${HELLO}'), 'world')
597 self.assertEqual(d2.expand('${@d.getVar("HELLO")}'), 'world')
598 self.assertIn('flagname', d2.getVarFlags('OTHER'))
599 self.assertEqual(d2.getVarFlag('OTHER', 'flagname'), 'flagvalue')
600 self.assertEqual(d1.varhistory.variable('HELLO'), d2.varhistory.variable('HELLO'))
601 # Test setVar on client side affects server
602 d2.setVar('HELLO', 'other-world')
603 self.assertEqual(d1.getVar('HELLO'), 'other-world')
604 # Test setVarFlag on client side affects server
605 d2.setVarFlag('HELLO', 'flagname', 'flagvalue')
606 self.assertEqual(d1.getVarFlag('HELLO', 'flagname'), 'flagvalue')
607 # Test client side data is incorporated in python expansion (which is done on server)
608 d2.setVar('FOO', 'bar')
609 self.assertEqual(d2.expand('${@d.getVar("FOO")}'), 'bar')
610 # Test overrides work
611 d1.setVar('FOO_test', 'baz')
612 d1.appendVar('OVERRIDES', ':test')
613 self.assertEqual(d2.getVar('FOO'), 'baz')
614
615
616# Remote equivalents of local test classes
617# Note that these aren't perfect since we only test in one direction
618
619class RemoteDataExpansions(DataExpansions):
620 def setUp(self):
621 self.d1 = bb.data.init()
622 self.d = bb.data.init()
623 self.d1["foo"] = "value_of_foo"
624 self.d1["bar"] = "value_of_bar"
625 self.d1["value_of_foo"] = "value_of_'value_of_foo'"
626 connector = TestConnector(self.d1)
627 self.d.setVar('_remote_data', connector)
628
629class TestRemoteNestedExpansions(TestNestedExpansions):
630 def setUp(self):
631 self.d1 = bb.data.init()
632 self.d = bb.data.init()
633 self.d1["foo"] = "foo"
634 self.d1["bar"] = "bar"
635 self.d1["value_of_foobar"] = "187"
636 connector = TestConnector(self.d1)
637 self.d.setVar('_remote_data', connector)
638
639class TestRemoteConcat(TestConcat):
640 def setUp(self):
641 self.d1 = bb.data.init()
642 self.d = bb.data.init()
643 self.d1.setVar("FOO", "foo")
644 self.d1.setVar("VAL", "val")
645 self.d1.setVar("BAR", "bar")
646 connector = TestConnector(self.d1)
647 self.d.setVar('_remote_data', connector)
648
649class TestRemoteConcatOverride(TestConcatOverride):
650 def setUp(self):
651 self.d1 = bb.data.init()
652 self.d = bb.data.init()
653 self.d1.setVar("FOO", "foo")
654 self.d1.setVar("VAL", "val")
655 self.d1.setVar("BAR", "bar")
656 connector = TestConnector(self.d1)
657 self.d.setVar('_remote_data', connector)
658
659class TestRemoteOverrides(TestOverrides):
660 def setUp(self):
661 self.d1 = bb.data.init()
662 self.d = bb.data.init()
663 self.d1.setVar("OVERRIDES", "foo:bar:local")
664 self.d1.setVar("TEST", "testvalue")
665 connector = TestConnector(self.d1)
666 self.d.setVar('_remote_data', connector)
667
668class TestRemoteKeyExpansion(TestKeyExpansion):
669 def setUp(self):
670 self.d1 = bb.data.init()
671 self.d = bb.data.init()
672 self.d1.setVar("FOO", "foo")
673 self.d1.setVar("BAR", "foo")
674 connector = TestConnector(self.d1)
675 self.d.setVar('_remote_data', connector)
676
677class TestRemoteFlags(TestFlags):
678 def setUp(self):
679 self.d1 = bb.data.init()
680 self.d = bb.data.init()
681 self.d1.setVar("foo", "value of foo")
682 self.d1.setVarFlag("foo", "flag1", "value of flag1")
683 self.d1.setVarFlag("foo", "flag2", "value of flag2")
684 connector = TestConnector(self.d1)
685 self.d.setVar('_remote_data', connector)