Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Fix flaky ResultListenerIntegrationTest #7326

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

import java.time.Duration;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.junit.jupiter.api.AfterEach;
Expand All @@ -16,6 +17,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.util.ReflectionTestUtils;

import de.tum.in.www1.artemis.AbstractSpringIntegrationLocalCILocalVCTest;
import de.tum.in.www1.artemis.course.CourseUtilService;
Expand Down Expand Up @@ -92,8 +94,11 @@ void cleanup() {

@BeforeEach
void setupTestScenario() {
// Prevents the ParticipantScoreScheduleService from scheduling tasks related to prior results
ReflectionTestUtils.setField(participantScoreScheduleService, "lastScheduledRun", Optional.of(Instant.now()));

ParticipantScoreScheduleService.DEFAULT_WAITING_TIME_FOR_SCHEDULED_TASKS = 100;
participantScoreScheduleService.activate();
ParticipantScoreScheduleService.DEFAULT_WAITING_TIME_FOR_SCHEDULED_TASKS = 50;
ZonedDateTime pastReleaseDate = ZonedDateTime.now().minusDays(5);
ZonedDateTime pastDueDate = ZonedDateTime.now().minusDays(3);
ZonedDateTime pastAssessmentDueDate = ZonedDateTime.now().minusDays(2);
Expand All @@ -103,7 +108,6 @@ void setupTestScenario() {
idOfStudent1 = student1.getId();
// creating course
Course course = courseUtilService.createCourse();
Long idOfCourse = course.getId();
TextExercise textExercise = textExerciseUtilService.createIndividualTextExercise(course, pastReleaseDate, pastDueDate, pastAssessmentDueDate);
idOfIndividualTextExercise = textExercise.getId();
Exercise teamExercise = textExerciseUtilService.createTeamTextExercise(course, pastReleaseDate, pastDueDate, pastAssessmentDueDate);
Expand Down Expand Up @@ -422,7 +426,7 @@ private ParticipantScore setupTestScenarioWithOneResultSaved(boolean isRatedResu

// Wait for the scheduler to execute its task
participantScoreScheduleService.executeScheduledTasks();
await().atMost(Duration.ofSeconds(30)).until(() -> participantScoreScheduleService.isIdle());
await().until(() -> participantScoreScheduleService.isIdle());

var savedParticipantScores = participantScoreRepository.findAllByExercise(exercise);
assertThat(savedParticipantScores).isNotEmpty();
Expand Down
Loading