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

refactoring registration and provider service to make it resilient for conflict errors #200

Merged
merged 4 commits into from
Jan 12, 2024

Conversation

abhupadh
Copy link
Collaborator

@abhupadh abhupadh commented Jan 5, 2024

Description

See issue description

Related Issue

#199
https://jira.corp.adobe.com/browse/CI-6365

Motivation and Context

Make our e2e more resilient

How Has This Been Tested?

Using aio-events-itests running locally

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

Copy link
Collaborator

@francoisledroff francoisledroff left a comment

Choose a reason for hiding this comment

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

cool, thanks for the PR, it looks good to me
as you are at it, could you also add the same use of the x-conflicting-id header in ProviderService.createOrUpdateProvider(..) ?

@abhupadh
Copy link
Collaborator Author

abhupadh commented Jan 9, 2024

@francoisledroff : please approve

Copy link
Collaborator

@francoisledroff francoisledroff left a comment

Choose a reason for hiding this comment

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

a few small requests:

return updateProvider(providerId,providerInputModel);
} catch (ConflictException e){
String conflictingProviderId = e.getConflictingId();
logger.warn("Another provider (id: `{}` ) exist with conflict due to {}, trying to update it ...",
Copy link
Collaborator

Choose a reason for hiding this comment

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

logger.info would be enough, don't you think ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

return createRegistration(registrationCreateModelBuilder);
} catch (ConflictException ex) {
String conflictingRegistrationId = ex.getConflictingId();
logger.warn("Another registration (id `{}`) exists with conflict due to {}. Trying to update it...", conflictingRegistrationId, ex.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

logger.info would be enough, don't you think ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

@@ -51,7 +51,7 @@ public void createGetDeleteJournalRegistration() {
try {
providerId = providerServiceTester.createOrUpdateProvider(TEST_EVENT_PROVIDER_LABEL,
TEST_EVENT_CODE).getId();
Registration registration = createJournalRegistration(TEST_REGISTRATION_NAME, providerId,
Registration registration = createOrUpdateJournalRegistration(TEST_REGISTRATION_NAME, providerId,
Copy link
Collaborator

Choose a reason for hiding this comment

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

may be we could test both path ?
using createOrUpdate once and then createOrUpdate again ... once created
here and may be in ProviderServiceIntegrationTest too
wdyt ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't get this

Copy link
Collaborator Author

@abhupadh abhupadh Jan 11, 2024

Choose a reason for hiding this comment

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

…d update flows without any conflict eexception
@abhupadh
Copy link
Collaborator Author

@francoisledroff : how can we retrigger the integration test? Locally it is getting passed.

Copy link
Collaborator

@francoisledroff francoisledroff left a comment

Choose a reason for hiding this comment

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

one small request:

() -> registrationService.findById(finalRegistrationId));

// covering the update path
registration = createOrUpdateJournalRegistration(TEST_REGISTRATION_NAME, providerId,
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you add the same coverage for the ProviderService pretty please ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well,I have done this here in the ProviderServiceIntegrationTest, is there any other place I need to do that you meant?

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh I did not catch this, thanks !

String updatedProviderDescription = "updated Provider Description";
Optional<Provider> updatedProvider = providerService.updateProvider(providerId,
getTestProviderInputModelBuilder(TEST_EVENT_PROVIDER_LABEL)
Provider updatedProvider = createOrUpdateProvider(getTestProviderInputModelBuilder(TEST_EVENT_PROVIDER_LABEL)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

here

@abhupadh abhupadh merged commit a46275a into main Jan 12, 2024
5 checks passed
@abhupadh abhupadh changed the title refactoring registration service to make it resilient for conflict errors refactoring registration and provider service to make it resilient for conflict errors Jan 12, 2024
@francoisledroff francoisledroff deleted the CI-6365 branch January 18, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants