Skip to contentSkip to conversation

0/8] Add toaster test suite support

PATCH New Aníbal Limón 1 participant 9 messages Feb 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 0/8] Add toaster test suite support

Aníbal Limón (8):
autobuilder/lib: Add buildsteps module for provide helpers autobuilder/buildsteps: Add ToasterSetupVenv step. autobuilder/buildsteps: Add ToasterStart and ToasterStop buildsteps. buildset-config.toaster: Add toaster-tests.conf. buildsteps/ToasterRunTests.py: Add step for run toaster tests.
buildset-config.toaster/toaster-tests.conf: Add ToasterRunTests step.
autobuilder/lib/buildsteps.py: ShellCommandCleanEnv preserve PATH buildset-config.toaster/toaster-tests.conf: Add Sleep step buildsteps/ToasterRunTests.py: Now call run tests with verbose.

 buildset-config.toaster/toaster-tests.conf         | 21 +++++++++++
 buildset-config.toaster/yoctoAB.conf               |  2 +-
 .../autobuilder/buildsteps/ToasterRunTests.py      | 31 ++++++++++++++++
 .../autobuilder/buildsteps/ToasterSetupVenv.py     | 31 ++++++++++++++++
 .../autobuilder/buildsteps/ToasterStart.py         | 32 +++++++++++++++++
 .../autobuilder/buildsteps/ToasterStop.py          | 33 +++++++++++++++++
 .../site-packages/autobuilder/lib/buildsteps.py    | 42 ++++++++++++++++++++++
 7 files changed, 191 insertions(+), 1 deletion(-)
 create mode 100644 buildset-config.toaster/toaster-tests.conf
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterRunTests.py
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterSetupVenv.py
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterStart.py
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterStop.py
 create mode 100644 lib/python2.7/site-packages/autobuilder/lib/buildsteps.py
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 1/8] autobuilder/lib: Add buildsteps module for provide helpers

Add ShellCommandCleanEnv helper for run command in a clean enviroment a shell for run the command can be specified also the variables to preserve in the new enviroment.

---
 .../site-packages/autobuilder/lib/buildsteps.py    | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 lib/python2.7/site-packages/autobuilder/lib/buildsteps.py
lib/python2.7/site-packages/autobuilder/lib/buildsteps.py new file +41 -0
new file mode 100644
index 0000000..8b719fa
@@ -0,0 +1,41 @@
+'''
+Created on Feb 15, 2016
+
+__author__ = "Anibal (alimon) Limon"
+__copyright__ = "Copyright 2016, Intel Corp."
+__credits__ = ["Anibal Limon"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Anibal Limon"
+__email__ = "[email protected]"
+'''
+
+import os
+from buildbot.steps.shell import ShellCommand
+
+DEFAULT_SHELL = 'bash'
+
+class ShellCommandCleanEnv(ShellCommand):
+    def __init__(self, factory, argdict=None, **kwargs):
+        shell = DEFAULT_SHELL
+        if 'SHELL' in kwargs:
+            shell = kwargs['SHELL']
+            del kwargs['SHELL']
+
+        if 'PENV' in kwargs:
+            preserve_env = kwargs['PENV']
+            del kwargs['PENV']
+        else:
+            preserve_env = ['HOME', 'PWD', 'http_proxy', 'https_proxy',
+                            'ftp_proxy', 'no_proxy', 'GIT_PROXY_COMMAND']
+
+        env_command = self._get_env_cleaned_command(shell, preserve_env)
+        self.command = "%s \'%s\'" % (env_command, self.command)
+        ShellCommand.__init__(self, **kwargs)
+
+    def _get_env_cleaned_command(self, shell, preserve_env):
+        pe_cmd = ''
+        for pe in preserve_env:
+            pe_cmd += "%s=\"$%s\" " % (pe, pe)
+
+        return "env -i %s %s -c " % (pe_cmd, shell)
Signature · 1 line
2.1.4
#2 lore raw

PATCH 1/1 2/8] autobuilder/buildsteps: Add ToasterSetupVenv step.

In reply to Aníbal Limón

ToasterSetupVenv creates a virtualenv and install requeriments for run toaster and toaster tests.

---
 .../autobuilder/buildsteps/ToasterSetupVenv.py     | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterSetupVenv.py
lib/python2.7/site-packages/autobuilder/buildsteps/ToasterSetupVenv.py new file +31 -0
new file mode 100644
index 0000000..54cf1e7
@@ -0,0 +1,31 @@
+'''
+Created on Feb 15, 2016
+
+__author__ = "Anibal (alimon) Limon"
+__copyright__ = "Copyright 2016, Intel Corp."
+__credits__ = ["Anibal Limon"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Anibal Limon"
+__email__ = "[email protected]"
+'''
+
+from lib.buildsteps import ShellCommandCleanEnv
+
+class ToasterSetupVenv(ShellCommandCleanEnv):
+    haltOnFailure = True
+    flunkOnFailure = True
+    name = "ToasterSetupVenv"
+
+    def __init__(self, factory, argdict=None, **kwargs):
+        self.factory = factory
+        self.description = "Creating virtualenv..."
+
+        oe_cmd = "source ./oe-init-build-env;"
+        venv_cmd = "virtualenv venv; source venv/bin/activate;"
+        install_cmd = "pip install -r ../bitbake/toaster-requirements.txt;"
+        install_tests_cmd = "pip install -r ../bitbake/toaster-tests-requirements.txt;"
+
+        self.command = oe_cmd + venv_cmd + install_cmd + install_tests_cmd 
+
+        ShellCommandCleanEnv.__init__(self, factory, argdict, **kwargs)
Signature · 1 line
2.1.4
#3 lore raw

