Skip to contentSkip to conversation

lib/oeqa/runtime/cases/python2_module.py: add test

RFC In review Tim Orling 2 participants 4 messages Jan 25, 2020 – Feb 5, 2020

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

RFC 1/1 lib/oeqa/runtime/cases/python2_module.py: add test

This test case is intentionally limited to only tesing one python package/recipe at a time, because the use case is to determine whether dependencies have been met for a minimal image with 'only' the package under test installed. This dependency checking must include the packages-split python standard library modules that OE/YP creates from the python manifest.

TODO: Be smarter about PYTHON_IMPORTS_UNDER_TEST, as this
should be discoverable from /usr/lib/python2.7/site-packages or from the rpm/deb/ipk of the python package itself. What we do NOT want to do is use pkgdata or some other magical Python script that will add dependencies to the test image. We need as pristine and minimalist a test environment as we can get.

TODO: Use a minimal master test image and install the package under
test from a package feed using a package manager in the master test image. This would allow for much shorter developement cycles.

TODO: Parse the ImportError and give hints about what dependencies
are missing.

Example configuration in local.conf:

IMAGE_CLASSES += " testimage"
DISTRO_FEAURES_append = " ptest"
EXTRA_IMAGE_FEATURES = "debug-tweaks"
TESTIMAGE_AUTO = "1"
TEST_SUITES = " ping ssh python2 ptest python2_module"
TEST_QEMUPARAMS += "-smp 4 -m 8192"
TEST_RUNQEMUPARAMS += "kvm gl"
IMAGE_ROOTFS_SIZE ?= "8192"
IMAGE_ROOTFS_EXTRA_SPACE_append = "${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "", d)}" IMAGE_INSTALL_append = " ptest-runner dropbear procps coreutils iproute2 sysstat" PYTHON_PACKAGE_UNDER_TEST = "python-pymongo"
IMAGE_INSTALL_append = " ${PYTHON_PACKAGE_UNDER_TEST}"
PYTHON_IMPORTS_UNDER_TEST = "bson gridfs pymongo"

---
 lib/oeqa/runtime/cases/python2_module.py | 97 ++++++++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 lib/oeqa/runtime/cases/python2_module.py
