diff options
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol')
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 2 | ||||
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/sshbecontroller.py | 5 | ||||
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/tests.py | 84 |
3 files changed, 61 insertions, 30 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py index dfe06f9473..bc3566acee 100644 --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | |||
@@ -117,7 +117,7 @@ class LocalhostBEController(BuildEnvironmentController): | |||
117 | f.seek(0, 2) # jump to the end | 117 | f.seek(0, 2) # jump to the end |
118 | toaster_ui_log_filelength = f.tell() | 118 | toaster_ui_log_filelength = f.tell() |
119 | 119 | ||
120 | cmd = "bash -c \"source %s/oe-init-build-env %s 2>&1 >toaster_server.log && bitbake --read conf/toaster-pre.conf --postread conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 2>&1 >>toaster_server.log \"" % (self.pokydirname, self.be.builddir) | 120 | cmd = "bash -c \"source %s/oe-init-build-env %s 2>&1 >toaster_server.log && bitbake --read %s/conf/toaster-pre.conf --postread %s/conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 2>&1 >>toaster_server.log \"" % (self.pokydirname, self.be.builddir, self.be.builddir, self.be.builddir) |
121 | 121 | ||
122 | port = "-1" | 122 | port = "-1" |
123 | logger.debug("localhostbecontroller: starting builder \n%s\n" % cmd) | 123 | logger.debug("localhostbecontroller: starting builder \n%s\n" % cmd) |
diff --git a/bitbake/lib/toaster/bldcontrol/sshbecontroller.py b/bitbake/lib/toaster/bldcontrol/sshbecontroller.py index 11ad08d440..29ed0a770f 100644 --- a/bitbake/lib/toaster/bldcontrol/sshbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/sshbecontroller.py | |||
@@ -31,6 +31,9 @@ from toastermain import settings | |||
31 | 31 | ||
32 | from bbcontroller import BuildEnvironmentController, ShellCmdException, BuildSetupException | 32 | from bbcontroller import BuildEnvironmentController, ShellCmdException, BuildSetupException |
33 | 33 | ||
34 | class NotImplementedException(Exception): | ||
35 | pass | ||
36 | |||
34 | def DN(path): | 37 | def DN(path): |
35 | return "/".join(path.split("/")[0:-1]) | 38 | return "/".join(path.split("/")[0:-1]) |
36 | 39 | ||
@@ -125,7 +128,7 @@ class SSHBEController(BuildEnvironmentController): | |||
125 | # set layers in the layersource | 128 | # set layers in the layersource |
126 | 129 | ||
127 | 130 | ||
128 | raise Exception("Not implemented: SSH setLayers") | 131 | raise NotImplementedException("Not implemented: SSH setLayers") |
129 | # 3. configure the build environment, so we have a conf/bblayers.conf | 132 | # 3. configure the build environment, so we have a conf/bblayers.conf |
130 | assert self.pokydirname is not None | 133 | assert self.pokydirname is not None |
131 | self._setupBE() | 134 | self._setupBE() |
diff --git a/bitbake/lib/toaster/bldcontrol/tests.py b/bitbake/lib/toaster/bldcontrol/tests.py index 5a9d1df37a..5dbc77fda5 100644 --- a/bitbake/lib/toaster/bldcontrol/tests.py +++ b/bitbake/lib/toaster/bldcontrol/tests.py | |||
@@ -7,7 +7,7 @@ Replace this with more appropriate tests for your application. | |||
7 | 7 | ||
8 | from django.test import TestCase | 8 | from django.test import TestCase |
9 | 9 | ||
10 | from bldcontrol.bbcontroller import BitbakeController | 10 | from bldcontrol.bbcontroller import BitbakeController, BuildSetupException |
11 | from bldcontrol.localhostbecontroller import LocalhostBEController | 11 | from bldcontrol.localhostbecontroller import LocalhostBEController |
12 | from bldcontrol.sshbecontroller import SSHBEController | 12 | from bldcontrol.sshbecontroller import SSHBEController |
13 | from bldcontrol.models import BuildEnvironment, BuildRequest | 13 | from bldcontrol.models import BuildEnvironment, BuildRequest |
@@ -15,6 +15,7 @@ from bldcontrol.management.commands.runbuilds import Command | |||
15 | 15 | ||
16 | import socket | 16 | import socket |
17 | import subprocess | 17 | import subprocess |
18 | import os | ||
18 | 19 | ||
19 | # standard poky data hardcoded for testing | 20 | # standard poky data hardcoded for testing |
20 | BITBAKE_LAYERS = [type('bitbake_info', (object,), { "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "", "commit": "HEAD"})] | 21 | BITBAKE_LAYERS = [type('bitbake_info', (object,), { "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "", "commit": "HEAD"})] |
@@ -29,6 +30,17 @@ POKY_LAYERS = [ | |||
29 | # we have an abstract test class designed to ensure that the controllers use a single interface | 30 | # we have an abstract test class designed to ensure that the controllers use a single interface |
30 | # specific controller tests only need to override the _getBuildEnvironment() method | 31 | # specific controller tests only need to override the _getBuildEnvironment() method |
31 | 32 | ||
33 | test_sourcedir = os.getenv("TTS_SOURCE_DIR") | ||
34 | test_builddir = os.getenv("TTS_BUILD_DIR") | ||
35 | test_address = os.getenv("TTS_TEST_ADDRESS", "localhost") | ||
36 | |||
37 | if test_sourcedir == None or test_builddir == None or test_address == None: | ||
38 | raise Exception("Please set TTTS_SOURCE_DIR, TTS_BUILD_DIR and TTS_TEST_ADDRESS") | ||
39 | |||
40 | # The bb server will expect a toaster-pre.conf file to exist. If it doesn't exit then we make | ||
41 | # an empty one here. | ||
42 | open(test_builddir + 'conf/toaster-pre.conf', 'a').close() | ||
43 | |||
32 | class BEControllerTests(object): | 44 | class BEControllerTests(object): |
33 | 45 | ||
34 | def _serverForceStop(self, bc): | 46 | def _serverForceStop(self, bc): |
@@ -36,28 +48,53 @@ class BEControllerTests(object): | |||
36 | self.assertTrue(err == '', "bitbake server pid %s not stopped" % err) | 48 | self.assertTrue(err == '', "bitbake server pid %s not stopped" % err) |
37 | 49 | ||
38 | def test_serverStartAndStop(self): | 50 | def test_serverStartAndStop(self): |
51 | from bldcontrol.sshbecontroller import NotImplementedException | ||
39 | obe = self._getBuildEnvironment() | 52 | obe = self._getBuildEnvironment() |
40 | bc = self._getBEController(obe) | 53 | bc = self._getBEController(obe) |
41 | bc.setLayers(BITBAKE_LAYERS, POKY_LAYERS) # setting layers, skip any layer info | 54 | try: |
55 | # setting layers, skip any layer info | ||
56 | bc.setLayers(BITBAKE_LAYERS, POKY_LAYERS) | ||
57 | except NotImplementedException, e: | ||
58 | print "Test skipped due to command not implemented yet" | ||
59 | return True | ||
60 | # We are ok with the exception as we're handling the git already exists | ||
61 | except BuildSetupException: | ||
62 | pass | ||
63 | |||
64 | bc.pokydirname = test_sourcedir | ||
65 | bc.islayerset = True | ||
42 | 66 | ||
43 | hostname = self.test_address.split("@")[-1] | 67 | hostname = test_address.split("@")[-1] |
44 | 68 | ||
45 | # test start server and stop | 69 | # test start server and stop |
46 | self.assertTrue(socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex((hostname, 8200)), "Port already occupied") | 70 | bc.startBBServer() |
47 | bc.startBBServer("0:0") | 71 | |
48 | self.assertFalse(socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex((hostname, 8200)), "Server not answering") | 72 | self.assertFalse(socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex((hostname, int(bc.be.bbport))), "Server not answering") |
49 | 73 | ||
50 | bc.stopBBServer() | 74 | bc.stopBBServer() |
51 | self.assertTrue(socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex((hostname, 8200)), "Server not stopped") | 75 | self.assertTrue(socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex((hostname, int(bc.be.bbport))), "Server not stopped") |
52 | 76 | ||
53 | self._serverForceStop(bc) | 77 | self._serverForceStop(bc) |
54 | 78 | ||
55 | def test_getBBController(self): | 79 | def test_getBBController(self): |
80 | from bldcontrol.sshbecontroller import NotImplementedException | ||
56 | obe = self._getBuildEnvironment() | 81 | obe = self._getBuildEnvironment() |
57 | bc = self._getBEController(obe) | 82 | bc = self._getBEController(obe) |
58 | bc.setLayers(BITBAKE_LAYERS, POKY_LAYERS) # setting layers, skip any layer info | 83 | layerSet = False |
59 | 84 | try: | |
60 | bbc = bc.getBBController("%d:%d" % (-1, obe.pk)) | 85 | # setting layers, skip any layer info |
86 | layerSet = bc.setLayers(BITBAKE_LAYERS, POKY_LAYERS) | ||
87 | except NotImplementedException: | ||
88 | print "Test skipped due to command not implemented yet" | ||
89 | return True | ||
90 | # We are ok with the exception as we're handling the git already exists | ||
91 | except BuildSetupException: | ||
92 | pass | ||
93 | |||
94 | bc.pokydirname = test_sourcedir | ||
95 | bc.islayerset = True | ||
96 | |||
97 | bbc = bc.getBBController() | ||
61 | self.assertTrue(isinstance(bbc, BitbakeController)) | 98 | self.assertTrue(isinstance(bbc, BitbakeController)) |
62 | bc.stopBBServer() | 99 | bc.stopBBServer() |
63 | 100 | ||
@@ -66,19 +103,15 @@ class BEControllerTests(object): | |||
66 | class LocalhostBEControllerTests(TestCase, BEControllerTests): | 103 | class LocalhostBEControllerTests(TestCase, BEControllerTests): |
67 | def __init__(self, *args): | 104 | def __init__(self, *args): |
68 | super(LocalhostBEControllerTests, self).__init__(*args) | 105 | super(LocalhostBEControllerTests, self).__init__(*args) |
69 | # hardcoded for Alex's machine; since the localhost BE is machine-dependent, | 106 | |
70 | # I found no good way to abstractize this | ||
71 | self.test_sourcedir = "/home/ddalex/ssd/yocto" | ||
72 | self.test_builddir = "/home/ddalex/ssd/yocto/build" | ||
73 | self.test_address = "localhost" | ||
74 | 107 | ||
75 | def _getBuildEnvironment(self): | 108 | def _getBuildEnvironment(self): |
76 | return BuildEnvironment.objects.create( | 109 | return BuildEnvironment.objects.create( |
77 | lock = BuildEnvironment.LOCK_FREE, | 110 | lock = BuildEnvironment.LOCK_FREE, |
78 | betype = BuildEnvironment.TYPE_LOCAL, | 111 | betype = BuildEnvironment.TYPE_LOCAL, |
79 | address = self.test_address, | 112 | address = test_address, |
80 | sourcedir = self.test_sourcedir, | 113 | sourcedir = test_sourcedir, |
81 | builddir = self.test_builddir ) | 114 | builddir = test_builddir ) |
82 | 115 | ||
83 | def _getBEController(self, obe): | 116 | def _getBEController(self, obe): |
84 | return LocalhostBEController(obe) | 117 | return LocalhostBEController(obe) |
@@ -86,25 +119,20 @@ class LocalhostBEControllerTests(TestCase, BEControllerTests): | |||
86 | class SSHBEControllerTests(TestCase, BEControllerTests): | 119 | class SSHBEControllerTests(TestCase, BEControllerTests): |
87 | def __init__(self, *args): | 120 | def __init__(self, *args): |
88 | super(SSHBEControllerTests, self).__init__(*args) | 121 | super(SSHBEControllerTests, self).__init__(*args) |
89 | self.test_address = "ddalex-desktop.local" | ||
90 | # hardcoded for ddalex-desktop.local machine; since the localhost BE is machine-dependent, | ||
91 | # I found no good way to abstractize this | ||
92 | self.test_sourcedir = "/home/ddalex/ssd/yocto" | ||
93 | self.test_builddir = "/home/ddalex/ssd/yocto/build" | ||
94 | 122 | ||
95 | def _getBuildEnvironment(self): | 123 | def _getBuildEnvironment(self): |
96 | return BuildEnvironment.objects.create( | 124 | return BuildEnvironment.objects.create( |
97 | lock = BuildEnvironment.LOCK_FREE, | 125 | lock = BuildEnvironment.LOCK_FREE, |
98 | betype = BuildEnvironment.TYPE_SSH, | 126 | betype = BuildEnvironment.TYPE_SSH, |
99 | address = self.test_address, | 127 | address = test_address, |
100 | sourcedir = self.test_sourcedir, | 128 | sourcedir = test_sourcedir, |
101 | builddir = self.test_builddir ) | 129 | builddir = test_builddir ) |
102 | 130 | ||
103 | def _getBEController(self, obe): | 131 | def _getBEController(self, obe): |
104 | return SSHBEController(obe) | 132 | return SSHBEController(obe) |
105 | 133 | ||
106 | def test_pathExists(self): | 134 | def test_pathExists(self): |
107 | obe = BuildEnvironment.objects.create(betype = BuildEnvironment.TYPE_SSH, address= self.test_address) | 135 | obe = BuildEnvironment.objects.create(betype = BuildEnvironment.TYPE_SSH, address= test_address) |
108 | sbc = SSHBEController(obe) | 136 | sbc = SSHBEController(obe) |
109 | self.assertTrue(sbc._pathexists("/")) | 137 | self.assertTrue(sbc._pathexists("/")) |
110 | self.assertFalse(sbc._pathexists("/.deadbeef")) | 138 | self.assertFalse(sbc._pathexists("/.deadbeef")) |
@@ -129,7 +157,7 @@ class RunBuildsCommandTests(TestCase): | |||
129 | self.assertRaises(IndexError, command._selectBuildEnvironment) | 157 | self.assertRaises(IndexError, command._selectBuildEnvironment) |
130 | 158 | ||
131 | def test_br_select(self): | 159 | def test_br_select(self): |
132 | from orm.models import Project, Release, BitbakeVersion | 160 | from orm.models import Project, Release, BitbakeVersion, Branch |
133 | p = Project.objects.create_project("test", Release.objects.get_or_create(name = "HEAD", bitbake_version = BitbakeVersion.objects.get_or_create(name="HEAD", branch=Branch.objects.get_or_create(name="HEAD"))[0])[0]) | 161 | p = Project.objects.create_project("test", Release.objects.get_or_create(name = "HEAD", bitbake_version = BitbakeVersion.objects.get_or_create(name="HEAD", branch=Branch.objects.get_or_create(name="HEAD"))[0])[0]) |
134 | obr = BuildRequest.objects.create(state = BuildRequest.REQ_QUEUED, project = p) | 162 | obr = BuildRequest.objects.create(state = BuildRequest.REQ_QUEUED, project = p) |
135 | command = Command() | 163 | command = Command() |