-
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
Integrated code lifecycle
: Add blackbox tests to LocalCI
#10118
base: develop
Are you sure you want to change the base?
Integrated code lifecycle
: Add blackbox tests to LocalCI
#10118
Conversation
…-code-lifecycle/localci-blackbox
…-code-lifecycle/localci-blackbox
…-code-lifecycle/localci-blackbox # Conflicts: # src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobExecutionService.java
…-code-lifecycle/localci-blackbox
…-code-lifecycle/localci-blackbox
Integrated code lifecycle
: Make blackbox tests work with LocalCIIntegrated code lifecycle
: Add blackbox tests to LocalCI
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.
0c71745
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: 0
♻️ Duplicate comments (1)
src/main/java/de/tum/cit/aet/artemis/buildagent/service/parser/CustomFeedbackParser.java (1)
60-67
:⚠️ Potential issueUse appropriate exception type and consistent message formatting
The use of
InvalidPropertiesFormatException
is not appropriate for this context.- private static void validateCustomFeedback(final String fileName, final CustomFeedback feedback) throws InvalidPropertiesFormatException { + private static void validateCustomFeedback(final String fileName, final CustomFeedback feedback) { if (feedback.name() == null || feedback.name().trim().isEmpty()) { - throw new InvalidPropertiesFormatException(String.format("Custom feedback from file %s needs to have a name attribute.", fileName)); + throw new IllegalArgumentException(String.format("Custom feedback from file %s needs to have a name attribute.", fileName)); } if (!feedback.successful() && feedback.message() == null) { - throw new InvalidPropertiesFormatException(String.format("Custom non-success feedback from file %s needs to have a message", fileName)); + throw new IllegalArgumentException(String.format("Custom non-success feedback from file %s needs to have a message.", fileName)); } }
🧹 Nitpick comments (6)
src/main/java/de/tum/cit/aet/artemis/buildagent/service/parser/CustomFeedbackParser.java (6)
21-21
: Consider making ObjectMapper thread-safeThe static
ObjectMapper
instance should be configured for thread safety since it might be accessed concurrently. Consider usingJsonMapper.builder().build()
or enabling thread-safe features.- private static final ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper mapper = JsonMapper.builder() + .enable(MapperFeature.BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES) + .build();
41-44
: Enhance error handling specificityThe catch block catches all
IOException
instances but only logs them. Consider:
- Catching more specific exceptions (
JsonParseException
,JsonMappingException
)- Propagating the error to the caller for better error handling
- catch (IOException e) { + catch (JsonParseException | JsonMappingException e) { + log.error("Invalid JSON format in custom feedback file {}. {}", fileName, e.getMessage(), e); + throw new IllegalArgumentException("Failed to parse custom feedback file: " + fileName, e); + } + catch (IOException e) { log.error("Error during custom Feedback creation. {}", e.getMessage(), e); - return; + throw new UncheckedIOException("Failed to read custom feedback file: " + fileName, e); }
45-45
: Remove redundant commentThe comment is redundant as the control flow makes it clear that the code below only executes if no exception occurs.
- // Only create TestCase if there was no exception during the custom feedback extraction final TestCase testCase = customFeedbackToTestCase(feedback);
73-73
: Fix incorrect return type documentationThe
@return
documentation mentions returning a "Testsuite" but the method returns aTestCase
.- * @return A Testsuite in the same format as used by JUnit reports + * @return A TestCase in the same format as used by JUnit reports
75-86
: Simplify the conversion logicThe conversion logic can be simplified using a ternary operator and method references.
private static TestCase customFeedbackToTestCase(final CustomFeedback feedback) { - final TestCase testCase; - if (feedback.successful()) { - testCase = new TestCase(feedback.name(), null, null, null, feedback.message()); - } - else { - final Failure failure = new Failure(); - failure.setMessage(feedback.message()); - testCase = new TestCase(feedback.name(), failure, null, null, null); - } - return testCase; + return feedback.successful() + ? new TestCase(feedback.name(), null, null, null, feedback.message()) + : new TestCase(feedback.name(), createFailure(feedback.message()), null, null, null); + } + + private static Failure createFailure(String message) { + final Failure failure = new Failure(); + failure.setMessage(message); + return failure; }
88-99
: Enhance null handling and immutabilityConsider using Optional for cleaner null handling and make variables final where possible.
private static void processTestCase(final TestCase testCase, final List<LocalCITestJobDTO> failedTests, final List<LocalCITestJobDTO> successfulTests) { if (testCase.isSkipped()) { return; } - Failure failure = testCase.extractFailure(); - if (failure != null) { - failedTests.add(new LocalCITestJobDTO(testCase.name(), List.of(failure.extractMessage()))); - } - else { - successfulTests.add(new LocalCITestJobDTO(testCase.name(), List.of(testCase.extractSuccessMessage()))); - } + Optional.ofNullable(testCase.extractFailure()) + .ifPresentOrElse( + failure -> failedTests.add(new LocalCITestJobDTO(testCase.name(), List.of(failure.extractMessage()))), + () -> successfulTests.add(new LocalCITestJobDTO(testCase.name(), List.of(testCase.extractSuccessMessage()))) + ); }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/java/de/tum/cit/aet/artemis/buildagent/service/parser/CustomFeedbackParser.java
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/java/de/tum/cit/aet/artemis/buildagent/service/parser/CustomFeedbackParser.java (1)
Pattern src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: client-style
- GitHub Check: server-style
- GitHub Check: client-tests
- GitHub Check: Build and Push Docker Image
- GitHub Check: server-tests
- GitHub Check: Analyse
- GitHub Check: Build .war artifact
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.
Code 👍
…-code-lifecycle/localci-blackbox # Conflicts: # src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCIProgrammingLanguageFeatureService.java
517dd8d
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.
Checklist
General
Server
Changes affecting Programming Exercises
Motivation and Context
For Java exercises, the DejaGnu project type was previously only available for Jenkins Setups. LocalCI should also support this.
Description
The Aeolus templates for blackbox tests are updated. Aside from that, the Custom Feedback Parser that is part of the Jenkins server notification plugin (https://github.com/ls1intum/jenkins-server-notification-plugin/tree/main/src/main/java/de/tum/in/www1/jenkins/notifications) is included in the Artemis backend.
Since there are now two Parsers, XML and Custom, the records that were previously contained in the XML Parser are now put in a new package, so that both parsers can access them. A message attribute is added to the TestCase Record, because we need to see the results of the DejaGnu test runs.
Specification of the JSON feedback format: https://docs.artemis.cit.tum.de/user/exercises/programming.html#jenkins
Steps for Testing
Prerequisites:
The '(See more)' items should all be expandable and show the whole feedback test.
int blabla = 23;
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
Code Review
Manual Tests
Test Coverage
Screenshots
Summary by CodeRabbit
Release Notes
New Features
MAVEN_BLACKBOX
for Java programming language.CustomFeedback
,TestCase
,TestSuite
, andTestSuites
for enhanced test result representation.Failure
for handling error messages in test results.Improvements
MAVEN_BLACKBOX
.Technical Changes
CustomFeedbackParser
to ensure comprehensive coverage.