lib/oeqa/runtime/cases/python2_module.py new file +97 -0
new file mode 100644
index 00000000..59ae00fb
@@ -0,0 +1,97 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import OETestDataDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+
+class PythonModuleTest(OERuntimeTestCase):
+    """This test case is intentionally limited to only tesing one
+       python package/recipe at a time, because the use case is to
+       determine whether dependencies have been met for a minimal
+       image with 'only' the package under test installed. This
+       dependency checking must include the packages-split python
+       standard library modules that OE/YP creates from the python
+       manifest.
+
+       TODO: Be smarter about PYTHON_IMPORTS_UNDER_TEST, as this
+             should be discoverable from /usr/lib/python2.7/site-packages
+             or from the rpm/deb/ipk of the python package itself.
+             What we do NOT want to do is use pkgdata or some other
+             magical Python script that will add dependencies to the
+             test image. We need as pristine and minimalist a test
+             environment as we can get.
+
+       TODO: Use a minimal master test image and install the package under
+             test from a package feed using a package manager in the master
+             test image. This would allow for much shorter developement
+             cycles.
+
+       TODO: Parse the ImportError and give hints about what dependencies
+             are missing.
+
+
+       Example configuration in local.conf:
+       
+       IMAGE_CLASSES += " testimage"
+       DISTRO_FEAURES_append = " ptest"
+       EXTRA_IMAGE_FEATURES = "debug-tweaks"
+       TESTIMAGE_AUTO = "1"
+       TEST_SUITES = " ping ssh python2 ptest python2_module"
+       TEST_QEMUPARAMS += "-smp 4 -m 8192"
+       TEST_RUNQEMUPARAMS += "kvm gl"
+       IMAGE_ROOTFS_SIZE ?= "8192"
+       IMAGE_ROOTFS_EXTRA_SPACE_append = "${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "", d)}"
+       IMAGE_INSTALL_append = " ptest-runner dropbear procps coreutils iproute2 sysstat"
+       PYTHON_PACKAGE_UNDER_TEST = "python-engineio"
+       IMAGE_INSTALL_append = " ${PYTHON_PACKAGE_UNDER_TEST}"
+       PYTHON_IMPORTS_UNDER_TEST = "engineio"
+    """
+
+    package = ""
+    imports = []
+
+    @classmethod
+    def setUp(cls):
+        if 'PYTHON_PACKAGE_UNDER_TEST' in cls.tc.td:
+            cls.package = cls.tc.td.get('PYTHON_PACKAGE_UNDER_TEST')
+            cls.logger.debug('Running import test on "%s" recipe' % cls.package)
+        else:
+            cls.logger.error('No recipe to test found in configuration.\n'
+                             'Please set in PYTHON_PACKAGE_UNDER_TEST')
+        if 'PYTHON_IMPORTS_UNDER_TEST' in cls.tc.td:
+            cls.imports = cls.tc.td.get('PYTHON_IMPORTS_UNDER_TEST').split()
+            if isinstance(cls.imports, list) and len(cls.imports) > 0:
+                cls.logger.info('Importing from %s' % cls.imports)
+            else:
+                cls.logger.error("PYTHON_IMPORTS_UNDER_TEST should be a space delimited list")
+                cls.logger.error("typeof(PYTHON_IMPORTS_UNDER_TEST) is %s" % type(cls.imports))
+        else:
+            cls.logger.error("No modules to import found in configuration.\n"
+                             "Please set in variable PYTHON_IMPORTS_UNDER_TEST")
+
+
+class PythonModuleImportTest(PythonModuleTest):
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    @OETestDepends(['python2.PythonTest.test_python'])
+    @OETestDataDepends(['PYTHON_PACKAGE_UNDER_TEST'])
+    @OETestDataDepends(['PYTHON_IMPORTS_UNDER_TEST'])
+    def test_python_module(self):
+        # We can't use the OEHasPackage decorator, because 'package' isn't defined
+        # until the class has already been instantiated
+        msg = 'Checking if "%s" is installed' % self.package
+        self.logger.debug(msg)
+        if not self.package in self.tc.image_packages:
+            msg = 'Test requires "%s" to be installed' % self.package
+            self.skipTest(msg)
+
+        for python_import in self.imports:
+            cmd = 'python -c "import %s"' % python_import
+            status, output = self.target.run(cmd)
+            msg = 'Exit status was not 0. Output: %s' % output
+            self.assertEqual(status, 0, msg=msg)
Signature · 1 line
2.25.0
#1 lore raw
Quoted 16 lines · Tim Orling

This test case is intentionally limited to only tesing one python package/recipe at a time, because the use case is to determine whether dependencies have been met for a minimal image with 'only' the package under test installed. This dependency checking must include the packages-split python standard library modules that OE/YP creates from the python manifest.

TODO: Be smarter about PYTHON_IMPORTS_UNDER_TEST, as this
should be discoverable from /usr/lib/python2.7/site-packages or from the rpm/deb/ipk of the python package itself. What we do NOT want to do is use pkgdata or some other magical Python script that will add dependencies to the test image. We need as pristine and minimalist a test environment as we can get.

Quoted 7 lines

TODO: Use a minimal master test image and install the package under
test from a package feed using a package manager in the master test image. This would allow for much shorter developement cycles.

TODO: Parse the ImportError and give hints about what dependencies
are missing.

This looks useful. Do you have the python3 version done but not sent or should Trevor see if he can get that to work?

Quoted 13 lines

Example configuration in local.conf:

IMAGE_CLASSES += " testimage"
DISTRO_FEAURES_append = " ptest"
EXTRA_IMAGE_FEATURES = "debug-tweaks"
TESTIMAGE_AUTO = "1"
TEST_SUITES = " ping ssh python2 ptest python2_module"
TEST_QEMUPARAMS += "-smp 4 -m 8192"
TEST_RUNQEMUPARAMS += "kvm gl"
IMAGE_ROOTFS_SIZE ?= "8192"
IMAGE_ROOTFS_EXTRA_SPACE_append = "${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "", d)}" IMAGE_INSTALL_append = " ptest-runner dropbear procps coreutils iproute2 sysstat"

Is this really a minimal set of dependencies and if so, why do you need:
procps coreutils iproute2 sysstat
?

