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

Fix Azure data explorer #119089

Merged
merged 9 commits into from
Jun 11, 2024
Merged

Fix Azure data explorer #119089

merged 9 commits into from
Jun 11, 2024

Conversation

kaareseras
Copy link
Contributor

@kaareseras kaareseras commented Jun 7, 2024

Breaking change

Proposed change

Change the strings file to give a better explanation of what to insert
Add back the difference between the -ingest and non -ingest URI

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

Refactor the initialization of the Azure Data Explorer client to separate the creation of the ingest and query clients. Thisremoves the bug where the wrong URL was used when either testing for connectivity or inserting data
Copy link
Contributor

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Please fix the merge conflict and describe your changes in the PR description

@home-assistant
Copy link

home-assistant bot commented Jun 7, 2024

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft June 7, 2024 14:47
@i-am-shodan
Copy link
Contributor

image

Looks like I'm getting a filtering error, I have no filters

@kaareseras
Copy link
Contributor Author

kaareseras commented Jun 7, 2024 via email

@kaareseras kaareseras marked this pull request as ready for review June 7, 2024 20:06
@home-assistant home-assistant bot requested a review from edenhaus June 7, 2024 20:06
@MartinHjelmare MartinHjelmare changed the title Adx bug Fix Azure data explorer Jun 8, 2024
Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

No clue if this change is the right one, but have a review on the strings and some comments

homeassistant/components/azure_data_explorer/strings.json Outdated Show resolved Hide resolved
homeassistant/components/azure_data_explorer/strings.json Outdated Show resolved Hide resolved
homeassistant/components/azure_data_explorer/strings.json Outdated Show resolved Hide resolved
homeassistant/components/azure_data_explorer/strings.json Outdated Show resolved Hide resolved
homeassistant/components/azure_data_explorer/client.py Outdated Show resolved Hide resolved
homeassistant/components/azure_data_explorer/client.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft June 8, 2024 08:34
@kaareseras kaareseras marked this pull request as ready for review June 8, 2024 10:49
@home-assistant home-assistant bot requested a review from joostlek June 8, 2024 10:49
@joostlek joostlek added this to the 2024.6.2 milestone Jun 8, 2024
@kaareseras

This comment was marked as abuse.

@i-am-shodan

This comment was marked as off-topic.

@kaareseras

This comment was marked as abuse.

Comment on lines 68 to 70
if DOMAIN not in yaml_config:
return True
hass.data[DOMAIN][DATA_FILTER] = yaml_config[DOMAIN].pop(CONF_FILTER)
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
if DOMAIN not in yaml_config:
return True
hass.data[DOMAIN][DATA_FILTER] = yaml_config[DOMAIN].pop(CONF_FILTER)
if DOMAIN in yaml_config:
hass.data[DOMAIN][DATA_FILTER] = yaml_config[DOMAIN].pop(CONF_FILTER)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Im not sure why, but this change will cause many test to fail

FAILED tests/components/azure_data_explorer/test_init.py::test_connection[Exception] - AssertionError: assert <ConfigEntryState.NOT_LOADED: 'not_loaded'> == <ConfigEntryState.SETUP_ERROR: 'setup_error'>

  • where <ConfigEntryState.NOT_LOADED: 'not_loaded'> = .state
  • and <ConfigEntryState.SETUP_ERROR: 'setup_error'> = ConfigEntryState.SETUP_ERROR

Copy link
Contributor

Choose a reason for hiding this comment

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

The tests are running successfully on my machine with the above change. Can you please recheck?

ha-venv@edenhaus ➜ /workspaces/core (pr/kaareseras/119089) $ pytest tests/components/azure_data_explorer
Test session starts (platform: linux, Python 3.12.3, pytest 8.2.0, pytest-sugar 1.0.0)
rootdir: /workspaces/core
configfile: pyproject.toml
plugins: mock-3.14.0, rerunfailures-14.0, typeguard-4.2.1, aiohttp-1.0.5, picked-0.5.0, requests-mock-1.12.1, respx-0.21.1, cov-5.0.0, sugar-1.0.0, timeout-2.3.1, socket-0.7.0, unordered-0.6.0, github-actions-annotate-failures-0.2.0, syrupy-4.6.1, xdist-3.6.1, asyncio-0.23.6, pytest_freezer-0.4.8, anyio-4.3.0
asyncio: mode=Mode.AUTO
collected 19 items                                                                                                                                          

 tests/components/azure_data_explorer/test_config_flow.py ✓✓✓                                                                                  16% █▋        
 tests/components/azure_data_explorer/test_init.py ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓                                                                           100% ██████████

Results (1.12s):
      19 passed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing :-)

Results (3.27s):
11 passed
8 failed
- tests/components/azure_data_explorer/test_config_flow.py:15 test_config_flow
- tests/components/azure_data_explorer/test_init.py:153 test_filter[allowlist]
- tests/components/azure_data_explorer/test_init.py:153 test_filter[denylist]
- tests/components/azure_data_explorer/test_init.py:153 test_filter[filtered_allowlist]
- tests/components/azure_data_explorer/test_init.py:153 test_filter[filtered_denylist]
- tests/components/azure_data_explorer/test_init.py:268 test_connection[KustoServiceError]
- tests/components/azure_data_explorer/test_init.py:268 test_connection[KustoAuthenticationError]
- tests/components/azure_data_explorer/test_init.py:268 test_connection[Exception]

and when debugging the code, I get this error:

2024-06-10 16:45:40.022 ERROR (MainThread) [homeassistant.setup] Error during setup of component azure_data_explorer
Traceback (most recent call last):
File "/workspaces/core/homeassistant/setup.py", line 404, in _async_setup_component
result = await task
^^^^^^^^^^
File "/workspaces/core/homeassistant/components/azure_data_explorer/init.py", line 69, in async_setup
hass.data[DOMAIN][DATA_FILTER] = yaml_config[DOMAIN].pop(CONF_FILTER)
~~~~~~~~~~~^^^^^^^^
KeyError: 'azure_data_explorer'

And the integration does not load

Copy link
Contributor

Choose a reason for hiding this comment

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

There is something wrong with your dev environment. Can you please check that your are using the latest version of all requirements

homeassistant/components/azure_data_explorer/strings.json Outdated Show resolved Hide resolved
homeassistant/components/azure_data_explorer/strings.json Outdated Show resolved Hide resolved
homeassistant/components/azure_data_explorer/client.py Outdated Show resolved Hide resolved
homeassistant/components/azure_data_explorer/client.py Outdated Show resolved Hide resolved
homeassistant/components/azure_data_explorer/client.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft June 10, 2024 13:12
@edenhaus
Copy link
Contributor

@joostlek, @edenhaus can you please have a look, so I can get this fix out asap.

Kindly

Please don't ping members for review. The bot will notify us when the PR is ready for review. You can see on the milestone that the next patch release is scheduled for 14. June

@kaareseras kaareseras marked this pull request as ready for review June 10, 2024 14:02
@home-assistant home-assistant bot requested a review from edenhaus June 10, 2024 14:02
Copy link
Contributor

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Thanks @kaareseras 👍

@edenhaus edenhaus merged commit 511547c into home-assistant:dev Jun 11, 2024
24 checks passed
frenck pushed a commit that referenced this pull request Jun 11, 2024
@frenck frenck mentioned this pull request Jun 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2024
@kaareseras kaareseras deleted the adx-bug branch June 17, 2024 06:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants