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

Don't skip last index during iteration. #18996

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

voyvodov
Copy link

@voyvodov voyvodov commented Nov 6, 2024

Last empty element is removed on line 358 in get_info func

What does this PR do?

Fixing #18995

Motivation

We're missing information for the last index in every namespace

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Copy link

codecov bot commented Nov 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.46%. Comparing base (c370c7b) to head (14b2d11).
Report is 17 commits behind head on master.

Additional details and impacted files
Flag Coverage Δ
activemq ?
aerospike 88.81% <100.00%> (+1.79%) ⬆️
cassandra ?
hive ?
hivemq ?
hudi ?
ignite ?
jboss_wildfly ?
kafka ?
presto ?
solr ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Last empty element is removed on line 358 in `get_info` func
@voyvodov voyvodov force-pushed the master branch 8 times, most recently from 0655e3c to 88ad789 Compare November 11, 2024 07:18
@iliakur
Copy link
Contributor

iliakur commented Nov 12, 2024

@voyvodov thanks for your contribution!

Could you please add a unit test for it? lmk if I can help with that.

@iliakur iliakur self-assigned this Nov 12, 2024
@voyvodov
Copy link
Author

@voyvodov thanks for your contribution!

Could you please add a unit test for it? lmk if I can help with that.

Thanks @iliakur ! If you can help with the unit tests that will be great.

I'm trying to at least add indexes to the e2e tests, but if we can do it in unit too, that will be great.
I've some draft unit tests, but that requires to move sindex metrics collection in separate func, e.g.

def collect_sindex(self, namespaces, namespace_tags):
    for ns in namespaces:
         # https://www.aerospike.com/docs/reference/info/#sindex
        sindex = self.get_info('sindex/{}'.format(ns))
        for idx in parse_namespace(sindex, ns, 'indexname'):
            sindex_tags = ['sindex:{}'.format(idx)]
            sindex_tags.extend(namespace_tags)
            self.collect_info('sindex/{}/{}'.format(ns, idx), SINDEX_METRIC_TYPE, tags=sindex_tags)

@voyvodov voyvodov force-pushed the master branch 2 times, most recently from d2cdc1e to 194c9e5 Compare November 13, 2024 13:51
@voyvodov
Copy link
Author

@iliakur I think I found a way to do it correctly, without touching base code.

Can you check?

Copy link
Contributor

@iliakur iliakur left a comment

Choose a reason for hiding this comment

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

Thanks for this!

Left a few suggestions to clean things up, otherwise lgtm!!

return common.MOCK_INDEXES_METRICS
elif command.startswith("sets/"):
return []
print(f'got {command}')
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
print(f'got {command}')

"ns=test:indexname=idx_characters_name:set=characters:bin=name:type=string:indextype=default:context=null:state=RW"
]
elif command == "sindex/test/idx_characters_name":
print(f"got get index info. Returning {common.MOCK_INDEXES_METRICS}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
print(f"got get index info. Returning {common.MOCK_INDEXES_METRICS}")

check._tags = []
check._client = mock.MagicMock()
check._client.get_node_names = mock.MagicMock(
side_effect=lambda: [{'address': common.HOST, 'port': common.PORT, 'node_name': 'test'}]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
side_effect=lambda: [{'address': common.HOST, 'port': common.PORT, 'node_name': 'test'}]
return_value={'address': common.HOST, 'port': common.PORT, 'node_name': 'test'}

side_effect=lambda: [{'address': common.HOST, 'port': common.PORT, 'node_name': 'test'}]
)
check.get_namespaces = mock.MagicMock(return_value=['test'])
# check.collect_info = mock.MagicMock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# check.collect_info = mock.MagicMock()

@voyvodov
Copy link
Author

Thanks for this!

Left a few suggestions to clean things up, otherwise lgtm!!

Oh my....Didn't notice that I commit all the "debug" prints there 🤦🏽 .

Sorry, all fixed.

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.

2 participants