I should probably try it before replying but
it's already been a long day!

../Randy

Quoted 114 lines

PYTHON_PACKAGE_UNDER_TEST = "python-pymongo" IMAGE_INSTALL_append = " ${PYTHON_PACKAGE_UNDER_TEST}" PYTHON_IMPORTS_UNDER_TEST = "bson gridfs pymongo"

---
  lib/oeqa/runtime/cases/python2_module.py | 97 ++++++++++++++++++++++++
  1 file changed, 97 insertions(+)

create mode 100644 lib/oeqa/runtime/cases/python2_module.py

lib/oeqa/runtime/cases/python2_module.py new file +97 -0
new file mode 100644
index 00000000..59ae00fb
@@ -0,0 +1,97 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import OETestDataDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+
+class PythonModuleTest(OERuntimeTestCase):
+    """This test case is intentionally limited to only tesing one
+       python package/recipe at a time, because the use case is to
+       determine whether dependencies have been met for a minimal
+       image with 'only' the package under test installed. This
+       dependency checking must include the packages-split python
+       standard library modules that OE/YP creates from the python
+       manifest.
+
+       TODO: Be smarter about PYTHON_IMPORTS_UNDER_TEST, as this
+             should be discoverable from /usr/lib/python2.7/site-packages
+             or from the rpm/deb/ipk of the python package itself.
+             What we do NOT want to do is use pkgdata or some other
+             magical Python script that will add dependencies to the
+             test image. We need as pristine and minimalist a test
+             environment as we can get.
+
+       TODO: Use a minimal master test image and install the package under
+             test from a package feed using a package manager in the master
+             test image. This would allow for much shorter developement
+             cycles.
+
+       TODO: Parse the ImportError and give hints about what dependencies
+             are missing.
+
+
+       Example configuration in local.conf:
+
+       IMAGE_CLASSES += " testimage"
+       DISTRO_FEAURES_append = " ptest"
+       EXTRA_IMAGE_FEATURES = "debug-tweaks"
+       TESTIMAGE_AUTO = "1"
+       TEST_SUITES = " ping ssh python2 ptest python2_module"
+       TEST_QEMUPARAMS += "-smp 4 -m 8192"
+       TEST_RUNQEMUPARAMS += "kvm gl"
+       IMAGE_ROOTFS_SIZE ?= "8192"
+       IMAGE_ROOTFS_EXTRA_SPACE_append = "${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "", d)}"
+       IMAGE_INSTALL_append = " ptest-runner dropbear procps coreutils iproute2 sysstat"
+       PYTHON_PACKAGE_UNDER_TEST = "python-engineio"
+       IMAGE_INSTALL_append = " ${PYTHON_PACKAGE_UNDER_TEST}"
+       PYTHON_IMPORTS_UNDER_TEST = "engineio"
+    """
+
+    package = ""
+    imports = []
+
+    @classmethod
+    def setUp(cls):
+        if 'PYTHON_PACKAGE_UNDER_TEST' in cls.tc.td:
+            cls.package = cls.tc.td.get('PYTHON_PACKAGE_UNDER_TEST')
+            cls.logger.debug('Running import test on "%s" recipe' % cls.package)
+        else:
+            cls.logger.error('No recipe to test found in configuration.\n'
+                             'Please set in PYTHON_PACKAGE_UNDER_TEST')
+        if 'PYTHON_IMPORTS_UNDER_TEST' in cls.tc.td:
+            cls.imports = cls.tc.td.get('PYTHON_IMPORTS_UNDER_TEST').split()
+            if isinstance(cls.imports, list) and len(cls.imports) > 0:
+                cls.logger.info('Importing from %s' % cls.imports)
+            else:
+                cls.logger.error("PYTHON_IMPORTS_UNDER_TEST should be a space delimited list")
+                cls.logger.error("typeof(PYTHON_IMPORTS_UNDER_TEST) is %s" % type(cls.imports))
+        else:
+            cls.logger.error("No modules to import found in configuration.\n"
+                             "Please set in variable PYTHON_IMPORTS_UNDER_TEST")
+
+
+class PythonModuleImportTest(PythonModuleTest):
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    @OETestDepends(['python2.PythonTest.test_python'])
+    @OETestDataDepends(['PYTHON_PACKAGE_UNDER_TEST'])
+    @OETestDataDepends(['PYTHON_IMPORTS_UNDER_TEST'])
+    def test_python_module(self):
+        # We can't use the OEHasPackage decorator, because 'package' isn't defined
+        # until the class has already been instantiated
+        msg = 'Checking if "%s" is installed' % self.package
+        self.logger.debug(msg)
+        if not self.package in self.tc.image_packages:
+            msg = 'Test requires "%s" to be installed' % self.package
+            self.skipTest(msg)
+
+        for python_import in self.imports:
+            cmd = 'python -c "import %s"' % python_import
+            status, output = self.target.run(cmd)
+            msg = 'Exit status was not 0. Output: %s' % output
+            self.assertEqual(status, 0, msg=msg)
Signature · 2 lines
# Randy MacLeod
# Wind River Linux
author
#2 lore raw
Quoted 22 lines · Randy MacLeod
Quoted 21 lines · Tim Orling

