Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_remove(self):
pool_manager = PHPFPMPoolManager()
assert_that(pool_manager, not_none())
# check to make sure there are no pools
current_pools = context.objects.find_all(types=pool_manager.types)
assert_that(current_pools, has_length(0))
# find pools
pool_manager._discover_objects()
# check that a pool is found
current_pools = context.objects.find_all(types=pool_manager.types)
assert_that(current_pools, has_length(2))
# stop php-fpm
self.stop_fpm()
time.sleep(0.1) # release gil
# re-run master manager to remove the master
self.phpfpm_manager._discover_objects()
def test_discover_objects(self):
mysql_manager = MySQLManager()
assert_that(mysql_manager, not_none())
# check to make sure there are no mysqlds
mysql_objects = context.objects.find_all(types=mysql_manager.types)
assert_that(mysql_objects, has_length(0))
# find objects
mysql_manager._discover_objects()
# check to see that a mysqld is found
mysql_objects = context.objects.find_all(types=mysql_manager.types)
assert_that(mysql_objects, has_length(1))
def test_discover_objects(self):
pool_manager = PHPFPMPoolManager()
assert_that(pool_manager, not_none())
# check to make sure there are no pools
current_pools = context.objects.find_all(types=pool_manager.types)
assert_that(current_pools, has_length(0))
# find pools
pool_manager._discover_objects()
# check that a pool is found
current_pools = context.objects.find_all(types=pool_manager.types)
assert_that(current_pools, has_length(2))
def test_restart_objects(self):
phpfpm_manager = PHPFPMManager()
assert_that(phpfpm_manager, not_none())
# check to make sure there are no masters
current_masters = context.objects.find_all(types=phpfpm_manager.types)
assert_that(current_masters, has_length(0))
# find masters
phpfpm_manager._discover_objects()
# check to see that a master is found
current_masters = context.objects.find_all(types=phpfpm_manager.types)
assert_that(current_masters, has_length(1))
# store the master id
old_master_id = current_masters[0].id
# stop php-fpm
self.stop_fpm()
time.sleep(0.1)
def test_restart_objects(self):
mysql_manager = MySQLManager()
assert_that(mysql_manager, not_none())
# check to make sure there are no mysqlds
mysql_objects = context.objects.find_all(types=mysql_manager.types)
assert_that(mysql_objects, has_length(0))
# find objects
mysql_manager._discover_objects()
# check to see that a mysqld is found
mysql_objects = context.objects.find_all(types=mysql_manager.types)
assert_that(mysql_objects, has_length(1))
# store the mysqld id
old_master_id = mysql_objects[0].id
# stop mysqld
self.stop_mysqld()
time.sleep(0.1)
def setup_method(self, method):
super(MySQLMetaCollectorTestCase, self).setup_method(method)
self.old = deepcopy(context.app_config['mysql'])
context._setup_object_tank()
mysql_manager = MySQLManager()
mysql_manager._discover_objects()
found_objects = context.objects.find_all(types=mysql_manager.types)
self.mysql_object = found_objects[0]
def setup_method(self, method):
super(PHPFPMMetaCollectorTestCase, self).setup_method(method)
context._setup_object_tank()
phpfpm_manager = PHPFPMManager()
phpfpm_manager._discover_objects()
found_masters = context.objects.find_all(types=phpfpm_manager.types)
self.phpfpm_obj = found_masters[0]
def test_collect_remote(self):
context.app_config['mysql']['remote'] = True
context.app_config['mysql']['host'] = '127.0.0.1'
context.app_config['mysql']['port'] = '3306'
context.app_config['mysql'].pop('unix_socket', None)
mysql_manager = MySQLManager()
mysql_manager._discover_objects()
found_objects = context.objects.find_all(types=mysql_manager.types)
self.mysql_object = found_objects[0]
mysql_meta_collector = MySQLMetaCollector(
object=self.mysql_object, interval=self.mysql_object.intervals['meta']
)
# collect and assert that meta is not empty
mysql_meta_collector.collect()
# check value
assert_that(mysql_meta_collector.meta, has_entries(
{
'display_name': 'mysql @ hostname.nginx',
'local_id': 'd47bcca34c2b2836266086c5d5d428b754cc4831e2df6e251b2ffa27bca59b3b',
'type': 'mysql',
'cmd': 'unknown',
def test_discover(self):
assert_that(context.nginx_configs, has_length(0))
# init manager and make sure that object count is 0
manager = NginxManager()
assert_that(context.objects.find_all(types=manager.types), has_length(0))
# discover objects and make sure that there is now 1 managed nginx object
manager._discover_objects()
assert_that(context.objects.find_all(types=manager.types), has_length(1))
# check to see that there is now one nginx config
assert_that(context.nginx_configs, has_length(1))