def test_new_problem(self): self.replies = 4 huge_file_path = get_huge_file_path() buses = list() while len(buses) < self.replies: huge_file = open(huge_file_path, "r") description = { "analyzer": "problems2testsuite_analyzer", "reason": "Application has been killed", "backtrace": "die()", "duphash": "NEW_PROBLEM_DATA_SIZE", "uuid": "NEW_PROBLEM_DATA_SIZE", "huge_file": dbus.types.UnixFd(huge_file), "executable": "/usr/bin/foo", "type": "abrt-problems2-sanity" } bus = dbus.SystemBus(private=True) p2_proxy = bus.get_object(BUS_NAME, '/org/freedesktop/Problems2') p2 = dbus.Interface(p2_proxy, dbus_interface='org.freedesktop.Problems2') buses.append((bus, p2, description, huge_file)) task_paths = list() for bus, p2, description, _ in buses: task_paths.append((p2.NewProblem(description, 0x1 | 0x4), bus)) tasks = list() for path, bus in task_paths: tasks.append(Problems2Task(bus, path)) for i in range(0, 60): for t in tasks: status = t.getproperty("Status") if status == 4: results, code = t.Finish() self.assertIn("Error.Message", results) self.assertRegexpMatches( results["Error.Message"], "Failed to create new problem " "directory: Problem data is " "too big") tasks.remove(t) elif not status == 1: self.fail("Unexpected task status: %s" % (str(status))) if not tasks: break time.sleep(1) self.assertFalse(tasks) for _, _, _, huge_file in buses: huge_file.close()
def test_new_problem(self): self.replies = 4 huge_file_path = get_huge_file_path() buses = list() while len(buses) < self.replies: huge_file = open(huge_file_path, "r") description = {"analyzer": "problems2testsuite_analyzer", "reason": "Application has been killed", "backtrace": "die()", "duphash": "NEW_PROBLEM_DATA_SIZE", "uuid": "NEW_PROBLEM_DATA_SIZE", "huge_file": dbus.types.UnixFd(huge_file), "executable": "/usr/bin/foo", "type": "abrt-problems2-sanity"} bus = dbus.SystemBus(private=True) p2_proxy = bus.get_object(BUS_NAME, '/org/freedesktop/Problems2') p2 = dbus.Interface(p2_proxy, dbus_interface='org.freedesktop.Problems2') buses.append((bus, p2, description, huge_file)) task_paths = list() for bus, p2, description, _ in buses: task_paths.append((p2.NewProblem(description, 0x1 | 0x4), bus)) tasks = list() for path, bus in task_paths: tasks.append(Problems2Task(bus, path)) for i in range(0, 60): for t in tasks: status = t.getproperty("Status") if status == 4: results, code = t.Finish() self.assertIn("Error.Message", results) self.assertRegexpMatches(results["Error.Message"], "Failed to create new problem " "directory: Problem data is " "too big") tasks.remove(t) elif not status == 1: self.fail("Unexpected task status: %s" % (str(status))) if not tasks: break time.sleep(1) self.assertFalse(tasks) for _, _, _, huge_file in buses: huge_file.close()
def test_new_problem_data_size_limit(self): huge_file_path = get_huge_file_path() with open(huge_file_path, "r") as huge_file: description = {"analyzer": "problems2testsuite_analyzer", "reason": "Application has been killed", "backtrace": "die()", "duphash": "NEW_PROBLEM_DATA_SIZE", "uuid": "NEW_PROBLEM_DATA_SIZE", "huge_file": dbus.types.UnixFd(huge_file), "executable": "/usr/bin/foo", "type": "abrt-problems2-sanity"} task_path = self.p2.NewProblem(description, 0x1) self.assertRaisesProblems2Exception( "Failed to " "create new problem directory: Problem data is too big", wait_for_task_new_problem, self, self.bus, task_path)
def test_task_running_task_destroyed_with_session(self): pbus = dbus.SystemBus(private=True) p2_proxy = pbus.get_object(BUS_NAME, '/org/freedesktop/Problems2') p2 = dbus.Interface(p2_proxy, dbus_interface='org.freedesktop.Problems2') task_path = None huge_file_path = get_huge_file_path() with open(huge_file_path, "r") as huge_file: description = {"analyzer": "problems2testsuite_analyzer", "reason": "Application has been killed", "backtrace": "die()", "duphash": "TASK_NEW_PROBLEM_SESSION", "uuid": "TASK_NEW_PROBLEM_SESSION", "huge_file": dbus.types.UnixFd(huge_file), "executable": "/usr/bin/foo", "type": "abrt-problems2-running-destroyed-with-session"} # Create task, run it and stop after temporary entry is created task_path = p2.NewProblem(description, 0x1 | 0x2 | 0x4) pbus.close() task = Problems2Task(self.bus, task_path) self.assertRaisesDBusError( "org.freedesktop.DBus.Error.UnknownMethod: No such interface " "'org.freedesktop.DBus.Properties' on object at path " + task_path, task.getproperty, "Status") # let abrt-dbus finish its work load pbus = dbus.SystemBus(private=True) p2_proxy = pbus.get_object(BUS_NAME, '/org/freedesktop/Problems2') p2 = dbus.Interface(p2_proxy, dbus_interface='org.freedesktop.Problems2') time.sleep(10)
def test_task_running_task_destroyed_with_session(self): pbus = dbus.SystemBus(private=True) p2_proxy = pbus.get_object(BUS_NAME, '/org/freedesktop/Problems2') p2 = dbus.Interface(p2_proxy, dbus_interface='org.freedesktop.Problems2') task_path = None huge_file_path = get_huge_file_path() with open(huge_file_path, "r") as huge_file: description = { "analyzer": "problems2testsuite_analyzer", "reason": "Application has been killed", "backtrace": "die()", "duphash": "TASK_NEW_PROBLEM_SESSION", "uuid": "TASK_NEW_PROBLEM_SESSION", "huge_file": dbus.types.UnixFd(huge_file), "executable": "/usr/bin/foo", "type": "abrt-problems2-running-destroyed-with-session" } # Create task, run it and stop after temporary entry is created task_path = p2.NewProblem(description, 0x1 | 0x2 | 0x4) pbus.close() task = Problems2Task(self.bus, task_path) self.assertRaisesDBusError( "org.freedesktop.DBus.Error.UnknownMethod: No such interface " "'org.freedesktop.DBus.Properties' on object at path " + task_path, task.getproperty, "Status") # let abrt-dbus finish its work load pbus = dbus.SystemBus(private=True) p2_proxy = pbus.get_object(BUS_NAME, '/org/freedesktop/Problems2') p2 = dbus.Interface(p2_proxy, dbus_interface='org.freedesktop.Problems2') time.sleep(10)
def test_save_elements_data_size_limit(self): huge_file_path = get_huge_file_path() entry = Problems2Entry(self.bus, self.p2_entry_path) key = "huge_file" with open(huge_file_path, "r") as huge_file: entry.SaveElements({key: dbus.types.UnixFd(huge_file)}, 0) data = entry.ReadElements([key], 0x1) self.assertIn(key, data, "SaveElements: created truncated file") fd = data[key].take() end = os.lseek(fd, 0, os.SEEK_END) os.close(fd) self.assertLessEqual(end, get_dbus_limit_data_size(), "SaveElements: wrote up to Size limit Bytes") smaller_ed = {key: "smaller file"} entry.SaveElements(smaller_ed, 0) data = entry.ReadElements([key], 0x4) self.assertIn(key, data, "SaveElements: created non-text file") self.assertEqual(smaller_ed[key], data[key], "SaveElements: dump directory does not grow")