Skip to content

Iris: Add integration test for rewriting and consistency pipeline #10931

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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

cremertim
Copy link
Contributor

@cremertim cremertim commented May 27, 2025

Checklist

General

  • This is a small issue that I tested locally and was confirmed by another developer on a test server.

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the principle of data economy for all database calls.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).

Motivation and Context

In a previous PR, i introduced the Rewriting of FAQs and Problem Statements. However, those functionalities have not been coverd by the server test so far. I made sure to add the tests now.

@FelixTJDietrich and @wasnertobias introduced a consistency check for programming exercises, i also added some test cases for this pipeline

Description

This PR adds integration test for both, the rewriting and the consistency pipeline

Steps for Testing

Only code review necessary, this add some test cases

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Code Review

  • Code Review 1
  • Code Review 2

Test Coverage

Class/File Line Coverage Confirmation (assert/expect)
IrisRewritingRessource.java 100%
IrisRewritingService.java 100%
IrisConsistencyCheckResource.java 100%
IrisConsistencyCheckService.java 100%

Summary by CodeRabbit

  • New Features

    • Added new integration tests for the Pyris rewriting pipeline, including access control checks for different user roles.
    • Introduced a utility to provide mock LLM cost data for testing purposes.
  • Refactor

    • Updated method names and parameters in test mocks for improved clarity.
    • Replaced a private helper in tests with a shared utility function for generating mock LLM cost data.

@cremertim cremertim requested review from a team and krusche as code owners May 27, 2025 20:32
@github-project-automation github-project-automation bot moved this to Work In Progress in Artemis Development May 27, 2025
@github-actions github-actions bot added tests core Pull requests that affect the corresponding module iris Pull requests that affect the corresponding module labels May 27, 2025
@cremertim cremertim added ready for review and removed tests core Pull requests that affect the corresponding module iris Pull requests that affect the corresponding module labels May 27, 2025
@cremertim cremertim changed the title IRIS: Add test for rewriting pipeline Iris: Add test for rewriting pipeline May 27, 2025
Copy link
Contributor

coderabbitai bot commented May 27, 2025

Walkthrough

New integration tests for the Pyris rewriting pipeline and consistency check were added, verifying functionality and role-based access control. A utility class for mock LLM cost data was introduced and used to replace a local helper method. A mock provider method was renamed and its endpoint updated, and a new mock method for consistency check responses was added.

Changes

File(s) Change Summary
src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingIntegrationTest.java Added new integration test class for the Pyris rewriting pipeline with tests for authorized and unauthorized access.
src/test/java/de/tum/cit/aet/artemis/iris/PyrisConcistencyCheckIntegrationTest.java Added new integration test class for Pyris programming exercise consistency check, including role-based access tests.
src/test/java/de/tum/cit/aet/artemis/iris/utils/IrisLLMMock.java Added new utility class with static method to generate mock LLM cost data.
src/test/java/de/tum/cit/aet/artemis/iris/IrisChatTokenTrackingIntegrationTest.java Removed local mock LLM costs method and replaced with import from new utility class.
src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java Renamed mock response method, updated endpoint and parameter names; added new mock method for programming consistency check.

Sequence Diagram(s)

sequenceDiagram
    participant Instructor
    participant TestClient
    participant IrisRequestMockProvider
    participant Websocket

    Instructor->>TestClient: Send rewriting request (text, variant)
    TestClient->>IrisRequestMockProvider: Mock rewriting pipeline response
    IrisRequestMockProvider-->>TestClient: Return mocked response
    TestClient->>Websocket: Send intermediate stage message (no result)
    TestClient->>Websocket: Send final stage message (with result)
    Websocket-->>Instructor: Deliver messages
Loading
sequenceDiagram
    participant Instructor
    participant TestClient
    participant IrisRequestMockProvider
    participant IrisConsistencyCheckService
    participant Websocket

    Instructor->>TestClient: Send consistency check request
    TestClient->>IrisRequestMockProvider: Mock consistency check response
    IrisRequestMockProvider-->>TestClient: Return HTTP 202 Accepted
    IrisConsistencyCheckService->>Websocket: Send staged status updates
    Websocket-->>Instructor: Deliver consistency check messages
Loading

Suggested labels

tests, server, iris, core

Suggested reviewers

  • krusche
  • FelixTJDietrich
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingIntegrationTest.java (1)

89-98: Good access control test but consider enhancing verification.

The test properly verifies that students cannot access the rewriting pipeline. However, the mock setup with an empty consumer doesn't add value since the request should be blocked before reaching the pipeline.

Consider removing the unnecessary mock setup since the request should be forbidden at the controller level:

-    irisRequestMockProvider.mockRewritingPipelineResponse(dto -> {
-    });
src/test/java/de/tum/cit/aet/artemis/iris/utils/IrisLLMMock.java (1)

12-14: Consider extracting magic numbers as constants for better maintainability.

While the current implementation works well, extracting the magic numbers would improve readability and maintainability.