This test case is intentionally limited to only tesing one python package/recipe at a time, because the use case is to determine whether dependencies have been met for a minimal image with 'only' the package under test installed. This dependency checking must include the packages-split python standard library modules that OE/YP creates from the python manifest.

TODO: Be smarter about PYTHON_IMPORTS_UNDER_TEST, as this
should be discoverable from /usr/lib/python2.7/site-packages or from the rpm/deb/ipk of the python package itself. What we do NOT want to do is use pkgdata or some other magical Python script that will add dependencies to the test image. We need as pristine and minimalist a test environment as we can get.

TODO: Use a minimal master test image and install the package under
test from a package feed using a package manager in the master test image. This would allow for much shorter developement cycles.

Quoted 7 lines
Quoted 2 lines

TODO: Parse the ImportError and give hints about what dependencies
are missing.

This looks useful. Do you have the python3 version done but not sent or should Trevor see if he can get that to work?

I have not started the python3 version yet. To do what is functional here will
be trivial changes. I'd love to see traction on the TODO list and it should be interesting
work for Trevor to do. This tool is now in my "daily" workflow.

There is one possible issue, which is a change in the variables does not necessarily trigger
the tests you expect. The symptom is running testimage tests the last thing you had the variable
set to, not the current value in local.conf. There are other places in the code base where variables
are watched and trigger changes appropriately. I did not go that far yet.

Also, the variables names between py2 and py3 would need to be different, but that is a thing
of the past for master, so not a real issue.

Quoted 164 lines
Quoted 12 lines

Example configuration in local.conf:

IMAGE_CLASSES += " testimage" DISTRO_FEAURES_append = " ptest" EXTRA_IMAGE_FEATURES = "debug-tweaks" TESTIMAGE_AUTO = "1"
TEST_SUITES = " ping ssh python2 ptest python2_module" TEST_QEMUPARAMS += "-smp 4 -m 8192" TEST_RUNQEMUPARAMS += "kvm gl" IMAGE_ROOTFS_SIZE ?= "8192" IMAGE_ROOTFS_EXTRA_SPACE_append =

"${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "", d)}"

Quoted 1 line

IMAGE_INSTALL_append = " ptest-runner dropbear procps coreutils iproute2

sysstat"
Is this really a minimal set of dependencies and if so, why do you need:
procps coreutils iproute2 sysstat
?

I should probably try it before replying but
it's already been a long day!

../Randy

Review

Quoted 11 lines

PYTHON_PACKAGE_UNDER_TEST = "python-pymongo" IMAGE_INSTALL_append = " ${PYTHON_PACKAGE_UNDER_TEST}" PYTHON_IMPORTS_UNDER_TEST = "bson gridfs pymongo"

---
  lib/oeqa/runtime/cases/python2_module.py | 97 ++++++++++++++++++++++++
  1 file changed, 97 insertions(+)

create mode 100644 lib/oeqa/runtime/cases/python2_module.py

(quoted diff) +0 -0

b/lib/oeqa/runtime/cases/python2_module.py

Quoted 18 lines

new file mode 100644
index 00000000..59ae00fb

lib/oeqa/runtime/cases/python2_module.py new file +13 -0
@@ -0,0 +1,97 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import OETestDataDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+
+class PythonModuleTest(OERuntimeTestCase):

