A DM can choose (deliberately or randomly) to interrupt the players long rests with a random encounter. See for example this question: Our DM keeps interrupting our long rests
Now rules as written say that less than 1 hour of interruption, even strenuous fighting, doesn't invalidate the long rest. The players can fight the monsters that attacked them during their rest, go back to sleep, and still get the benefits of the long rest.
But how does that apply to resources like spell slots that were spent during the rest? Imagine the interruption happens one hour before the end of the long rest, the barbarian uses one of his rages, the casters use up spell slots, and so on, do they get all of that back one hour later? Or do they only recover the resources they had spent before starting the long rest?