You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/03/19 16:23:31 UTC

[GitHub] [airflow] potiuk opened a new pull request #7770: [AIRFLOW-7069] Fix cloudsql system tests

potiuk opened a new pull request #7770: [AIRFLOW-7069] Fix cloudsql system tests
URL: https://github.com/apache/airflow/pull/7770
 
 
   ---
   Issue link: WILL BE INSERTED BY [boring-cyborg](https://github.com/kaxil/boring-cyborg)
   
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [x] Commit message/PR title starts with `[AIRFLOW-NNNN]`. AIRFLOW-NNNN = JIRA ID<sup>*</sup>
   - [x] Unit tests coverage for changes (not needed for documentation changes)
   - [x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [x] Relevant documentation is updated including usage instructions.
   - [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   <sup>*</sup> For document-only changes commit message can start with `[AIRFLOW-XXXX]`.
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] turbaszek commented on a change in pull request #7770: [AIRFLOW-7069] Fix CloudSQL system tests

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #7770: [AIRFLOW-7069] Fix CloudSQL system tests
URL: https://github.com/apache/airflow/pull/7770#discussion_r395295835
 
 

 ##########
 File path: airflow/providers/google/cloud/hooks/cloud_sql.py
 ##########
 @@ -324,21 +315,14 @@ def export_instance(self, instance: str, body: Dict, project_id: Optional[str] =
         :type project_id: str
         :return: None
         """
-        if not project_id:
-            raise ValueError("The project_id should be set")
 
 Review comment:
   This should not be removed I think

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] potiuk commented on a change in pull request #7770: [AIRFLOW-7069] Fix cloudsql system tests

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #7770: [AIRFLOW-7069] Fix cloudsql system tests
URL: https://github.com/apache/airflow/pull/7770#discussion_r395207261
 
 

 ##########
 File path: tests/providers/google/cloud/hooks/test_cloud_sql.py
 ##########
 @@ -1210,32 +1198,30 @@ def test_hook_with_not_too_long_unix_socket_path(self, get_connection):
         self.assertEqual('postgres', connection.conn_type)
         self.assertEqual('testdb', connection.schema)
 
-    @mock.patch("airflow.providers.google.cloud.hooks.cloud_sql.CloudSQLDatabaseHook.get_connection")
-    def test_hook_with_correct_parameters_postgres(self, get_connection):
-        uri = "gcpcloudsql://user:password@127.0.0.1:3200/testdb?database_type=postgres&" \
-              "project_id=example-project&location=europe-west1&instance=testdb&" \
-              "use_proxy=False&use_ssl=False"
+    def _verify_postgres_connection(self, get_connection, uri):
 
 Review comment:
   Me too (as you will see in many places below) . But sometimes it's quite ok to add some DRYness to the DAMPness. Especially when you actually test something else those tests are DAMP-first DRY-little.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] potiuk merged pull request #7770: [AIRFLOW-7069] Fix CloudSQL system tests

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #7770: [AIRFLOW-7069] Fix CloudSQL system tests
URL: https://github.com/apache/airflow/pull/7770
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] potiuk commented on a change in pull request #7770: [AIRFLOW-7069] Fix CloudSQL system tests

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #7770: [AIRFLOW-7069] Fix CloudSQL system tests
URL: https://github.com/apache/airflow/pull/7770#discussion_r395297024
 
 

 ##########
 File path: airflow/providers/google/cloud/hooks/cloud_sql.py
 ##########
 @@ -270,19 +263,18 @@ def patch_database(
         :type project_id: str
         :return: None
         """
-        if not project_id:
-            raise ValueError("The project_id should be set")
-        response = self.get_conn().databases().patch(  # pylint: disable=no-member
+        response = self.get_conn().databases().patch(  # noqa # pylint: disable=no-member
             project=project_id,
             instance=instance,
             database=database,
             body=body
         ).execute(num_retries=self.num_retries)
         operation_name = response["name"]
-        self._wait_for_operation_to_complete(project_id=project_id,
+        self._wait_for_operation_to_complete(project_id=project_id,  # type:ignore
                                              operation_name=operation_name)
 
     @CloudBaseHook.fallback_to_default_project_id
+    @CloudBaseHook.operation_in_progress_retry()
 
 Review comment:
   yes. it returns a decorator  - this was copied from the quota_retry() and it is an easy way to get the tenacity default values for retry 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] mik-laj commented on a change in pull request #7770: [AIRFLOW-7069] Fix cloudsql system tests

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #7770: [AIRFLOW-7069] Fix cloudsql system tests
URL: https://github.com/apache/airflow/pull/7770#discussion_r395203132
 
 

 ##########
 File path: tests/providers/google/cloud/hooks/test_cloud_sql.py
 ##########
 @@ -1210,32 +1198,30 @@ def test_hook_with_not_too_long_unix_socket_path(self, get_connection):
         self.assertEqual('postgres', connection.conn_type)
         self.assertEqual('testdb', connection.schema)
 
-    @mock.patch("airflow.providers.google.cloud.hooks.cloud_sql.CloudSQLDatabaseHook.get_connection")
-    def test_hook_with_correct_parameters_postgres(self, get_connection):
-        uri = "gcpcloudsql://user:password@127.0.0.1:3200/testdb?database_type=postgres&" \
-              "project_id=example-project&location=europe-west1&instance=testdb&" \
-              "use_proxy=False&use_ssl=False"
+    def _verify_postgres_connection(self, get_connection, uri):
 
 Review comment:
   Personally, I prefer the DAMP principle in testing.
   https://testing.googleblog.com/2019/12/testing-on-toilet-tests-too-dry-make.html
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] potiuk commented on a change in pull request #7770: [AIRFLOW-7069] Fix CloudSQL system tests

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #7770: [AIRFLOW-7069] Fix CloudSQL system tests
URL: https://github.com/apache/airflow/pull/7770#discussion_r395297812
 
 

 ##########
 File path: airflow/providers/google/cloud/hooks/cloud_sql.py
 ##########
 @@ -324,21 +315,14 @@ def export_instance(self, instance: str, body: Dict, project_id: Optional[str] =
         :type project_id: str
         :return: None
         """
-        if not project_id:
-            raise ValueError("The project_id should be set")
 
 Review comment:
   It can be removed. We have the fallback_to_default_poject_id which will throw an error if project_id cannot be retrieved.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] turbaszek commented on a change in pull request #7770: [AIRFLOW-7069] Fix CloudSQL system tests

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #7770: [AIRFLOW-7069] Fix CloudSQL system tests
URL: https://github.com/apache/airflow/pull/7770#discussion_r395295628
 
 

 ##########
 File path: airflow/providers/google/cloud/hooks/cloud_sql.py
 ##########
 @@ -270,19 +263,18 @@ def patch_database(
         :type project_id: str
         :return: None
         """
-        if not project_id:
-            raise ValueError("The project_id should be set")
-        response = self.get_conn().databases().patch(  # pylint: disable=no-member
+        response = self.get_conn().databases().patch(  # noqa # pylint: disable=no-member
             project=project_id,
             instance=instance,
             database=database,
             body=body
         ).execute(num_retries=self.num_retries)
         operation_name = response["name"]
-        self._wait_for_operation_to_complete(project_id=project_id,
+        self._wait_for_operation_to_complete(project_id=project_id,  # type:ignore
                                              operation_name=operation_name)
 
     @CloudBaseHook.fallback_to_default_project_id
+    @CloudBaseHook.operation_in_progress_retry()
 
 Review comment:
   Do we need this () brackets?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services