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

Improve the test results for Integrations internals #2376

Merged

Conversation

Swiddis
Copy link
Collaborator

@Swiddis Swiddis commented Mar 5, 2025

Description

I was debugging some tests locally and it stood out that the errors aren't that useful: most of them are result.ok assertions of the form "Expected true but got false." This is inactionable without custom debugging logic (usually well-placed console.logs). I've added some result helpers that can check results with context, and show the specific errors on failure. Failures should be actionable.

After implementing, I tried introducing some random errors in our integration configs and parsing logic, and verified that the failures made sense.

Issues Resolved

N/A

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Collaborator Author

@Swiddis Swiddis Mar 5, 2025

Choose a reason for hiding this comment

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

note: Another option is to extend expect directly

This saves having to tweak the lint config, but I felt the interface was too complicated. We ultimately don't need anything too sophisticated here.

describe('Local Nginx Integration', () => {
it('Should serialize without errors', async () => {
const integration = await repository.getIntegration('nginx');

await expect(integration?.serialize()).resolves.toHaveProperty('ok', true);
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

@Swiddis Swiddis Mar 5, 2025

Choose a reason for hiding this comment

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

That file is also related by virtue of it being the same sort of result validation. We could use the same helpers there as well if we touch the file again. I didn't migrate everything since there's probably a lot of migration to do and the exact syntax for how I checked it in different places isn't consistent (which goes to show the necessity for a standard form...)

@Swiddis Swiddis merged commit cd70e05 into opensearch-project:main Mar 5, 2025
20 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/dashboards-observability/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/dashboards-observability/backport-2.x
# Create a new branch
git switch --create backport/backport-2376-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 cd70e059a6d1616fe7bbe8dc2cc1157e59394deb
# Push it to GitHub
git push --set-upstream origin backport/backport-2376-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/dashboards-observability/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-2376-to-2.x.

Swiddis added a commit to Swiddis/dashboards-observability that referenced this pull request Mar 5, 2025
…ct#2376)

* Add custom expect handlers for integration results

Signed-off-by: Simeon Widdis <[email protected]>

* Add context to integrationReader errors

Signed-off-by: Simeon Widdis <[email protected]>

* Use FileParams type where applicable

Signed-off-by: Simeon Widdis <[email protected]>

* Assert serialized integrations works as part of usage

Signed-off-by: Simeon Widdis <[email protected]>

---------

Signed-off-by: Simeon Widdis <[email protected]>
Swiddis added a commit to Swiddis/dashboards-observability that referenced this pull request Mar 5, 2025
…ct#2376)

* Add custom expect handlers for integration results

Signed-off-by: Simeon Widdis <[email protected]>

* Add context to integrationReader errors

Signed-off-by: Simeon Widdis <[email protected]>

* Use FileParams type where applicable

Signed-off-by: Simeon Widdis <[email protected]>

* Assert serialized integrations works as part of usage

Signed-off-by: Simeon Widdis <[email protected]>

---------

Signed-off-by: Simeon Widdis <[email protected]>
Swiddis added a commit that referenced this pull request Mar 6, 2025
* Add custom expect handlers for integration results



* Add context to integrationReader errors



* Use FileParams type where applicable



* Assert serialized integrations works as part of usage



---------

Signed-off-by: Simeon Widdis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants