def testExpiry(self): config = PMDAConfig() config.script_expiry_time = 2 self.setup(config) script = self.service.register_script(Script('kretprobe:vfs_read { @bytes = hist(retval); }')) time.sleep(4) script = self.service.refresh_script(script.script_id) self.assertIsNone(script)
def testTooMuchOutput(self): config = PMDAConfig() config.max_throughput = 64 * 1024 self.setup(config) script = self.service.register_script(Script('profile:hz:9999 { printf("test"); }')) time.sleep(15) script = self.service.refresh_script(script.script_id) self.assertEqual(script.state.status, 'error') self.assertRegex(script.state.error, 'BPFtrace output exceeds limit of .+ bytes per second')
def testTooManyKeys(self): config = PMDAConfig() config.max_throughput = 4 * 1024 self.setup(config) script = self.service.register_script(Script('profile:hz:999 { @test1[kstack,ustack] = count(); }')) for _i in range(20): script = self.service.refresh_script(script.script_id) if script.state.status == 'error': break time.sleep(1) script = self.service.refresh_script(script.script_id) self.assertEqual(script.state.status, 'error') self.assertRegex(script.state.error, 'BPFtrace output exceeds limit of .+ bytes per second')
def setup(self, config=None, logger=None): self.config = config or PMDAConfig() self.logger = logger or Logger(lambda x: print("Info: " + x), lambda x: print("Error: " + x)) self.service = BPFtraceService(self.config, self.logger) self.service.start_daemon()