Consider extracting constants for better clarity:

+    private static final int MOCK_DATA_COUNT = 5;
+    private static final String MOCK_MODEL_NAME = "test-llm";
+    private static final String MOCK_PIPELINE_ID = "IRIS_CHAT_EXERCISE_MESSAGE";
+
     public static List<LLMRequest> getMockLLMCosts() {
         List<LLMRequest> costs = new ArrayList<>();
-        for (int i = 0; i < 5; i++) {
-            costs.add(new LLMRequest("test-llm", i * 10 + 5, i * 0.5f, i * 3 + 5, i * 0.12f, "IRIS_CHAT_EXERCISE_MESSAGE"));
+        for (int i = 0; i < MOCK_DATA_COUNT; i++) {
+            costs.add(new LLMRequest(MOCK_MODEL_NAME, i * 10 + 5, i * 0.5f, i * 3 + 5, i * 0.12f, MOCK_PIPELINE_ID));
         }
         return costs;
     }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dce69c0 and 7251a29.

📒 Files selected for processing (4)
  • src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/iris/IrisChatTokenTrackingIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/iris/utils/IrisLLMMock.java (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`src/test/java/**/*.java`: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_...

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

  • src/test/java/de/tum/cit/aet/artemis/iris/IrisChatTokenTrackingIntegrationTest.java
  • src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java
  • src/test/java/de/tum/cit/aet/artemis/iris/utils/IrisLLMMock.java
  • src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingIntegrationTest.java
🧬 Code Graph Analysis (2)
src/test/java/de/tum/cit/aet/artemis/iris/IrisChatTokenTrackingIntegrationTest.java (1)
src/test/java/de/tum/cit/aet/artemis/iris/utils/IrisLLMMock.java (1)
  • IrisLLMMock (8-17)
src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingIntegrationTest.java (3)
src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java (1)
  • Constants (8-498)
src/main/webapp/app/app.constants.ts (1)
  • PROFILE_IRIS (52-52)
src/test/java/de/tum/cit/aet/artemis/iris/utils/IrisLLMMock.java (1)
  • IrisLLMMock (8-17)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Build and Push Docker Image / Build Docker Image for ls1intum/artemis
  • GitHub Check: Build and Push Docker Image / Build Docker Image for ls1intum/artemis
  • GitHub Check: Build .war artifact
  • GitHub Check: client-style
  • GitHub Check: client-tests
  • GitHub Check: server-style
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (5)
src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java (1)

200-212: LGTM! Improved method naming and endpoint consistency.

The refactoring improves the method name to be more descriptive and follows the naming pattern of other mock methods in the class. The parameter name change from executionDTOConsumer to responseConsumer is more concise and clear. The endpoint simplification from /rewriting/faq/run to /rewriting/run appears to align with API changes.

src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingIntegrationTest.java (2)

31-53: Well-structured test class setup with proper naming and initialization.

The test class follows excellent practices:

  • Descriptive class name and test prefix
  • Proper Spring profile configuration
  • Clean setup with course and users initialization
  • Iris activation for testing context

55-87: Comprehensive integration test with proper websocket verification.

The test method effectively validates:

  • Mock pipeline response with input verification
  • Proper HTTP status handling
  • Websocket message sequence verification using ArgumentCaptor
  • Stage progression and result validation

The test follows the coding guidelines with descriptive naming and proper assertThat usage.

src/test/java/de/tum/cit/aet/artemis/iris/IrisChatTokenTrackingIntegrationTest.java (1)

3-3: Excellent refactoring to centralize mock data generation.

The import of the static getMockLLMCosts() method from the new utility class improves code organization by following the DRY principle. This centralizes the mock LLM cost data generation for reuse across multiple test classes.

src/test/java/de/tum/cit/aet/artemis/iris/utils/IrisLLMMock.java (1)

8-17: Well-designed utility class following good practices.

The utility class design is excellent:

  • Final class prevents inheritance
  • Static method for utility functionality
  • Descriptive method name
  • Consistent mock data generation

The deterministic parameter calculations ensure reproducible test results, which is important for reliable testing.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 27, 2025
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report201 ran197 passed3 skipped1 failed57m 27s 767ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts
ts.Static code analysis tests › Configures SCA grading and makes a successful submission with SCA errors❌ failure1m 49s 790ms

@cremertim cremertim changed the title Iris: Add test for rewriting pipeline Iris: Add test for rewriting and consistency pipeline May 27, 2025
@github-actions github-actions bot added tests core Pull requests that affect the corresponding module iris Pull requests that affect the corresponding module labels May 27, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7251a29 and 0c97b08.

📒 Files selected for processing (3)
  • src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java (2 hunks)
  • src/test/java/de/tum/cit/aet/artemis/iris/PyrisConcistencyCheckIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingIntegrationTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingIntegrationTest.java
🧰 Additional context used
📓 Path-based instructions (1)
`src/test/java/**/*.java`: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_...

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

  • src/test/java/de/tum/cit/aet/artemis/iris/PyrisConcistencyCheckIntegrationTest.java
  • src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java
🧠 Learnings (1)
src/test/java/de/tum/cit/aet/artemis/iris/PyrisConcistencyCheckIntegrationTest.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`.
🧬 Code Graph Analysis (1)
src/test/java/de/tum/cit/aet/artemis/iris/PyrisConcistencyCheckIntegrationTest.java (4)
src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java (1)
  • Constants (8-498)
src/main/webapp/app/app.constants.ts (1)
  • PROFILE_IRIS (52-52)
src/test/java/de/tum/cit/aet/artemis/iris/utils/IrisLLMMock.java (1)
  • IrisLLMMock (8-17)
src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingIntegrationTest.java (1)
  • Profile (31-98)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Build and Push Docker Image / Build Docker Image for ls1intum/artemis
  • GitHub Check: Build and Push Docker Image / Build Docker Image for ls1intum/artemis
  • GitHub Check: Build .war artifact
  • GitHub Check: server-tests
  • GitHub Check: client-style
  • GitHub Check: client-tests
  • GitHub Check: server-style
  • GitHub Check: Analyse
🔇 Additional comments (8)
src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java (3)

41-41: LGTM!

Import addition is necessary for the new consistency check mock method.


201-213: LGTM!

The method rename from mockRunRewritingResponseAnd to mockRewritingPipelineResponse improves naming consistency and the parameter name change enhances clarity. The implementation follows the established pattern.


215-223: LGTM!

The new mockProgrammingConsistencyCheckResponse method follows the same pattern as other mock methods in this class. The endpoint URL /inconsistency-check/run and HTTP 202 response are appropriate for the consistency check pipeline.

src/test/java/de/tum/cit/aet/artemis/iris/PyrisConcistencyCheckIntegrationTest.java (5)

4-4: LGTM!

Good use of the utility class IrisLLMMock.getMockLLMCosts() to provide mock LLM cost data for testing.


56-66: LGTM!

The test setup properly creates users with different roles, sets up a programming exercise, and activates Iris for the course. This follows the established pattern from other integration tests and adheres to the coding guidelines.


68-105: LGTM!

Comprehensive integration test that verifies:

  • Instructor role access and permissions
  • DTO conversion and request payload validation
  • Websocket messaging with staged updates
  • Proper handling of status updates including intermediate and final results

The test follows best practices with proper mocking, assertions, and timeout handling.


107-125: LGTM!

Proper role-based access control tests ensuring that students and tutors receive forbidden (403) responses when attempting to trigger consistency checks. This enforces the security requirements correctly.


127-132: LGTM!

The helper method creates appropriate test data with hardcoded values which is suitable for integration testing. The DTO includes all necessary fields for comprehensive testing.

@github-project-automation github-project-automation bot moved this from Work In Progress to Ready For Review in Artemis Development May 27, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes May 27, 2025
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ✅Skipped ⚠️FailedTime ⏱
End-to-End (E2E) Test Report201 ran198 passed3 skipped0 failed59m 47s 202ms
TestResultTime ⏱
No test annotations available

@cremertim cremertim changed the title Iris: Add test for rewriting and consistency pipeline Iris: Add integration test for rewriting and consistency pipeline May 28, 2025
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report201 ran197 passed3 skipped1 failed56m 20s 538ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts
ts.Static code analysis tests › Configures SCA grading and makes a successful submission with SCA errors❌ failure1m 47s 898ms

eylulnc
eylulnc previously approved these changes May 30, 2025
Copy link
Contributor

@eylulnc eylulnc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code

Copy link

github-actions bot commented Jun 1, 2025

End-to-End (E2E) Test Results Summary

TestsPassed ✅Skipped ⚠️FailedTime ⏱
End-to-End (E2E) Test Report201 ran198 passed3 skipped0 failed55m 36s 737ms
TestResultTime ⏱
No test annotations available

Copy link
Contributor

@florian-glombik florian-glombik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code unfortunately is partly duplicated and was very hard to understand for me.

I think with a few changes we can improve the readability and maintainability for future adjustments.

Copy link
Contributor

@tobias-lippert tobias-lippert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comments and I agree with all change requests from @florian-glombik

@cremertim cremertim dismissed stale reviews from eylulnc and coderabbitai[bot] via 3300d7a June 2, 2025 20:12
Copy link

github-actions bot commented Jun 2, 2025

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report201 ran197 passed3 skipped1 failed58m 3s 769ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts
ts.Static code analysis tests › Configures SCA grading and makes a successful submission with SCA errors❌ failure2m 19s 802ms

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 3, 2025
Copy link

github-actions bot commented Jun 3, 2025

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report201 ran197 passed3 skipped1 failed59m 31s 578ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts
ts.Static code analysis tests › Configures SCA grading and makes a successful submission with SCA errors❌ failure2m 16s 644ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Pull requests that affect the corresponding module iris Pull requests that affect the corresponding module ready for review tests
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

4 participants