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

[backend/frontend] Restarting an atomic testing keeps the same Inject UUID #1901

Merged
merged 7 commits into from
Nov 29, 2024

Conversation

isselparra
Copy link
Contributor

@isselparra isselparra commented Nov 21, 2024

Proposed changes

  • Handle the relaunch of an Atomic Testing

API changes:

  • Atomic testing duplication route
    Before: @PostMapping("/{atomicTestingId}")
    After: @PostMapping("/{atomicTestingId}/duplicate")

  • Atomic testing launching route
    Before: @GetMapping("/try/{injectId}")
    After: @PostMapping("/{atomicTestingId}/launch")

  • Atomic testing relaunching route (new)
    @PostMapping("/{atomicTestingId}/relaunch")

  • Inject launching (deleted)
    Not used in the app
    @GetMapping("/api/injects/try/{injectId}")

Refactor:
Change InjectDuplicateService to reduce the number of db calls

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@github-actions github-actions bot added the filigran team use to identify PR from the Filigran team label Nov 21, 2024
@isselparra isselparra force-pushed the issue/1847 branch 2 times, most recently from e4a1047 to cb41d05 Compare November 21, 2024 09:56
Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 76.34409% with 22 lines in your changes missing coverage. Please review.

Project coverage is 34.10%. Comparing base (a20d4d6) to head (36a7099).
Report is 1 commits behind head on release/1.10.0.

Files with missing lines Patch % Lines
...as/rest/inject/service/InjectDuplicateService.java 34.61% 17 Missing ⚠️
...pi/src/main/java/io/openbas/utils/InjectUtils.java 89.28% 2 Missing and 1 partial ⚠️
...rc/main/java/io/openbas/rest/inject/InjectApi.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##             release/1.10.0    #1901      +/-   ##
====================================================
+ Coverage             33.62%   34.10%   +0.48%     
- Complexity             1671     1700      +29     
====================================================
  Files                   572      572              
  Lines                 16697    16718      +21     
  Branches                970      969       -1     
====================================================
+ Hits                   5614     5702      +88     
+ Misses                10829    10756      -73     
- Partials                254      260       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@isselparra isselparra force-pushed the issue/1847 branch 6 times, most recently from f7e1608 to 2db9515 Compare November 25, 2024 06:50
@isselparra isselparra marked this pull request as ready for review November 25, 2024 07:03
public InjectResultOverviewOutput launchAtomicTesting(
@PathVariable @NotBlank final String atomicTestingId) {
return atomicTestingService.launch(atomicTestingId);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The API routes are much clearer now, thank you!

@MarineLeM
Copy link
Contributor

@isselparra When I try to relaunch an atomic test, I consistently encounter a 500 error. It seems like there might be an issue on the backend.

@antoinemzs antoinemzs self-requested a review November 26, 2024 09:27
Comment on lines 105 to 146
@Transactional
public InjectResultOverviewOutput duplicate(String id) {
Inject injectOrigin = injectRepository.findById(id).orElseThrow(ElementNotFoundException::new);
Inject duplicatedInject = InjectUtils.duplicateInject(injectOrigin);
duplicatedInject.setTitle(duplicateString(duplicatedInject.getTitle()));
Inject savedInject = injectRepository.save(duplicatedInject);
return injectMapper.toInjectResultOverviewOutput(savedInject);
}

@Transactional
public InjectResultOverviewOutput launch(String id) {
Inject inject = injectRepository.findById(id).orElseThrow(ElementNotFoundException::new);
inject.clean();
inject.setUpdatedAt(Instant.now());

InjectStatus injectStatus = setInjectStatusAsQueuing(inject);
inject.setStatus(injectStatus);

return injectMapper.toInjectResultOverviewOutput(injectRepository.save(inject));
}

@Transactional
public InjectResultOverviewOutput relaunch(String id) {
Inject injectOrigin = injectRepository.findById(id).orElseThrow(ElementNotFoundException::new);
Inject duplicatedInject = InjectUtils.duplicateInject(injectOrigin);

Inject savedInject = injectRepository.save(duplicatedInject);

InjectStatus injectStatus = setInjectStatusAsQueuing(savedInject);
savedInject.setStatus(injectStatus);

injectDocumentRepository.deleteDocumentsFromInject(id);
injectRepository.deleteById(id);

return injectMapper.toInjectResultOverviewOutput(injectRepository.save(savedInject));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: we should avoid duplicating too much code, perhaps we could encapsulate some behaviour

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mutualise as much as possible some behaviors
Let me know if you have any other suggestions

@isselparra
Copy link
Contributor Author

@MarineLeM I fixed the problem you were having with the relaunch of an Inject
Let me know if it works on your side or if you detect any other issues
Thanks!

@isselparra isselparra self-assigned this Nov 26, 2024
@isselparra isselparra requested a review from MarineLeM November 27, 2024 14:42
@isselparra isselparra changed the base branch from master to release/1.10.0 November 29, 2024 08:36
@isselparra isselparra merged commit 4273a9d into release/1.10.0 Nov 29, 2024
7 checks passed
@isselparra isselparra deleted the issue/1847 branch December 12, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filigran team use to identify PR from the Filigran team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restarting an atomic testing keeps the same Inject UUID
3 participants