tests: Enhance race conditions tests for recording API with additional consistency checks

This commit is contained in:
Carlos Santos 2025-05-07 13:00:48 +02:00
parent d85bda282e
commit 185d6e9def

View File

@ -11,6 +11,7 @@ import {
deleteAllRecordings,
deleteAllRooms,
deleteRecording,
getRecording,
getRecordingMedia,
sleep,
startRecording,
@ -191,10 +192,29 @@ describe('Recording API Race Conditions Tests', () => {
const deleteSuccessful = deleteResponse.status === 'fulfilled' && deleteResponse.value.status === 204;
expect(streamSuccessful || deleteSuccessful).toBe(true);
console.log(`Stream successful: ${streamSuccessful}, Delete successful: ${deleteSuccessful}`);
// If both operations are successful, it means that the logic has a problem
expect(streamSuccessful && deleteSuccessful).toBe(false);
if (deleteSuccessful) {
// If delete was successful, verify that a new streaming request fails
// This ensures the recording was actually deleted
const verificationStreamResponse = await getRecordingMedia(recordingId);
expect(verificationStreamResponse.status).not.toEqual(200);
expect(verificationStreamResponse.status).not.toEqual(206);
}
if (streamSuccessful && deleteSuccessful) {
// Both operations succeeded - this is possible if streaming started first
// and had an open connection when delete happened
// The system should still be in a consistent state where the recording is gone
console.log('Both operations succeeded - checking system consistency');
// Verify the recording doesn't exist in storage anymore
const verificationRecordingResponse = await getRecording(recordingId);
expect(verificationRecordingResponse.status).toBe(404);
}
expect(streamSuccessful || deleteSuccessful).toBe(true);
});
it('should handle race condition between bulk delete and recording start', async () => {