"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "buildbot/test/integration/test_setup_entrypoints.py" between
buildbot-3.0.2.tar.gz and buildbot-3.1.0.tar.gz

About: Buildbot is a continuous integration testing framework (Python-based). It supports also automation of complex build systems, application deployment, and management of sophisticated software-release processes.

test_setup_entrypoints.py  (buildbot-3.0.2):test_setup_entrypoints.py  (buildbot-3.1.0)
skipping to change at line 25 skipping to change at line 25
import importlib import importlib
import inspect import inspect
import os import os
import pkg_resources import pkg_resources
import warnings import warnings
import twisted import twisted
from twisted.trial import unittest from twisted.trial import unittest
from twisted.trial.unittest import SkipTest from twisted.trial.unittest import SkipTest
from zope.interface.verify import verifyClass
from buildbot.interfaces import IBuildStep from buildbot.interfaces import IBuildStep
from buildbot.interfaces import IChangeSource from buildbot.interfaces import IChangeSource
from buildbot.interfaces import IScheduler from buildbot.interfaces import IScheduler
from buildbot.interfaces import IWorker from buildbot.interfaces import IWorker
from buildbot.plugins.db import get_plugins from buildbot.plugins.db import get_plugins
def get_python_module_contents(package_name): def get_python_module_contents(package_name):
spec = importlib.util.find_spec(package_name) spec = importlib.util.find_spec(package_name)
if spec is None or spec.origin is None: if spec is None or spec.origin is None:
skipping to change at line 61 skipping to change at line 62
if dir_entry.is_dir(): if dir_entry.is_dir():
result.add(next_package_name) result.add(next_package_name)
result |= get_python_module_contents(next_package_name) result |= get_python_module_contents(next_package_name)
return result return result
# NOTE: when running this test locally, make sure to reinstall master after ever y change to pick up # NOTE: when running this test locally, make sure to reinstall master after ever y change to pick up
# new entry points. # new entry points.
class TestSetupPyEntryPoints(unittest.TestCase): class TestSetupPyEntryPoints(unittest.TestCase):
def test_changes(self): def test_changes(self):
self.verify_plugins_registered('changes', 'buildbot.changes', IChangeSou known_not_exported = {
rce) 'buildbot.changes.gerritchangesource.GerritChangeSourceBase',
'buildbot.changes.base.ReconfigurablePollingChangeSource',
'buildbot.changes.base.PollingChangeSource',
'buildbot.changes.base.ChangeSource',
}
self.verify_plugins_registered('changes', 'buildbot.changes', IChangeSou
rce,
known_not_exported)
def test_schedulers(self): def test_schedulers(self):
self.verify_plugins_registered('schedulers', 'buildbot.schedulers', ISch known_not_exported = {
eduler) 'buildbot.schedulers.basic.BaseBasicScheduler',
'buildbot.schedulers.timed.Timed',
'buildbot.schedulers.trysched.TryBase',
'buildbot.schedulers.base.BaseScheduler',
'buildbot.schedulers.timed.NightlyBase',
'buildbot.schedulers.basic.Scheduler',
}
self.verify_plugins_registered('schedulers', 'buildbot.schedulers', ISch
eduler,
known_not_exported)
def test_steps(self): def test_steps(self):
self.verify_plugins_registered('steps', 'buildbot.steps', IBuildStep) known_not_exported = {
'buildbot.steps.download_secret_to_worker.RemoveWorkerFileSecret',
'buildbot.steps.source.base.Source',
'buildbot.steps.download_secret_to_worker.DownloadSecretsToWorker',
'buildbot.steps.shell.SetProperty',
'buildbot.steps.worker.WorkerBuildStep',
'buildbot.steps.vstudio.VisualStudio',
}
self.verify_plugins_registered('steps', 'buildbot.steps', IBuildStep, kn
own_not_exported)
def test_util(self): def test_util(self):
# work around Twisted bug 9384. # work around Twisted bug 9384.
if pkg_resources.parse_version(twisted.__version__) < pkg_resources.pars e_version("18.9.0"): if pkg_resources.parse_version(twisted.__version__) < pkg_resources.pars e_version("18.9.0"):
raise SkipTest('manhole.py can not be imported on old twisted and ne w python') raise SkipTest('manhole.py can not be imported on old twisted and ne w python')
known_not_exported = { known_not_exported = {
'buildbot.util._notifier.Notifier', 'buildbot.util._notifier.Notifier',
'buildbot.util.bbcollections.KeyedSets', 'buildbot.util.bbcollections.KeyedSets',
'buildbot.util.codebase.AbsoluteSourceStampsMixin', 'buildbot.util.codebase.AbsoluteSourceStampsMixin',
skipping to change at line 167 skipping to change at line 192
'buildbot.secrets.secret.SecretDetails', 'buildbot.secrets.secret.SecretDetails',
} }
self.verify_plugins_registered('secrets', 'buildbot.secrets', None, know n_not_exported) self.verify_plugins_registered('secrets', 'buildbot.secrets', None, know n_not_exported)
def test_webhooks(self): def test_webhooks(self):
# in the case of webhooks the entry points list modules, not classes, so # in the case of webhooks the entry points list modules, not classes, so
# verify_plugins_registered won't work. For now let's ignore this edge c ase # verify_plugins_registered won't work. For now let's ignore this edge c ase
get_plugins('webhooks', None, load_now=True) get_plugins('webhooks', None, load_now=True)
def test_workers(self): def test_workers(self):
self.verify_plugins_registered('worker', 'buildbot.worker', IWorker) known_not_exported = {
'buildbot.worker.upcloud.UpcloudLatentWorker',
'buildbot.worker.base.AbstractWorker',
'buildbot.worker.latent.AbstractLatentWorker',
'buildbot.worker.latent.LocalLatentWorker',
'buildbot.worker.marathon.MarathonLatentWorker',
'buildbot.worker.docker.DockerBaseWorker',
}
self.verify_plugins_registered('worker', 'buildbot.worker', IWorker, kno
wn_not_exported)
def verify_plugins_registered(self, plugin_type, module_name, interface, def verify_plugins_registered(self, plugin_type, module_name, interface,
known_not_exported=None): known_not_exported=None):
# This will verify whether we can load plugins, i.e. whether the entry p oints are valid. # This will verify whether we can load plugins, i.e. whether the entry p oints are valid.
plugins = get_plugins(plugin_type, interface, load_now=True) plugins = get_plugins(plugin_type, interface, load_now=True)
# Now verify that are no unregistered plugins left. # Now verify that are no unregistered plugins left.
existing_classes = self.get_existing_classes(module_name, interface) existing_classes = self.get_existing_classes(module_name, interface)
exported_classes = {'{}.{}'.format(plugins._get_entry(name)._entry.modul e_name, name) exported_classes = {'{}.{}'.format(plugins._get_entry(name)._entry.modul e_name, name)
for name in plugins.names} for name in plugins.names}
if known_not_exported is None: if known_not_exported is None:
known_not_exported = set() known_not_exported = set()
not_exported_classes = existing_classes - exported_classes - known_not_e xported not_exported_classes = existing_classes - exported_classes - known_not_e xported
self.assertEqual(not_exported_classes, set()) self.assertEqual(not_exported_classes, set())
self.assertEqual(known_not_exported - existing_classes, set()) self.assertEqual(known_not_exported - existing_classes, set())
def class_provides_iface(self, interface, klass):
try:
verifyClass(interface, klass)
return True
except Exception:
return False
def get_existing_classes(self, module_name, interface): def get_existing_classes(self, module_name, interface):
existing_modules = get_python_module_contents(module_name) existing_modules = get_python_module_contents(module_name)
existing_classes = set() existing_classes = set()
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
for existing_module in existing_modules: for existing_module in existing_modules:
module = importlib.import_module(existing_module) module = importlib.import_module(existing_module)
for name, obj in inspect.getmembers(module): for name, obj in inspect.getmembers(module):
if name.startswith('_'): if name.startswith('_'):
continue continue
if inspect.isclass(obj) and obj.__module__ == existing_modul e: if inspect.isclass(obj) and obj.__module__ == existing_modul e:
if interface is not None and not issubclass(obj, interfa ce): if interface is not None and not self.class_provides_ifa ce(interface, obj):
continue continue
existing_classes.add('{}.{}'.format(existing_module, nam e)) existing_classes.add('{}.{}'.format(existing_module, nam e))
return existing_classes return existing_classes
 End of changes. 7 change blocks. 
7 lines changed or deleted 49 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)