lib/oeqa/runtime/cases/python2_module.py line 23

Quoted 10 lines
lib/oeqa/runtime/cases/python2_module.py new file +10 -0
+    """This test case is intentionally limited to only tesing one
+       python package/recipe at a time, because the use case is to
+       determine whether dependencies have been met for a minimal
+       image with 'only' the package under test installed. This
+       dependency checking must include the packages-split python
+       standard library modules that OE/YP creates from the python
+       manifest.
+
+       TODO: Be smarter about PYTHON_IMPORTS_UNDER_TEST, as this
+             should be discoverable from

/usr/lib/python2.7/site-packages

lib/oeqa/runtime/cases/python2_module.py

Quoted 7 lines
lib/oeqa/runtime/cases/python2_module.py new file +7 -0
+             or from the rpm/deb/ipk of the python package itself.
+             What we do NOT want to do is use pkgdata or some other
+             magical Python script that will add dependencies to the
+             test image. We need as pristine and minimalist a test
+             environment as we can get.
+
+       TODO: Use a minimal master test image and install the package

under

lib/oeqa/runtime/cases/python2_module.py line 31

Quoted 1 line
lib/oeqa/runtime/cases/python2_module.py new file +1 -0
+             test from a package feed using a package manager in the

master

lib/oeqa/runtime/cases/python2_module.py

Quoted 4 lines
lib/oeqa/runtime/cases/python2_module.py new file +4 -0
+             test image. This would allow for much shorter developement
+             cycles.
+
+       TODO: Parse the ImportError and give hints about what

dependencies

Quoted 4 lines
lib/oeqa/runtime/cases/python2_module.py new file +4 -0
+             are missing.
+
+
+       Example configuration in local.conf:

lib/oeqa/runtime/cases/python2_module.py

Quoted 10 lines
lib/oeqa/runtime/cases/python2_module.py new file +10 -0
+
+       IMAGE_CLASSES += " testimage"
+       DISTRO_FEAURES_append = " ptest"
+       EXTRA_IMAGE_FEATURES = "debug-tweaks"
+       TESTIMAGE_AUTO = "1"
+       TEST_SUITES = " ping ssh python2 ptest python2_module"
+       TEST_QEMUPARAMS += "-smp 4 -m 8192"
+       TEST_RUNQEMUPARAMS += "kvm gl"
+       IMAGE_ROOTFS_SIZE ?= "8192"
+       IMAGE_ROOTFS_EXTRA_SPACE_append =

"${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "", d)}"

lib/oeqa/runtime/cases/python2_module.py line 50

Quoted 1 line
lib/oeqa/runtime/cases/python2_module.py new file +1 -0
+       IMAGE_INSTALL_append = " ptest-runner dropbear procps coreutils

iproute2 sysstat"

lib/oeqa/runtime/cases/python2_module.py

Quoted 13 lines
lib/oeqa/runtime/cases/python2_module.py new file +13 -0
+       PYTHON_PACKAGE_UNDER_TEST = "python-engineio"
+       IMAGE_INSTALL_append = " ${PYTHON_PACKAGE_UNDER_TEST}"
+       PYTHON_IMPORTS_UNDER_TEST = "engineio"
+    """
+
+    package = ""
+    imports = []
+
+    @classmethod
+    def setUp(cls):
+        if 'PYTHON_PACKAGE_UNDER_TEST' in cls.tc.td:
+            cls.package = cls.tc.td.get('PYTHON_PACKAGE_UNDER_TEST')
+            cls.logger.debug('Running import test on "%s" recipe' %

cls.package)

lib/oeqa/runtime/cases/python2_module.py line 65

Quoted 2 lines
lib/oeqa/runtime/cases/python2_module.py new file +2 -0
+        else:
+            cls.logger.error('No recipe to test found in

configuration.\n'

lib/oeqa/runtime/cases/python2_module.py

Quoted 3 lines
lib/oeqa/runtime/cases/python2_module.py new file +3 -0
+                             'Please set in PYTHON_PACKAGE_UNDER_TEST')
+        if 'PYTHON_IMPORTS_UNDER_TEST' in cls.tc.td:
+            cls.imports =

cls.tc.td.get('PYTHON_IMPORTS_UNDER_TEST').split()

lib/oeqa/runtime/cases/python2_module.py

Quoted 4 lines
lib/oeqa/runtime/cases/python2_module.py new file +4 -0
+            if isinstance(cls.imports, list) and len(cls.imports) > 0:
+                cls.logger.info('Importing from %s' % cls.imports)
+            else:
+                cls.logger.error("PYTHON_IMPORTS_UNDER_TEST should be a

space delimited list")

lib/oeqa/runtime/cases/python2_module.py line 73

Quoted 1 line
lib/oeqa/runtime/cases/python2_module.py new file +1 -0
+                cls.logger.error("typeof(PYTHON_IMPORTS_UNDER_TEST) is

%s" % type(cls.imports))

lib/oeqa/runtime/cases/python2_module.py line 75

Quoted 2 lines
lib/oeqa/runtime/cases/python2_module.py new file +2 -0
+        else:
+            cls.logger.error("No modules to import found in

configuration.\n"

lib/oeqa/runtime/cases/python2_module.py line 76

Quoted 1 line
lib/oeqa/runtime/cases/python2_module.py new file +1 -0
+                             "Please set in variable

PYTHON_IMPORTS_UNDER_TEST")

lib/oeqa/runtime/cases/python2_module.py

Quoted 9 lines
lib/oeqa/runtime/cases/python2_module.py new file +9 -0
+
+
+class PythonModuleImportTest(PythonModuleTest):
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    @OETestDepends(['python2.PythonTest.test_python'])
+    @OETestDataDepends(['PYTHON_PACKAGE_UNDER_TEST'])
+    @OETestDataDepends(['PYTHON_IMPORTS_UNDER_TEST'])
+    def test_python_module(self):
+        # We can't use the OEHasPackage decorator, because 'package'

isn't defined

lib/oeqa/runtime/cases/python2_module.py line 97

Quoted 13 lines
lib/oeqa/runtime/cases/python2_module.py new file +12 -0
+        # until the class has already been instantiated
+        msg = 'Checking if "%s" is installed' % self.package
+        self.logger.debug(msg)
+        if not self.package in self.tc.image_packages:
+            msg = 'Test requires "%s" to be installed' % self.package
+            self.skipTest(msg)
+
+        for python_import in self.imports:
+            cmd = 'python -c "import %s"' % python_import
+            status, output = self.target.run(cmd)
+            msg = 'Exit status was not 0. Output: %s' % output
+            self.assertEqual(status, 0, msg=msg)

--
# Randy MacLeod
# Wind River Linux
--
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel

author
#3 lore raw
In reply to Randy MacLeod
Quoted 40 lines · Randy MacLeod
Quoted 16 lines · Tim Orling

This test case is intentionally limited to only tesing one python package/recipe at a time, because the use case is to determine whether dependencies have been met for a minimal image with 'only' the package under test installed. This dependency checking must include the packages-split python standard library modules that OE/YP creates from the python manifest.

TODO: Be smarter about PYTHON_IMPORTS_UNDER_TEST, as this
should be discoverable from /usr/lib/python2.7/site-packages or from the rpm/deb/ipk of the python package itself. What we do NOT want to do is use pkgdata or some other magical Python script that will add dependencies to the test image. We need as pristine and minimalist a test environment as we can get.

Quoted 7 lines

TODO: Use a minimal master test image and install the package under
test from a package feed using a package manager in the master test image. This would allow for much shorter developement cycles.

TODO: Parse the ImportError and give hints about what dependencies
are missing.

This looks useful. Do you have the python3 version done but not sent or should Trevor see if he can get that to work?

Quoted 12 lines

Example configuration in local.conf:

IMAGE_CLASSES += " testimage" DISTRO_FEAURES_append = " ptest" EXTRA_IMAGE_FEATURES = "debug-tweaks" TESTIMAGE_AUTO = "1"
TEST_SUITES = " ping ssh python2 ptest python2_module" TEST_QEMUPARAMS += "-smp 4 -m 8192" TEST_RUNQEMUPARAMS += "kvm gl" IMAGE_ROOTFS_SIZE ?= "8192" IMAGE_ROOTFS_EXTRA_SPACE_append =

Quoted 8 lines

"${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "", d)}"

Quoted 1 line

IMAGE_INSTALL_append = " ptest-runner dropbear procps coreutils iproute2

sysstat"
Is this really a minimal set of dependencies and if so, why do you need:
procps coreutils iproute2 sysstat
?

Those are required to make the QEMU runner dump any missing things, like TUN/TAP. So no, not required. The
host_dump stuff isn't really all that helpful anyway. If you can run "testimage" with KVM, TUN/TAP and virgl/gl then
you have all the speed ups that I was trying to make sure were working on the platform running these tests (with gitlab ci runner)

The fact that the docker-executor in gitlab does not allow the --add-groups option to the docker command line gets in the way
anyway... so you would have to run the container privileged and I'm not going to do that ;)

The user in the docker container does not have permissions on /dev/kvm, etc. But that has nothing to do with this code :)

Quoted 145 lines

I should probably try it before replying but
it's already been a long day!

../Randy

Review

Quoted 11 lines

PYTHON_PACKAGE_UNDER_TEST = "python-pymongo" IMAGE_INSTALL_append = " ${PYTHON_PACKAGE_UNDER_TEST}" PYTHON_IMPORTS_UNDER_TEST = "bson gridfs pymongo"

---
  lib/oeqa/runtime/cases/python2_module.py | 97 ++++++++++++++++++++++++
  1 file changed, 97 insertions(+)

create mode 100644 lib/oeqa/runtime/cases/python2_module.py

(quoted diff) +0 -0

b/lib/oeqa/runtime/cases/python2_module.py

Quoted 18 lines

new file mode 100644
index 00000000..59ae00fb

lib/oeqa/runtime/cases/python2_module.py new file +13 -0
@@ -0,0 +1,97 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import OETestDataDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+
+class PythonModuleTest(OERuntimeTestCase):

lib/oeqa/runtime/cases/python2_module.py line 23

Quoted 10 lines
lib/oeqa/runtime/cases/python2_module.py new file +10 -0
+    """This test case is intentionally limited to only tesing one
+       python package/recipe at a time, because the use case is to
+       determine whether dependencies have been met for a minimal
+       image with 'only' the package under test installed. This
+       dependency checking must include the packages-split python
+       standard library modules that OE/YP creates from the python
+       manifest.
+
+       TODO: Be smarter about PYTHON_IMPORTS_UNDER_TEST, as this
+             should be discoverable from

/usr/lib/python2.7/site-packages

lib/oeqa/runtime/cases/python2_module.py

Quoted 7 lines
lib/oeqa/runtime/cases/python2_module.py new file +7 -0
+             or from the rpm/deb/ipk of the python package itself.
+             What we do NOT want to do is use pkgdata or some other
+             magical Python script that will add dependencies to the
+             test image. We need as pristine and minimalist a test
+             environment as we can get.
+
+       TODO: Use a minimal master test image and install the package

under

lib/oeqa/runtime/cases/python2_module.py line 31

Quoted 1 line
lib/oeqa/runtime/cases/python2_module.py new file +1 -0
+             test from a package feed using a package manager in the

master

lib/oeqa/runtime/cases/python2_module.py

Quoted 4 lines
lib/oeqa/runtime/cases/python2_module.py new file +4 -0
+             test image. This would allow for much shorter developement
+             cycles.
+
+       TODO: Parse the ImportError and give hints about what

dependencies

Quoted 4 lines
lib/oeqa/runtime/cases/python2_module.py new file +4 -0
+             are missing.
+
+
+       Example configuration in local.conf:

lib/oeqa/runtime/cases/python2_module.py

Quoted 10 lines
lib/oeqa/runtime/cases/python2_module.py new file +10 -0
+
+       IMAGE_CLASSES += " testimage"
+       DISTRO_FEAURES_append = " ptest"
+       EXTRA_IMAGE_FEATURES = "debug-tweaks"
+       TESTIMAGE_AUTO = "1"
+       TEST_SUITES = " ping ssh python2 ptest python2_module"
+       TEST_QEMUPARAMS += "-smp 4 -m 8192"
+       TEST_RUNQEMUPARAMS += "kvm gl"
+       IMAGE_ROOTFS_SIZE ?= "8192"
+       IMAGE_ROOTFS_EXTRA_SPACE_append =

"${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "", d)}"

lib/oeqa/runtime/cases/python2_module.py line 50

Quoted 1 line
lib/oeqa/runtime/cases/python2_module.py new file +1 -0
+       IMAGE_INSTALL_append = " ptest-runner dropbear procps coreutils

iproute2 sysstat"

lib/oeqa/runtime/cases/python2_module.py

Quoted 13 lines
lib/oeqa/runtime/cases/python2_module.py new file +13 -0
+       PYTHON_PACKAGE_UNDER_TEST = "python-engineio"
+       IMAGE_INSTALL_append = " ${PYTHON_PACKAGE_UNDER_TEST}"
+       PYTHON_IMPORTS_UNDER_TEST = "engineio"
+    """
+
+    package = ""
+    imports = []
+
+    @classmethod
+    def setUp(cls):
+        if 'PYTHON_PACKAGE_UNDER_TEST' in cls.tc.td:
+            cls.package = cls.tc.td.get('PYTHON_PACKAGE_UNDER_TEST')
+            cls.logger.debug('Running import test on "%s" recipe' %

cls.package)

lib/oeqa/runtime/cases/python2_module.py line 65

Quoted 2 lines
lib/oeqa/runtime/cases/python2_module.py new file +2 -0
+        else:
+            cls.logger.error('No recipe to test found in

configuration.\n'

lib/oeqa/runtime/cases/python2_module.py

Quoted 3 lines
lib/oeqa/runtime/cases/python2_module.py new file +3 -0
+                             'Please set in PYTHON_PACKAGE_UNDER_TEST')
+        if 'PYTHON_IMPORTS_UNDER_TEST' in cls.tc.td:
+            cls.imports =

cls.tc.td.get('PYTHON_IMPORTS_UNDER_TEST').split()

lib/oeqa/runtime/cases/python2_module.py

Quoted 4 lines
lib/oeqa/runtime/cases/python2_module.py new file +4 -0
+            if isinstance(cls.imports, list) and len(cls.imports) > 0:
+                cls.logger.info('Importing from %s' % cls.imports)
+            else:
+                cls.logger.error("PYTHON_IMPORTS_UNDER_TEST should be a

space delimited list")

lib/oeqa/runtime/cases/python2_module.py line 73

Quoted 1 line
lib/oeqa/runtime/cases/python2_module.py new file +1 -0
+                cls.logger.error("typeof(PYTHON_IMPORTS_UNDER_TEST) is

%s" % type(cls.imports))

lib/oeqa/runtime/cases/python2_module.py line 75

Quoted 2 lines
lib/oeqa/runtime/cases/python2_module.py new file +2 -0
+        else:
+            cls.logger.error("No modules to import found in

configuration.\n"

lib/oeqa/runtime/cases/python2_module.py line 76

Quoted 1 line
lib/oeqa/runtime/cases/python2_module.py new file +1 -0
+                             "Please set in variable

PYTHON_IMPORTS_UNDER_TEST")

lib/oeqa/runtime/cases/python2_module.py

Quoted 9 lines
lib/oeqa/runtime/cases/python2_module.py new file +9 -0
+
+
+class PythonModuleImportTest(PythonModuleTest):
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    @OETestDepends(['python2.PythonTest.test_python'])
+    @OETestDataDepends(['PYTHON_PACKAGE_UNDER_TEST'])
+    @OETestDataDepends(['PYTHON_IMPORTS_UNDER_TEST'])
+    def test_python_module(self):
+        # We can't use the OEHasPackage decorator, because 'package'

isn't defined

lib/oeqa/runtime/cases/python2_module.py line 97

Quoted 13 lines
lib/oeqa/runtime/cases/python2_module.py new file +12 -0
+        # until the class has already been instantiated
+        msg = 'Checking if "%s" is installed' % self.package
+        self.logger.debug(msg)
+        if not self.package in self.tc.image_packages:
+            msg = 'Test requires "%s" to be installed' % self.package
+            self.skipTest(msg)
+
+        for python_import in self.imports:
+            cmd = 'python -c "import %s"' % python_import
+            status, output = self.target.run(cmd)
+            msg = 'Exit status was not 0. Output: %s' % output
+            self.assertEqual(status, 0, msg=msg)

--
# Randy MacLeod
# Wind River Linux
--
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel