You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/11/18 11:24:49 UTC

[GitHub] [superset] villebro opened a new pull request, #22167: fix(alerts): execute query as report executor

villebro opened a new pull request, #22167:
URL: https://github.com/apache/superset/pull/22167

   ### SUMMARY
   This is a continuation of #21931 which made it possible to execute reports as the object owners/creators etc. Unfortunately that PR didn't enable the same functionality for alerts, which were still being executed as the selenium user. This implements the same logic for alerts and adds integration tests to ensure alerts are executed as the correct user.
   
   <!--- Describe the change below, including rationale and design decisions -->
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] dpgaspar commented on a diff in pull request #22167: fix(alerts): execute query as report executor

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on code in PR #22167:
URL: https://github.com/apache/superset/pull/22167#discussion_r1026342463


##########
tests/integration_tests/reports/alert_tests.py:
##########
@@ -15,10 +15,80 @@
 # specific language governing permissions and limitations
 # under the License.
 # pylint: disable=invalid-name, unused-argument, import-outside-toplevel
+from contextlib import nullcontext
+from typing import List, Optional, Union
 
 import pandas as pd
+import pytest
 from pytest_mock import MockFixture
 
+from superset.reports.commands.exceptions import AlertQueryError
+from superset.reports.models import ReportCreationMethod, ReportScheduleType
+from superset.reports.types import ReportScheduleExecutor
+from superset.utils.database import get_example_database
+from tests.integration_tests.test_app import app
+
+
+@pytest.mark.parametrize(
+    "owner_names,creator_name,config,executor",
+    [
+        (["gamma"], None, [ReportScheduleExecutor.SELENIUM], "admin"),
+        (["gamma"], None, [ReportScheduleExecutor.OWNER], "gamma"),
+        (["alpha", "gamma"], "gamma", [ReportScheduleExecutor.CREATOR_OWNER], "gamma"),
+        (["alpha", "gamma"], "alpha", [ReportScheduleExecutor.CREATOR_OWNER], "alpha"),
+        (
+            ["alpha", "gamma"],
+            "admin",
+            [ReportScheduleExecutor.CREATOR_OWNER],
+            AlertQueryError(),
+        ),
+    ],
+)
+def test_execute_query_as_report_executor(
+    owner_names: List[str],
+    creator_name: Optional[str],
+    config: List[ReportScheduleExecutor],
+    executor: Union[str, Exception],

Review Comment:
   nit: it may be easier to read if you rename this to `expected_result` makes more sense when condensing usernames and exceptions



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro merged pull request #22167: fix(alerts): execute query as report executor

Posted by GitBox <gi...@apache.org>.
villebro merged PR #22167:
URL: https://github.com/apache/superset/pull/22167


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro commented on a diff in pull request #22167: fix(alerts): execute query as report executor

Posted by GitBox <gi...@apache.org>.
villebro commented on code in PR #22167:
URL: https://github.com/apache/superset/pull/22167#discussion_r1026343330


##########
tests/integration_tests/reports/alert_tests.py:
##########
@@ -15,10 +15,80 @@
 # specific language governing permissions and limitations
 # under the License.
 # pylint: disable=invalid-name, unused-argument, import-outside-toplevel
+from contextlib import nullcontext
+from typing import List, Optional, Union
 
 import pandas as pd
+import pytest
 from pytest_mock import MockFixture
 
+from superset.reports.commands.exceptions import AlertQueryError
+from superset.reports.models import ReportCreationMethod, ReportScheduleType
+from superset.reports.types import ReportScheduleExecutor
+from superset.utils.database import get_example_database
+from tests.integration_tests.test_app import app
+
+
+@pytest.mark.parametrize(
+    "owner_names,creator_name,config,executor",
+    [
+        (["gamma"], None, [ReportScheduleExecutor.SELENIUM], "admin"),
+        (["gamma"], None, [ReportScheduleExecutor.OWNER], "gamma"),
+        (["alpha", "gamma"], "gamma", [ReportScheduleExecutor.CREATOR_OWNER], "gamma"),
+        (["alpha", "gamma"], "alpha", [ReportScheduleExecutor.CREATOR_OWNER], "alpha"),
+        (
+            ["alpha", "gamma"],
+            "admin",
+            [ReportScheduleExecutor.CREATOR_OWNER],
+            AlertQueryError(),
+        ),
+    ],
+)
+def test_execute_query_as_report_executor(
+    owner_names: List[str],
+    creator_name: Optional[str],
+    config: List[ReportScheduleExecutor],
+    executor: Union[str, Exception],

Review Comment:
   Good idea! 👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #22167: fix(alerts): execute query as report executor

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #22167:
URL: https://github.com/apache/superset/pull/22167#issuecomment-1319881420

   # [Codecov](https://codecov.io/gh/apache/superset/pull/22167?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#22167](https://codecov.io/gh/apache/superset/pull/22167?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (10984bd) into [master](https://codecov.io/gh/apache/superset/commit/17c2bd89a6ecc480851801d58fadbf130704f784?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (17c2bd8) will **decrease** coverage by `11.45%`.
   > The diff coverage is `50.00%`.
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #22167       +/-   ##
   ===========================================
   - Coverage   66.99%   55.54%   -11.46%     
   ===========================================
     Files        1833     1833               
     Lines       69936    69938        +2     
     Branches     7572     7572               
   ===========================================
   - Hits        46855    38846     -8009     
   - Misses      21121    29132     +8011     
     Partials     1960     1960               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `?` | |
   | mysql | `?` | |
   | postgres | `?` | |
   | presto | `52.49% <50.00%> (-0.01%)` | :arrow_down: |
   | python | `57.45% <50.00%> (-23.94%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `50.89% <0.00%> (-0.01%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/22167?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset/reports/commands/alert.py](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvcmVwb3J0cy9jb21tYW5kcy9hbGVydC5weQ==) | `35.55% <50.00%> (-61.04%)` | :arrow_down: |
   | [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvZGFzaGJvYXJkX2ltcG9ydF9leHBvcnQucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [superset/tags/core.py](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdGFncy9jb3JlLnB5) | `4.54% <0.00%> (-95.46%)` | :arrow_down: |
   | [superset/key\_value/commands/update.py](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL3VwZGF0ZS5weQ==) | `0.00% <0.00%> (-90.91%)` | :arrow_down: |
   | [superset/key\_value/commands/delete.py](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZS5weQ==) | `0.00% <0.00%> (-87.88%)` | :arrow_down: |
   | [superset/db\_engines/hive.py](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lcy9oaXZlLnB5) | `0.00% <0.00%> (-85.19%)` | :arrow_down: |
   | [superset/key\_value/commands/delete\_expired.py](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZV9leHBpcmVkLnB5) | `0.00% <0.00%> (-84.00%)` | :arrow_down: |
   | [superset/dashboards/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGFzaGJvYXJkcy9jb21tYW5kcy9pbXBvcnRlcnMvdjAucHk=) | `15.62% <0.00%> (-76.25%)` | :arrow_down: |
   | [superset/datasets/commands/create.py](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvY3JlYXRlLnB5) | `30.61% <0.00%> (-69.39%)` | :arrow_down: |
   | [superset/datasets/commands/update.py](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvdXBkYXRlLnB5) | `25.00% <0.00%> (-69.05%)` | :arrow_down: |
   | ... and [283 more](https://codecov.io/gh/apache/superset/pull/22167/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org