Skip to content

chore: Flaky test in AuthenticationServiceTest#35538

Merged
abhvsn merged 1 commit intoreleasefrom
fix-flaky-auth-service-test
Aug 8, 2024
Merged

chore: Flaky test in AuthenticationServiceTest#35538
abhvsn merged 1 commit intoreleasefrom
fix-flaky-auth-service-test

Conversation

@abhvsn
Copy link
Contributor

@abhvsn abhvsn commented Aug 8, 2024

Description

  • Flaky testcase: AuthenticationServiceTest.testGetAuthorizationCodeURL_missingDatasource
  • Reason: Hot publisher newPageMono was getting executed before the datasourceMonoCached can complete the execution.
  • Fix: With this PR we are making sure newPageMono get's called only after the execution of datasourceMono is completed.

/test sanity

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10298256036
Commit: 16f3efb
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Thu, 08 Aug 2024 08:20:46 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • Improvements
    • Enhanced clarity in the authorization code URL generation process for OAuth2, resulting in better maintainability and readability.
    • Explicit handling of data sources to improve the logic flow associated with OAuth2 validation.

@abhvsn abhvsn requested a review from NilanshBansal August 8, 2024 08:01
@abhvsn abhvsn added the ok-to-test Required label for CI label Aug 8, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 8, 2024

Walkthrough

The recent changes in the AuthenticationServiceCEImpl class enhance the clarity and maintainability of the getAuthorizationCodeURLForGenericOAuth2 method. By introducing an intermediate lambda function for the datasource validation, the handling of the datasource becomes more explicit. This refactoring maintains the overall logic while improving code readability, making it easier for future developers to understand the flow of data.

Changes

File Change Summary
app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java Refactored getAuthorizationCodeURLForGenericOAuth2 method to use an intermediate lambda for datasource validation, enhancing clarity.

Poem

In the realm of code, a change took flight,
With clarity shining, oh what a sight!
A lambda emerges, neat and precise,
Handling datasources, so nice and concise.
Maintenance is easy, readability's grand,
In the world of Appsmith, we take a stand! ✨


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?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Aug 8, 2024
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fe7ca6b and 16f3efb.

Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java (1 hunks)
Additional comments not posted (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java (1)

143-144: Good use of lambda for clarity.

The introduction of a lambda function to handle validateRequiredFieldsForGenericOAuth2 with the datasource (ds) improves the readability and maintainability of the code. This makes the data flow clearer and easier to follow.

@abhvsn abhvsn enabled auto-merge (squash) August 8, 2024 08:21
@github-actions
Copy link

github-actions bot commented Aug 8, 2024

Failed server tests

  • com.appsmith.server.services.ThemeServiceTest#persistCurrentTheme_WhenCustomThemeIsSet_NewApplicationThemeCreated
  • com.appsmith.server.services.ce.ThemeImportableServiceCETest#importThemesToApplication_WhenBothImportedThemesAreCustom_NewThemesCreated

Comment on lines +143 to +144
.flatMap(ds -> this.validateRequiredFieldsForGenericOAuth2(ds)
.zipWith(Mono.zip(workspaceIdMono, trueEnvironmentIdCached, newPageMono)))
Copy link
Contributor

Choose a reason for hiding this comment

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

How will this change be any different than the execution which is already present.
The mono from .flatMap(this::validateRequiredFieldsForGenericOAuth2) was earlier being zipped with (Mono.zip(workspaceIdMono, trueEnvironmentIdCached, newPageMono)) which would mean that both these Monos will be executing in parallel.

With the new change

.flatMap(ds -> this.validateRequiredFieldsForGenericOAuth2(ds)
    .zipWith(Mono.zip(workspaceIdMono, trueEnvironmentIdCached, newPageMono)))

we are still doing the same thing.

Should we use something like:

.flatMap(this::validateRequiredFieldsForGenericOAuth2)
    .zipWhen(ds -> Mono.zip(workspaceIdMono, trueEnvironmentIdCached, newPageMono))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nsarupr the error is popping up because newPageMono is getting executed alongside of datasourceMonoCached. With the updated change we are making sure Monos will be executed within the flatMap which was not the case earlier.

Earlier:

.flatMap(this::validateRequiredFieldsForGenericOAuth2)
.zipWith(Mono.zip(workspaceIdMono, trueEnvironmentIdCached, newPageMono))

After changes:

.flatMap(ds -> this.validateRequiredFieldsForGenericOAuth2(ds)
    .zipWith(Mono.zip(workspaceIdMono, trueEnvironmentIdCached, newPageMono))
)

Also zipWhen also works but thought, all the zipped entities should be within the same flatMap hence opted for this approach.

This also works:

.flatMap(this::validateRequiredFieldsForGenericOAuth2)
.zipWhen(ds -> Mono.zip(workspaceIdMono, trueEnvironmentIdCached, newPageMono))

Copy link
Contributor

@NilanshBansal NilanshBansal Aug 8, 2024

Choose a reason for hiding this comment

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

@abhvsn should we use zipWhen() for a cleaner code and better readability here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As stated I would not prefer that considering we are not using the returned value in zipWhen.

@abhvsn abhvsn merged commit f0bccc6 into release Aug 8, 2024
@abhvsn abhvsn deleted the fix-flaky-auth-service-test branch August 8, 2024 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants