Skip to content

Conversation

@coopergillan
Copy link
Contributor

BEST REVIEWED COMMIT-BY-COMMIT

Problem

Currently many different sensors and operators are tested in the Hive operators module. Some of these operators already have test modules and others do not. This was originally called out by @mik-lag in #7316.

Solution

  • Move non-operator tests into separate test modules, creating new ones as needed.
  • Create a shared TestHiveEnvironment class from unittest.TestCase that each of the test modules can use
  • Preserve existing test functionality and skipping when adding tests to existing modules
  • Update test names when being added to a more general module like test_sql_sensor.py

Issue link: AIRFLOW-6721

Make sure to mark the boxes below before creating PR: [x]

  • Description above provides context of the change
  • Commit message/PR title starts with [AIRFLOW-NNNN]. AIRFLOW-NNNN = JIRA ID*
  • Unit tests coverage for changes (not needed for documentation changes)
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in Contribution Workflow Example.

* For document-only changes commit message can start with [AIRFLOW-XXXX].


In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.

Move the WebHdfsSensor tests out of the operator tests and into a
separate module.
Movee the TestHiveEnvironment class and setUp method out to the hive
test module so that it can be used in other hive tests.
Move skipped test for HiveStatsCollectionOperator to the test_hive_stats
module to make it easier to locate.
Move the NamedHivePartitionSensor tests from the operators module into
the test module for NamedHivePartitionSensor.
Move the HivePartitionSensor tests from the operators module into
the a new test module.
Move the HiveToMySqlTransfer test in the operators module into
the existing test module and use the shared test environment for
these tests.
Move the HdfsSensor test in the operators module into a new test
module and use the shared test environment.
Move the Hive2SambaOperator test in the operators module into the
existing test module and use the shared test environment.
Move the MetastorePartitionSensor test from the operators module
into a new module and use the shared test environment.
Move the PrestoToMySqlTransfer test from the operators module
into an existing test module and use shared Hive test environment.
Move the PrestoCheckOperator test from the Hive operators module
into a new Presto operators test module while still using the
shared Hive test environment.
Move the SqlSensor in the Hive operators module into the existing
SqlSensor test module and label it as such. Use the shared test
environment for all tests, ensuring that original setUp properties
are preserved for the existing tests.
@coopergillan coopergillan force-pushed the AIRFLOW-6721-reorganize-hive-tests branch from 1495461 to edc415d Compare February 19, 2020 16:18
@codecov-io
Copy link

Codecov Report

Merging #7468 into master will decrease coverage by 0.45%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7468      +/-   ##
==========================================
- Coverage   86.68%   86.22%   -0.46%     
==========================================
  Files         882      882              
  Lines       41526    41526              
==========================================
- Hits        35997    35806     -191     
- Misses       5529     5720     +191
Impacted Files Coverage Δ
...w/providers/apache/hive/operators/mysql_to_hive.py 35.84% <0%> (-64.16%) ⬇️
airflow/kubernetes/volume_mount.py 44.44% <0%> (-55.56%) ⬇️
airflow/kubernetes/volume.py 52.94% <0%> (-47.06%) ⬇️
airflow/security/kerberos.py 30.43% <0%> (-45.66%) ⬇️
airflow/kubernetes/pod_launcher.py 47.18% <0%> (-45.08%) ⬇️
airflow/providers/mysql/operators/mysql.py 55% <0%> (-45%) ⬇️
...viders/cncf/kubernetes/operators/kubernetes_pod.py 69.38% <0%> (-25.52%) ⬇️
airflow/kubernetes/refresh_config.py 50.98% <0%> (-23.53%) ⬇️
airflow/providers/apache/hive/hooks/hive.py 76.02% <0%> (-1.54%) ⬇️
airflow/hooks/dbapi_hook.py 90.9% <0%> (-0.83%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e5d272...edc415d. Read the comment docs.

Copy link
Member

@mik-laj mik-laj left a comment

Choose a reason for hiding this comment

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

Perfect!

@mik-laj
Copy link
Member

mik-laj commented Feb 19, 2020

Can you create a ticket about AIRFLOW_RUNALL_TESTS environment variable? This should be replaced by pytest markers.
More information: https://github.com/apache/airflow/blob/master/TESTING.rst#airflow-integration-tests

@mik-laj mik-laj merged commit e91d615 into apache:master Feb 19, 2020
@coopergillan
Copy link
Contributor Author

@coopergillan coopergillan deleted the AIRFLOW-6721-reorganize-hive-tests branch February 19, 2020 21:21
galuszkak pushed a commit to FlyrInc/apache-airflow that referenced this pull request Mar 5, 2020
* [AIRFLOW-6721] Move WebHdfsSensor tests to own module

Move the WebHdfsSensor tests out of the operator tests and into a
separate module.

* [AIRFLOW-6721] Move TestHiveEnvironment to test module

Movee the TestHiveEnvironment class and setUp method out to the hive
test module so that it can be used in other hive tests.

* [AIRFLOW-6721] Move Hive Stats tests to separate module

Move skipped test for HiveStatsCollectionOperator to the test_hive_stats
module to make it easier to locate.

* [AIRFLOW-6721] Move NamedHivePartitionSensor tests

Move the NamedHivePartitionSensor tests from the operators module into
the test module for NamedHivePartitionSensor.

* [AIRFLOW-6721] Move HivePartitionSensor tests

Move the HivePartitionSensor tests from the operators module into
the a new test module.

* [AIRFLOW-6721] Move HiveToMySqlTransfer test

Move the HiveToMySqlTransfer test in the operators module into
the existing test module and use the shared test environment for
these tests.

* [AIRFLOW-6721] Move HdfsSensor test to separate module

Move the HdfsSensor test in the operators module into a new test
module and use the shared test environment.

* [AIRFLOW-6721] Move Hive2SambaOperator test

Move the Hive2SambaOperator test in the operators module into the
existing test module and use the shared test environment.

* [AIRFLOW-6721] Move Hive MetastorePartitionSensor test

Move the MetastorePartitionSensor test from the operators module
into a new module and use the shared test environment.

* [AIRFLOW-6721] Move Hive PrestoToMySqlTransfer test

Move the PrestoToMySqlTransfer test from the operators module
into an existing test module and use shared Hive test environment.

* [AIRFLOW-6721] Move PrestoCheckOperator test

Move the PrestoCheckOperator test from the Hive operators module
into a new Presto operators test module while still using the
shared Hive test environment.

* [AIRFLOW-6721] Move Hive SqlSensor test

Move the SqlSensor in the Hive operators module into the existing
SqlSensor test module and label it as such. Use the shared test
environment for all tests, ensuring that original setUp properties
are preserved for the existing tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants