Add comprehensive testing framework, performance monitoring, and plugin system
- Add complete pytest testing framework with conftest.py and test files - Add performance monitoring and benchmarking capabilities - Add plugin system with ccache plugin example - Add comprehensive documentation (API, deployment, testing, etc.) - Add Docker API wrapper for service deployment - Add advanced configuration examples - Remove old wget package file - Update core modules with enhanced functionality
This commit is contained in:
parent
4c0dcb2522
commit
c51819c836
30 changed files with 11141 additions and 105 deletions
101
examples/plugins/ccache_plugin.py
Normal file
101
examples/plugins/ccache_plugin.py
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Sample ccache plugin for deb-mock
|
||||
Demonstrates the plugin system capabilities
|
||||
"""
|
||||
|
||||
requires_api_version = "1.0"
|
||||
run_in_bootstrap = False
|
||||
|
||||
|
||||
def init(plugin_manager, conf, deb_mock):
|
||||
"""Plugin entry point"""
|
||||
CCachePlugin(plugin_manager, conf, deb_mock)
|
||||
|
||||
|
||||
class CCachePlugin:
|
||||
"""Enables ccache in deb-mock chroots"""
|
||||
|
||||
def __init__(self, plugin_manager, conf, deb_mock):
|
||||
self.plugin_manager = plugin_manager
|
||||
self.conf = conf
|
||||
self.deb_mock = deb_mock
|
||||
|
||||
# Plugin configuration with defaults
|
||||
self.ccache_dir = conf.get('dir', '/var/cache/deb-mock/ccache')
|
||||
self.max_cache_size = conf.get('max_cache_size', '2G')
|
||||
self.show_stats = conf.get('show_stats', True)
|
||||
self.compress = conf.get('compress', True)
|
||||
self.hashdir = conf.get('hashdir', True)
|
||||
self.debug = conf.get('debug', False)
|
||||
|
||||
# Register hooks
|
||||
self._register_hooks()
|
||||
|
||||
# Add ccache to build dependencies
|
||||
if hasattr(deb_mock.config, 'chroot_additional_packages'):
|
||||
if 'ccache' not in deb_mock.config.chroot_additional_packages:
|
||||
deb_mock.config.chroot_additional_packages.append('ccache')
|
||||
|
||||
print(f"CCache plugin initialized: cache_dir={self.ccache_dir}, max_size={self.max_cache_size}")
|
||||
|
||||
def _register_hooks(self):
|
||||
"""Register plugin hooks"""
|
||||
self.plugin_manager.add_hook("prebuild", self._ccache_prebuild)
|
||||
self.plugin_manager.add_hook("postbuild", self._ccache_postbuild)
|
||||
self.plugin_manager.add_hook("prechroot_init", self._ccache_prechroot_init)
|
||||
|
||||
def _ccache_prebuild(self, source_package, **kwargs):
|
||||
"""Setup ccache before build starts"""
|
||||
print(f"CCache: Setting up ccache for {source_package}")
|
||||
|
||||
# Set ccache environment variables
|
||||
if hasattr(self.deb_mock.config, 'build_env'):
|
||||
self.deb_mock.config.build_env.update({
|
||||
'CCACHE_DIR': '/var/tmp/ccache',
|
||||
'CCACHE_UMASK': '002',
|
||||
'CCACHE_COMPRESS': str(self.compress),
|
||||
'CCACHE_HASHDIR': '1' if self.hashdir else '0',
|
||||
'CCACHE_DEBUG': '1' if self.debug else '0'
|
||||
})
|
||||
|
||||
def _ccache_postbuild(self, build_result, source_package, **kwargs):
|
||||
"""Show ccache statistics after build"""
|
||||
if not self.show_stats:
|
||||
return
|
||||
|
||||
print("CCache: Build completed, showing statistics...")
|
||||
# In a real implementation, you would execute ccache --show-stats in the chroot
|
||||
|
||||
if build_result.get('success', False):
|
||||
print(f"CCache: Build successful for {source_package}")
|
||||
else:
|
||||
print(f"CCache: Build failed for {source_package}")
|
||||
|
||||
def _ccache_prechroot_init(self, chroot_name):
|
||||
"""Setup ccache in chroot before initialization"""
|
||||
print(f"CCache: Setting up ccache in chroot {chroot_name}")
|
||||
|
||||
# Create ccache directory in chroot
|
||||
chroot_ccache_dir = f"/var/tmp/ccache"
|
||||
|
||||
# In a real implementation, you would:
|
||||
# 1. Create the ccache directory in the chroot
|
||||
# 2. Set proper permissions
|
||||
# 3. Mount the host ccache directory if configured
|
||||
|
||||
print(f"CCache: Created {chroot_ccache_dir} in chroot {chroot_name}")
|
||||
|
||||
|
||||
# Example configuration for this plugin:
|
||||
# plugin_conf = {
|
||||
# 'ccache_enable': True,
|
||||
# 'ccache_opts': {
|
||||
# 'dir': '/var/cache/deb-mock/ccache',
|
||||
# 'max_cache_size': '4G',
|
||||
# 'show_stats': True,
|
||||
# 'compress': True,
|
||||
# 'hashdir': True,
|
||||
# 'debug': False
|
||||
# }
|
||||
# }
|
||||
Loading…
Add table
Add a link
Reference in a new issue