-
Notifications
You must be signed in to change notification settings - Fork 301
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 exercise deletion with existing Iris sessions
#9567
Conversation
WalkthroughThe pull request introduces a new test method Changes
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
src/test/java/de/tum/cit/aet/artemis/iris/IrisExerciseChatSessionIntegrationTest.java (1)
93-93
: Consider adding test for multiple Iris sessions.To ensure comprehensive testing of the cascade delete functionality, consider adding a test case that verifies deletion of multiple Iris sessions associated with the same exercise.
Here's a suggested test case:
@Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void testDeleteExerciseWithMultipleIrisSessions() throws Exception { // Given database.resetTrackedQueries(); var irisSession1 = request.postWithResponseBody(exerciseChatUrl(exercise.getId()), null, IrisSession.class, HttpStatus.CREATED); var irisSession2 = request.postWithResponseBody(exerciseChatUrl(exercise.getId()), null, IrisSession.class, HttpStatus.CREATED); assertThat(irisExerciseChatSessionRepository.findAllById(List.of(irisSession1.getId(), irisSession2.getId()))) .as("Both Iris sessions should exist before exercise deletion") .hasSize(2); // When request.delete("/api/programming-exercises/" + exercise.getId(), HttpStatus.OK); // Then assertThat(irisExerciseChatSessionRepository.findAllById(List.of(irisSession1.getId(), irisSession2.getId()))) .as("All Iris sessions should be deleted along with the exercise") .isEmpty(); database.assertMaxQueryCount(7); // Adjust the number based on expected queries }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
⛔ Files ignored due to path filters (2)
src/main/resources/config/liquibase/changelog/20241023456789_changelog.xml
is excluded by!**/*.xml
src/main/resources/config/liquibase/master.xml
is excluded by!**/*.xml
📒 Files selected for processing (1)
- src/test/java/de/tum/cit/aet/artemis/iris/IrisExerciseChatSessionIntegrationTest.java (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/test/java/de/tum/cit/aet/artemis/iris/IrisExerciseChatSessionIntegrationTest.java (1)
Pattern
src/test/java/**/*.java
: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true
📓 Learnings (1)
src/test/java/de/tum/cit/aet/artemis/iris/IrisExerciseChatSessionIntegrationTest.java (1)
Learnt from: alexjoham PR: ls1intum/Artemis#9455 File: src/test/java/de/tum/cit/aet/artemis/iris/IrisTextExerciseChatMessageIntegrationTest.java:401-401 Timestamp: 2024-10-15T11:33:17.915Z Learning: In the Artemis project, when new fields are added to classes like `PyrisChatStatusUpdateDTO`, corresponding tests may be implemented in separate integration test classes such as `IrisChatTokenTrackingIntegrationTest`.
src/test/java/de/tum/cit/aet/artemis/iris/IrisExerciseChatSessionIntegrationTest.java
Outdated
Show resolved
Hide resolved
src/test/java/de/tum/cit/aet/artemis/iris/IrisExerciseChatSessionIntegrationTest.java
Outdated
Show resolved
Hide resolved
Bugfix
: Fix exercise deletion with existing Iris sessionsDevelopment
: Fix exercise deletion with existing Iris sessions
3b584f1
Checklist
General
Server
Motivation and Context
Currently, we are unable to delete exercises which have any associated iris sessions in the database, due to a foreign key integrity violation. This PR adds a database migration to introduce a cascading delete on that foreign key, so when an exercise is deleted, all associated sessions are automatically deleted as well. This also triggers (already existing) cascading deletes of all of the session's messages, and all of those messages' contents.
As far as I know, there are no foreign keys referencing
iris_session
anywhere else in the database, so this change should not introduce further integrity issues.Description
Steps for Testing
Prerequisites:
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Performance Review
Code Review
Manual Tests
Summary by CodeRabbit