PATCH 1/1 3/8] autobuilder/buildsteps: Add ToasterStart and ToasterStop buildsteps.

In reply to Aníbal Limón

These buildsteps servers for start/stop toaster in a clean way.

---
 .../autobuilder/buildsteps/ToasterStart.py         | 32 +++++++++++++++++++++
 .../autobuilder/buildsteps/ToasterStop.py          | 33 ++++++++++++++++++++++
 2 files changed, 65 insertions(+)
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterStart.py
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterStop.py
lib/python2.7/site-packages/autobuilder/buildsteps/ToasterStart.py new file +32 -0
new file mode 100644
index 0000000..14cf9db3
@@ -0,0 +1,32 @@
+'''
+Created on Feb 15, 2016
+
+__author__ = "Anibal (alimon) Limon"
+__copyright__ = "Copyright 2016, Intel Corp."
+__credits__ = ["Anibal Limon"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Anibal Limon"
+__email__ = "[email protected]"
+'''
+
+from lib.buildsteps import ShellCommandCleanEnv
+import os
+
+class ToasterStart(ShellCommandCleanEnv):
+    haltOnFailure = True
+    flunkOnFailure = True
+    name = "ToasterStart"
+
+    def __init__(self, factory, argdict=None, **kwargs):
+        self.factory = factory
+        self.description = "Starting toaster..."
+
+        oe_cmd = "source ./oe-init-build-env;"
+        venv_cmd = "source venv/bin/activate;"
+        start_cmd = "../bitbake/lib/toaster/tests/helpers.py -a start" \
+            " -d $(readlink -e ../)"
+
+        self.command = oe_cmd + venv_cmd + start_cmd
+
+        ShellCommandCleanEnv.__init__(self, factory, argdict, **kwargs)
lib/python2.7/site-packages/autobuilder/buildsteps/ToasterStop.py new file +33 -0
new file mode 100644
index 0000000..6fda0e8
@@ -0,0 +1,33 @@
+'''
+Created on Feb 15, 2016
+
+__author__ = "Anibal (alimon) Limon"
+__copyright__ = "Copyright 2016, Intel Corp."
+__credits__ = ["Anibal Limon"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Anibal Limon"
+__email__ = "[email protected]"
+'''
+
+from lib.buildsteps import ShellCommandCleanEnv
+import os
+
+class ToasterStop(ShellCommandCleanEnv):
+    alwaysRun = True
+    haltOnFailure = True
+    flunkOnFailure = True
+    name = "ToasterStop"
+
+    def __init__(self, factory, argdict=None, **kwargs):
+        self.factory = factory
+        self.description = "Stopping toaster..."
+
+        oe_cmd = "source ./oe-init-build-env;"
+        venv_cmd = "source venv/bin/activate;"
+        start_cmd = "../bitbake/lib/toaster/tests/helpers.py -a stop" \
+            " -d $(readlink -e ../)"
+
+        self.command = oe_cmd + venv_cmd + start_cmd
+
+        ShellCommandCleanEnv.__init__(self, factory, argdict, **kwargs)
Signature · 1 line
2.1.4
#4 lore raw

PATCH 1/1 5/8] buildsteps/ToasterRunTests.py: Add step for run toaster tests. buildset-config.toaster/toaster-tests.conf: Add ToasterRunTests step.

In reply to Aníbal Limón
---
 buildset-config.toaster/toaster-tests.conf         |  1 +
 .../autobuilder/buildsteps/ToasterRunTests.py      | 31 ++++++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterRunTests.py
buildset-config.toaster/toaster-tests.conf +1 -0
index 22ac176..c471c92 100644
@@ -15,5 +15,6 @@ steps: [{'SetDest':{}},
         {'GetBitbakeVersion': {}},
 	{'ToasterSetupVenv': {}},
 	{'ToasterStart': {}},
+	{'ToasterRunTests': {}},
 	{'ToasterStop': {}},
        ]
lib/python2.7/site-packages/autobuilder/buildsteps/ToasterRunTests.py new file +31 -0
new file mode 100644
index 0000000..392b600
@@ -0,0 +1,31 @@
+'''
+Created on Feb 15, 2016
+
+__author__ = "Anibal (alimon) Limon"
+__copyright__ = "Copyright 2016, Intel Corp."
+__credits__ = ["Anibal Limon"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Anibal Limon"
+__email__ = "[email protected]"
+'''
+
+from lib.buildsteps import ShellCommandCleanEnv
+import os
+
+class ToasterRunTests(ShellCommandCleanEnv):
+    haltOnFailure = True
+    flunkOnFailure = True
+    name = "ToasterRunTests"
+
+    def __init__(self, factory, argdict=None, **kwargs):
+        self.factory = factory
+        self.description = "Running toaster tests..."
+
+        oe_cmd = "source ./oe-init-build-env;"
+        venv_cmd = "source venv/bin/activate;"
+        cmd = "DISPLAY=:1 toaster-test --run-all-tests;"
+
+        self.command = oe_cmd + venv_cmd + cmd
+
+        ShellCommandCleanEnv.__init__(self, factory, argdict, **kwargs)
Signature · 1 line
2.1.4
#5 lore raw

PATCH 1/1 6/8] autobuilder/lib/buildsteps.py: ShellCommandCleanEnv preserve PATH

In reply to Aníbal Limón
---
 lib/python2.7/site-packages/autobuilder/lib/buildsteps.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/python2.7/site-packages/autobuilder/lib/buildsteps.py +2 -1
index 8b719fa..3693a7a 100644
@@ -26,7 +26,8 @@ class ShellCommandCleanEnv(ShellCommand):
             preserve_env = kwargs['PENV']
             del kwargs['PENV']
         else:
-            preserve_env = ['HOME', 'PWD', 'http_proxy', 'https_proxy',
+            preserve_env = ['HOME', 'PWD', 'PATH',
+                            'http_proxy', 'https_proxy',
                             'ftp_proxy', 'no_proxy', 'GIT_PROXY_COMMAND']
 
         env_command = self._get_env_cleaned_command(shell, preserve_env)
Signature · 1 line
2.1.4
#6 lore raw

PATCH 1/1 4/8] buildset-config.toaster: Add toaster-tests.conf.

In reply to Aníbal Limón

The toaster-test.conf file provides buildsteps for run toaster testing. For now only setup/start/stop toaster.

---
 buildset-config.toaster/toaster-tests.conf | 19 +++++++++++++++++++
 buildset-config.toaster/yoctoAB.conf       |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 buildset-config.toaster/toaster-tests.conf
buildset-config.toaster/toaster-tests.conf new file +19 -0
new file mode 100644
index 0000000..22ac176
@@ -0,0 +1,19 @@
+[toaster-tests]
+builders: 'example-worker'
+repos: [{'poky':
+            {'repourl':'git://git.yoctoproject.org/poky',
+             'layerversion':{'core':'meta', 'yoctobsp':'meta-yocto-bsp', 'yocto':'meta-yocto', 'poky':'meta-poky'},
+             'branch':'master' }}]
+steps: [{'SetDest':{}},
+        {'CheckOutLayers': {}},
+        {'RunPreamble': {}},
+        {'GetDistroVersion' : {'distro': 'poky'}},
+        {'CreateAutoConf': {'machine': 'qemux86', 'SDKMACHINE' : 'i686',
+                            'distro': 'poky', 'buildhistory' : True}},
+        {'CreateBBLayersConf': {'buildprovider' : 'yocto'}},
+        {'SyncPersistDB' : {'distro' : 'poky'}},
+        {'GetBitbakeVersion': {}},
+	{'ToasterSetupVenv': {}},
+	{'ToasterStart': {}},
+	{'ToasterStop': {}},
+       ]
buildset-config.toaster/yoctoAB.conf +1 -1
index 4f3fa00..614e39c 100644
@@ -1,2 +1,2 @@
 [BuildSets]
-order: [] 
+order: ['toaster-tests']
Signature · 1 line
2.1.4
#7 lore raw

PATCH 1/1 7/8] buildset-config.toaster/toaster-tests.conf: Add Sleep step

In reply to Aníbal Limón

Sleep step is needed before RunTests to give certain time to toaster for finish the initial setup.

---
 buildset-config.toaster/toaster-tests.conf | 1 +
 1 file changed, 1 insertion(+)
buildset-config.toaster/toaster-tests.conf +1 -0
index c471c92..0aa6b46 100644
@@ -15,6 +15,7 @@ steps: [{'SetDest':{}},
         {'GetBitbakeVersion': {}},
 	{'ToasterSetupVenv': {}},
 	{'ToasterStart': {}},
+	{'Sleep': {'time': '120'}},
 	{'ToasterRunTests': {}},
 	{'ToasterStop': {}},
        ]
Signature · 1 line
2.1.4
#8 lore raw

PATCH 1/1 8/8] buildsteps/ToasterRunTests.py: Now call run tests with verbose.

In reply to Aníbal Limón

In order to avoid kill by timeout call the toaster run tests with verbose option.

---
 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterRunTests.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/python2.7/site-packages/autobuilder/buildsteps/ToasterRunTests.py +1 -1
index 392b600..141768c 100644
@@ -24,7 +24,7 @@ class ToasterRunTests(ShellCommandCleanEnv):
 
         oe_cmd = "source ./oe-init-build-env;"
         venv_cmd = "source venv/bin/activate;"
-        cmd = "DISPLAY=:1 toaster-test --run-all-tests;"
+        cmd = "DISPLAY=:1 toaster-test --run-all-tests --verbose"
 
         self.command = oe_cmd + venv_cmd + cmd
 
Signature · 1 line
2.1.4